# HG changeset patch # User Doug Simon # Date 1451138455 -3600 # Node ID 4cf1946f59fc4438eecdbe9ff25ed5388531d7b6 # Parent 577a4a8caa72d06edaef3d40a4d24022df2a8e7c must not fold accesses to @Stable fields if -XX:-FoldStableValues (GRAAL-58) diff -r 577a4a8caa72 -r 4cf1946f59fc jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Thu Dec 24 09:50:27 2015 -1000 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java Sat Dec 26 15:00:55 2015 +0100 @@ -238,7 +238,7 @@ * {@link #readConstantFieldValue(ResolvedJavaField, 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; @@ -302,7 +302,7 @@ 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())) { @@ -319,8 +319,10 @@ HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; if (!hotspotField.isStable()) { return readNonStableFieldValue(field, receiver); + } else if (runtime.getConfig().foldStableValues) { + return readStableFieldValue(field, receiver, hotspotField.isDefaultStable()); } else { - return readStableFieldValue(field, receiver, hotspotField.isDefaultStable()); + return null; } } diff -r 577a4a8caa72 -r 4cf1946f59fc jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java Thu Dec 24 09:50:27 2015 -1000 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java Sat Dec 26 15:00:55 2015 +0100 @@ -40,17 +40,14 @@ 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.). This result of this method is undefined if this field is not + * {@linkplain #isStable() stable}. */ boolean isDefaultStable(); } diff -r 577a4a8caa72 -r 4cf1946f59fc jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java --- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Thu Dec 24 09:50:27 2015 -1000 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Sat Dec 26 15:00:55 2015 +0100 @@ -733,6 +733,7 @@ @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; @HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking; @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; + @HotSpotVMFlag(name = "FoldStableValues") @Stable public boolean foldStableValues; @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking;