changeset 5686:6cb39a47da14

replaced loading of instance prototype header word with a constant obtained from HotSpotResolvedJavaType
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 Jun 2012 17:16:57 +0200
parents 757fc384f9b7
children 5d06e32f10df
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java src/share/vm/graal/graalCompiler.cpp src/share/vm/graal/graalJavaAccess.hpp
diffstat 4 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java	Fri Jun 22 16:42:01 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java	Fri Jun 22 17:16:57 2012 +0200
@@ -54,6 +54,7 @@
     private ConstantPool constantPool;
     private boolean isInitialized;
     private ResolvedJavaType arrayOfType;
+    private long prototypeHeader;
 
     private HotSpotResolvedJavaType() {
         throw new GraalInternalError(HotSpotResolvedJavaType.class + " should only be created from C++ code");
@@ -283,4 +284,8 @@
     public int superCheckOffset() {
         return superCheckOffset;
     }
+
+    public long prototypeHeader() {
+        return prototypeHeader;
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Fri Jun 22 16:42:01 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Fri Jun 22 17:16:57 2012 +0200
@@ -70,12 +70,13 @@
     public static Object initialize(
                     @Parameter("memory") Word memory,
                     @Parameter("hub") Object hub,
+                    @Parameter("prototypeHeader") Word headerPrototype,
                     @ConstantParameter("size") int size) {
 
         if (memory == Word.zero()) {
             return NewInstanceStubCall.call(hub);
         }
-        formatObject(hub, size, memory);
+        formatObject(hub, size, memory, headerPrototype);
         Object instance = memory.toObject();
         return castFromHub(verifyOop(instance), hub);
     }
@@ -91,11 +92,6 @@
         return Word.fromObject(object);
     }
 
-    private static Word loadWord(Object object, int offset) {
-        Object value = loadObject(object, 0, offset, true);
-        return asWord(value);
-    }
-
     private static Word loadWord(Word address, int offset) {
         Object value = loadObject(address, 0, offset, true);
         return asWord(value);
@@ -104,8 +100,7 @@
     /**
      * Formats some allocated memory with an object header zeroes out the rest.
      */
-    private static void formatObject(Object hub, int size, Word memory) {
-        Word headerPrototype = loadWord(hub, instanceHeaderPrototypeOffset());
+    private static void formatObject(Object hub, int size, Word memory, Word headerPrototype) {
         store(memory, 0, 0, headerPrototype);
         store(memory, 0, hubOffset(), hub);
         explodeLoop();
@@ -140,11 +135,6 @@
     }
 
     @Fold
-    private static int instanceHeaderPrototypeOffset() {
-        return HotSpotGraalRuntime.getInstance().getConfig().instanceHeaderPrototypeOffset;
-    }
-
-    @Fold
     private static int hubOffset() {
         return HotSpotGraalRuntime.getInstance().getConfig().hubOffset;
     }
@@ -163,7 +153,7 @@
             this.useTLAB = useTLAB;
             try {
                 allocate = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("allocate", int.class));
-                initialize = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("initialize", Word.class, Object.class, int.class));
+                initialize = runtime.getResolvedJavaMethod(NewInstanceSnippets.class.getDeclaredMethod("initialize", Word.class, Object.class, Word.class, int.class));
             } catch (NoSuchMethodException e) {
                 throw new GraalInternalError(e);
             }
@@ -217,7 +207,7 @@
             Key key = new Key(initialize).add("size", size);
             ValueNode memory = initializeNode.memory();
             //assert memory instanceof AllocateNode || memory instanceof ConstantNode : memory;
-            Arguments arguments = arguments("memory", memory).add("hub", hub);
+            Arguments arguments = arguments("memory", memory).add("hub", hub).add("prototypeHeader", type.prototypeHeader());
             SnippetTemplate template = cache.get(key);
             Debug.log("Lowering initialize in %s: node=%s, template=%s, arguments=%s", graph, initializeNode, template, arguments);
             template.instantiate(runtime, initializeNode, initializeNode, arguments);
--- a/src/share/vm/graal/graalCompiler.cpp	Fri Jun 22 16:42:01 2012 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Fri Jun 22 17:16:57 2012 +0200
@@ -273,6 +273,7 @@
   HotSpotResolvedJavaType::set_accessFlags(obj, klass->access_flags().as_int());
   HotSpotResolvedJavaType::set_isInterface(obj, klass->is_interface());
   HotSpotResolvedJavaType::set_superCheckOffset(obj, klass->super_check_offset());
+  HotSpotResolvedJavaType::set_prototypeHeader(obj, (jlong) klass->prototype_header());
   HotSpotResolvedJavaType::set_isInstanceClass(obj, klass->oop_is_instance());
 
   if (klass->oop_is_javaArray()) {
--- a/src/share/vm/graal/graalJavaAccess.hpp	Fri Jun 22 16:42:01 2012 +0200
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Fri Jun 22 17:16:57 2012 +0200
@@ -49,6 +49,7 @@
     oop_field(HotSpotResolvedJavaType, javaMirror, "Ljava/lang/Class;")                     \
     oop_field(HotSpotResolvedJavaType, simpleName, "Ljava/lang/String;")                    \
     int_field(HotSpotResolvedJavaType, accessFlags)                                         \
+    long_field(HotSpotResolvedJavaType, prototypeHeader)                                    \
     boolean_field(HotSpotResolvedJavaType, hasFinalizer)                                    \
     boolean_field(HotSpotResolvedJavaType, hasFinalizableSubclass)                          \
     int_field(HotSpotResolvedJavaType, superCheckOffset)                                    \