changeset 6379:ad97777056ec

Checks on vtableEntryOffset to avoid calling to the VM if the holder is not initialized
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 12 Sep 2012 13:07:35 +0200
parents f8416485a37f
children a718f153b9f2
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 3 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Wed Sep 12 11:29:34 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Wed Sep 12 13:07:35 2012 +0200
@@ -279,7 +279,15 @@
         return canBeInlined;
     }
 
+    /**
+     * Returns the offset of this method into the v-table.
+     * If the holder is not initialized, returns -1
+     * @return the offset of this method into the v-table
+     */
     public int vtableEntryOffset() {
+        if (!holder.isInitialized()) {
+            return -1;
+        }
         return HotSpotGraalRuntime.getInstance().getCompilerToVM().JavaMethod_vtableEntryOffset(this);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Sep 12 11:29:34 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Sep 12 13:07:35 2012 +0200
@@ -254,7 +254,7 @@
                         // We use LocationNode.ANY_LOCATION for the reads that access the vtable entry and the compiled code entry
                         // as HotSpot does not guarantee they are final values.
                         int vtableEntryOffset = hsMethod.vtableEntryOffset();
-                        assert vtableEntryOffset != 0;
+                        assert vtableEntryOffset > 0;
                         SafeReadNode hub = safeReadHub(graph, receiver, StructuredGraph.INVALID_GRAPH_ID);
                         Kind wordKind = graalRuntime.getTarget().wordKind;
                         Stamp nonNullWordStamp = StampFactory.forWord(wordKind, true);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Sep 12 11:29:34 2012 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Sep 12 13:07:35 2012 +0200
@@ -939,6 +939,7 @@
 
   methodOop method = getMethodFromHotSpotMethod(hotspot_method);
   assert(!instanceKlass::cast(method->method_holder())->is_interface(), "vtableEntryOffset cannot be called for interface methods");
+  assert(instanceKlass::cast(method->method_holder())->is_linked(), "vtableEntryOffset cannot be called is holder is not linked");
 
   // get entry offset in words
   int vtable_entry_offset = instanceKlass::vtable_start_offset() + method->vtable_index() * vtableEntry::size();