changeset 22664:47f047ae2b4b

Make default values stable in enum switch maps Added isDefaultStable to HotSpotResolvedJavaField Fixed reference to Stable annotation
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Wed, 07 Oct 2015 14:55:08 +0200
parents 41b97852175d
children d92c9f043d02
files jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java
diffstat 4 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java	Wed Oct 07 13:32:56 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantReflectionProvider.java	Wed Oct 07 14:55:08 2015 +0200
@@ -338,7 +338,7 @@
         if (!hotspotField.isStable()) {
             return readNonStableFieldValue(field, receiver);
         } else {
-            return readStableFieldValue(field, receiver, false);
+            return readStableFieldValue(field, receiver, hotspotField.isDefaultStable());
         }
     }
 
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java	Wed Oct 07 13:32:56 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaField.java	Wed Oct 07 14:55:08 2015 +0200
@@ -45,4 +45,12 @@
      * @return true if field has {@link Stable} annotation, false otherwise
      */
     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
+     */
+    boolean isDefaultStable();
 }
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java	Wed Oct 07 13:32:56 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java	Wed Oct 07 14:55:08 2015 +0200
@@ -250,19 +250,25 @@
     }
 
     private boolean isImplicitStableField() {
-        if (isSynthetic()) {
-            if (isSyntheticImplicitStableField()) {
-                return true;
-            }
-        } else if (isWellKnownImplicitStableField()) {
+        if (isSyntheticEnumSwitchMap()) {
+            return true;
+        }
+        if (isWellKnownImplicitStableField()) {
             return true;
         }
         return false;
     }
 
-    private boolean isSyntheticImplicitStableField() {
-        assert this.isSynthetic();
-        if (isStatic() && isArray()) {
+    public boolean isDefaultStable() {
+        assert this.isStable();
+        if (isSyntheticEnumSwitchMap()) {
+            return true;
+        }
+        return false;
+    }
+
+    private boolean isSyntheticEnumSwitchMap() {
+        if (isSynthetic() && isStatic() && isArray()) {
             if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) {
                 // generated int[] field for EnumClass::values()
                 return true;
@@ -288,6 +294,7 @@
         }
 
         private static final ResolvedJavaField STRING_VALUE_FIELD;
+
         static {
             try {
                 MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess();
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java	Wed Oct 07 13:32:56 2015 +0200
+++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/Stable.java	Wed Oct 07 14:55:08 2015 +0200
@@ -29,8 +29,8 @@
 import java.lang.annotation.Target;
 
 /**
- * This annotation functions as an alias for the sun.invoke.Stable annotation within JVMCI code. It
- * is specially recognized during class file parsing in the same way as that annotation.
+ * This annotation functions as an alias for the java.lang.invoke.Stable annotation within JVMCI
+ * code. It is specially recognized during class file parsing in the same way as that annotation.
  */
 @Target(ElementType.FIELD)
 @Retention(RetentionPolicy.RUNTIME)