mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-24 04:54:40 +02:00
8146157: JVMCI must not fold accesses to @Stable fields if -XX:-FoldStableValues
Reviewed-by: twisti
This commit is contained in:
parent
28154b095e
commit
ae88612f52
3 changed files with 12 additions and 11 deletions
|
@ -242,7 +242,7 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProv
|
|||
* {@link #readConstantFieldValue(JavaField, JavaConstant)}.
|
||||
*/
|
||||
protected boolean isStaticFieldConstant(HotSpotResolvedJavaField staticField) {
|
||||
if (staticField.isFinal() || staticField.isStable()) {
|
||||
if (staticField.isFinal() || (staticField.isStable() && runtime.getConfig().foldStableValues)) {
|
||||
ResolvedJavaType holder = staticField.getDeclaringClass();
|
||||
if (holder.isInitialized() && !holder.getName().equals(SystemClassName)) {
|
||||
return true;
|
||||
|
@ -312,7 +312,7 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProv
|
|||
return value;
|
||||
}
|
||||
}
|
||||
} else if (hotspotField.isStable()) {
|
||||
} else if (hotspotField.isStable() && runtime.getConfig().foldStableValues) {
|
||||
if (hotspotField.isInObject(object)) {
|
||||
JavaConstant value = readFieldValue(field, receiver);
|
||||
if (isStableInstanceFieldValueConstant(value, object.getClass())) {
|
||||
|
@ -337,8 +337,10 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProv
|
|||
HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field;
|
||||
if (!hotspotField.isStable()) {
|
||||
return readNonStableFieldValue(field, receiver);
|
||||
} else {
|
||||
} else if (runtime.getConfig().foldStableValues) {
|
||||
return readStableFieldValue(field, receiver, hotspotField.isDefaultStable());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -40,17 +40,14 @@ public interface HotSpotResolvedJavaField extends ResolvedJavaField {
|
|||
int offset();
|
||||
|
||||
/**
|
||||
* Checks if this field has the {@link Stable} annotation.
|
||||
*
|
||||
* @return true if field has {@link Stable} annotation, false otherwise
|
||||
* Determines if this field should be treated as a constant.
|
||||
*/
|
||||
boolean isStable();
|
||||
|
||||
/**
|
||||
* If this field is stable, checks if default values (0, null, etc.) should be considered stable
|
||||
* as well.
|
||||
*
|
||||
* @return true if default values should be considered stable, false otherwise
|
||||
* Determines if this field should be considered constant if it has the default value for its
|
||||
* type (e.g, 0, null, etc.). The result of this method is undefined if this field is not
|
||||
* {@linkplain #isStable() stable}.
|
||||
*/
|
||||
boolean isDefaultStable();
|
||||
}
|
||||
|
|
|
@ -853,6 +853,7 @@ public class HotSpotVMConfig {
|
|||
@HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking;
|
||||
@HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable;
|
||||
@HotSpotVMFlag(name = "CodeCacheSegmentSize") @Stable public int codeSegmentSize;
|
||||
@HotSpotVMFlag(name = "FoldStableValues") @Stable public boolean foldStableValues;
|
||||
|
||||
@HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB;
|
||||
@HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking;
|
||||
|
@ -1683,6 +1684,7 @@ public class HotSpotVMConfig {
|
|||
@HotSpotVMConstant(name = "ArrayData::array_len_off_set") @Stable public int arrayDataArrayLenOffset;
|
||||
@HotSpotVMConstant(name = "ArrayData::array_start_off_set") @Stable public int arrayDataArrayStartOffset;
|
||||
@HotSpotVMConstant(name = "MultiBranchData::per_case_cell_count") @Stable public int multiBranchDataPerCaseCellCount;
|
||||
|
||||
// Checkstyle: resume
|
||||
|
||||
private boolean check() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue