changeset 7004:1d419abb0081

made the initialize state of the jump instruction in a static call stub conform to that expected by an assertion in the runtime Expanded documentation on the design and usage of static call stubs.
author Doug Simon <doug.simon@oracle.com>
date Thu, 22 Nov 2012 23:34:49 +0100
parents bb524ee6b8e9
children 45029b3ac59f
files graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DirectCallOp.java src/share/vm/code/compiledIC.cpp
diffstat 2 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DirectCallOp.java	Thu Nov 22 23:32:10 2012 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DirectCallOp.java	Thu Nov 22 23:34:49 2012 +0100
@@ -27,11 +27,10 @@
 import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.code.CompilationResult.Mark;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.*;
+import com.oracle.graal.lir.LIRInstruction.Opcode;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
 import com.oracle.graal.lir.asm.*;
@@ -45,7 +44,23 @@
  * 0L constant with Universe::non_oop_word(), a special sentinel
  * used for the initial value of the Klass in an inline cache.
  * <p>
- * For non-inline cache calls, a static call stub is emitted.
+ * For non-inline cache calls (i.e., INVOKESTATIC and INVOKESPECIAL), a static
+ * call stub is emitted. Initially, these calls go to the global static call
+ * resolution stub (i.e., SharedRuntime::get_resolve_static_call_stub()).
+ * Resolution will link the call to a compiled version of the callee if
+ * available otherwise to the interpreter. The interpreter expects to
+ * find the Method* for the callee in RBX. To achieve this, the static call
+ * is linked to a static call stub which initializes RBX and jumps to the
+ * interpreter. This pattern is shown below:
+ * <pre>
+ *       call L1
+ *       nop
+ *
+ *       ...
+ *
+ *   L1: mov rbx [Method*]
+ *       jmp [interpreter entry point]
+ * </pre>
  */
 @Opcode("CALL_DIRECT")
 final class AMD64DirectCallOp extends DirectCallOp {
@@ -73,9 +88,9 @@
                     assert callsiteMark != null : "static call site has not yet been emitted";
                     tasm.recordMark(Marks.MARK_STATIC_CALL_STUB, callsiteMark);
                     masm.movq(AMD64.rbx, 0L);
-                    Label dummy = new Label();
-                    masm.jmp(dummy);
-                    masm.bind(dummy);
+                    int pos = masm.codeBuffer.position();
+                    // Create a jump-to-self as expected by CompiledStaticCall::set_to_interpreted() in compiledIC.cpp
+                    masm.jmp(pos, true);
                 }
             });
         }
--- a/src/share/vm/code/compiledIC.cpp	Thu Nov 22 23:32:10 2012 +0100
+++ b/src/share/vm/code/compiledIC.cpp	Thu Nov 22 23:34:49 2012 +0100
@@ -565,10 +565,7 @@
   NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
 
   assert(method_holder->data()    == 0           || method_holder->data()    == (intptr_t)callee(), "a) MT-unsafe modification of inline cache");
-// TODO(thomaswue): Check what is the correct assert for Graal.
-#ifndef GRAAL
   assert(jump->jump_destination() == (address)-1 || jump->jump_destination() == entry, "b) MT-unsafe modification of inline cache");
-#endif
 
   // Update stub
   method_holder->set_data((intptr_t)callee());