changeset 3429:c6f9c897ea33

opto: specify offset of IC load in java_to_interp stub. If a compiled static call calls the interpreter, it jumps past a java_to_interp stub in the compiled code. Patching this call must find the load of the IC. So far the code assumed this is the first instruction in the stub. This might not be the case if, for example, the base of the constant table (toc) must be loaded. Extend CompiledStaticCall to consider an offset from it's beginning where to search the load of the IC.
author Goetz
date Wed, 14 Nov 2012 10:43:39 +0100
parents 884572fbb976
children db119a925e97
files src/cpu/ppc/vm/ppc.ad src/cpu/sparc/vm/sparc.ad src/cpu/x86/vm/x86_32.ad src/cpu/x86/vm/x86_64.ad src/share/vm/adlc/main.cpp src/share/vm/code/compiledIC.cpp src/share/vm/code/compiledIC.hpp
diffstat 7 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/ppc/vm/ppc.ad	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/cpu/ppc/vm/ppc.ad	Wed Nov 14 10:43:39 2012 +0100
@@ -1048,6 +1048,11 @@
 // is fixed up when the corresponding call is converted from calling compiled
 // code to calling interpreted code.
 
+// Offset from start of compiled java to interpreter stub to the load
+// constant that loads the inline cache (IC) (8 if we have to load
+// toc).
+const int CompiledStaticCall::comp_to_int_load_offset = 8;
+
 const uint java_to_interp_stub_size = 12 * BytesPerInstWord;
 
 void emit_java_to_interp_stub(MacroAssembler &_masm, const int insts_relocation_offset) {
--- a/src/cpu/sparc/vm/sparc.ad	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/cpu/sparc/vm/sparc.ad	Wed Nov 14 10:43:39 2012 +0100
@@ -1660,6 +1660,10 @@
 
 //=============================================================================
 
+// Offset from start of compiled java to interpreter stub to the load
+// constant that loads the inline cache (IC) (0 on sparc).
+const int CompiledStaticCall::comp_to_int_load_offset = 0;
+
 // emit call stub, compiled java to interpretor
 void emit_java_to_interp(CodeBuffer &cbuf ) {
 
@@ -9347,7 +9351,7 @@
   size(4);
   ins_cost(BRANCH_COST);
   format %{ "BA     $labl\t! short branch" %}
-  ins_encode %{ 
+  ins_encode %{
     Label* L = $labl$$label;
     assert(__ use_cbcond(*L), "back to back cbcond");
     __ ba_short(*L);
--- a/src/cpu/x86/vm/x86_32.ad	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/cpu/x86/vm/x86_32.ad	Wed Nov 14 10:43:39 2012 +0100
@@ -1168,6 +1168,10 @@
 
 //=============================================================================
 
+// Offset from start of compiled java to interpreter stub to the load
+// constant that loads the inline cache (IC) (0 on i486).
+const int CompiledStaticCall::comp_to_int_load_offset = 0;
+
 // emit call stub, compiled java to interpreter
 void emit_java_to_interp(CodeBuffer &cbuf ) {
   // Stub is fixed up when the corresponding call is converted from calling
--- a/src/cpu/x86/vm/x86_64.ad	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/cpu/x86/vm/x86_64.ad	Wed Nov 14 10:43:39 2012 +0100
@@ -1564,6 +1564,10 @@
 
 //=============================================================================
 
+// Offset from start of compiled java to interpreter stub to the load
+// constant that loads the inline cache (IC) (0 on amd64).
+const int CompiledStaticCall::comp_to_int_load_offset = 0;
+
 // emit call stub, compiled java to interpreter
 void emit_java_to_interp(CodeBuffer& cbuf)
 {
--- a/src/share/vm/adlc/main.cpp	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/share/vm/adlc/main.cpp	Wed Nov 14 10:43:39 2012 +0100
@@ -213,6 +213,7 @@
   AD.addInclude(AD._CPP_file, "adfiles", get_basename(AD._HPP_file._name));
   AD.addInclude(AD._CPP_file, "memory/allocation.inline.hpp");
   AD.addInclude(AD._CPP_file, "asm/assembler.hpp");
+  AD.addInclude(AD._CPP_file, "code/compiledIC.hpp");
   AD.addInclude(AD._CPP_file, "code/vmreg.hpp");
   AD.addInclude(AD._CPP_file, "gc_interface/collectedHeap.inline.hpp");
   AD.addInclude(AD._CPP_file, "oops/compiledICHolderOop.hpp");
--- a/src/share/vm/code/compiledIC.cpp	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/share/vm/code/compiledIC.cpp	Wed Nov 14 10:43:39 2012 +0100
@@ -524,7 +524,7 @@
                   callee->name_and_sig_as_C_string());
   }
 
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);   // creation also verifies the object
+  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + comp_to_int_load_offset);   // creation also verifies the object
   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");
@@ -587,7 +587,7 @@
   // Reset stub
   address stub = static_stub->addr();
   assert(stub!=NULL, "stub not found");
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);   // creation also verifies the object
+  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + comp_to_int_load_offset);   // creation also verifies the object
   NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
   method_holder->set_data(0);
   jump->set_jump_destination((address)-1);
@@ -666,11 +666,16 @@
   // Verify stub
   address stub = find_stub();
   assert(stub != NULL, "no stub found for static call");
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);   // creation also verifies the object
+  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + comp_to_int_load_offset);   // creation also verifies the object
+
   NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
 
   // Verify state
   assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
 }
 
+#endif // !PRODUCT
+
+#ifndef COMPILER2
+const int CompiledStaticCall::comp_to_int_load_offset = 0;
 #endif
--- a/src/share/vm/code/compiledIC.hpp	Wed Oct 31 15:15:29 2012 +0100
+++ b/src/share/vm/code/compiledIC.hpp	Wed Nov 14 10:43:39 2012 +0100
@@ -244,6 +244,10 @@
   // Misc.
   void print()  PRODUCT_RETURN;
   void verify() PRODUCT_RETURN;
+
+  // Offset of start of compiled java to interpreter stub to the load
+  // constant that loads the inline cache (IC). See ad file.
+  static const int comp_to_int_load_offset;
 };