changeset 10062:56fc40ca4ae0

HotSpotResolvedJavaField: don't embed caches of java.lang.{Integer,Long,Boolean} for replacements when compiled in AOT mode (GRAAL-290)
author Bernhard Urban <bernhard.urban@jku.at>
date Sun, 16 Jun 2013 23:55:19 +0200
parents b6dfe12478ff
children 9e688291fc53
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerifcationPhase.java
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Mon Jun 17 08:30:03 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Sun Jun 16 23:55:19 2013 +0200
@@ -32,6 +32,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.options.*;
+import com.oracle.graal.phases.*;
 import com.oracle.graal.replacements.*;
 
 /**
@@ -76,13 +77,21 @@
     }
 
     private static final String SystemClassName = MetaUtil.toInternalName(System.class.getName());
+    private static final String IntegerCacheClassName = "Ljava/lang/Integer$IntegerCache;";
+    private static final String LongCacheClassName = "Ljava/lang/Long$LongCache;";
+    private static final String BooleanCacheName = MetaUtil.toInternalName(Boolean.class.getName());
+
+    private boolean isConstantCache() {
+        String n = holder.getName();
+        return GraalOptions.AOTCompilation.getValue() && n.equals(IntegerCacheClassName) || n.equals(LongCacheClassName) || n.equals(BooleanCacheName);
+    }
 
     @Override
     public Constant readConstantValue(Constant receiver) {
         if (receiver == null) {
             assert Modifier.isStatic(flags);
             if (constant == null) {
-                if (holder.isInitialized() && !holder.getName().equals(SystemClassName)) {
+                if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && !isConstantCache()) {
                     if (Modifier.isFinal(getModifiers())) {
                         constant = readValue(receiver);
                     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerifcationPhase.java	Mon Jun 17 08:30:03 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerifcationPhase.java	Sun Jun 16 23:55:19 2013 +0200
@@ -31,7 +31,7 @@
     @Override
     protected boolean verify(StructuredGraph graph) {
         for (ConstantNode node : graph.getNodes().filter(ConstantNode.class)) {
-            assert !isOop(node) || isNullReference(node) || isString(node) : "embedded oop: " + node;
+            assert !isOop(node) || isNullReference(node) || isString(node) : "embedded oop: " + node + ". toString: " + node.asConstant().asObject();
         }
         return true;
     }