diff src/cpu/x86/vm/graalCodeInstaller_x86.hpp @ 11826:2d3d3d36ab3c

AMD64HotSpot: use conditional jump for IC_MISS_HANDLER
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 30 Sep 2013 11:16:36 +0200
parents 4c96ccce3772
children ff1d8605f354
line wrap: on
line diff
--- a/src/cpu/x86/vm/graalCodeInstaller_x86.hpp	Mon Sep 30 09:32:18 2013 +0200
+++ b/src/cpu/x86/vm/graalCodeInstaller_x86.hpp	Mon Sep 30 11:16:36 2013 +0200
@@ -50,6 +50,9 @@
     // the inlined vtable stub contains a "call register" instruction
     assert(method != NULL, "only valid for virtual calls");
     return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset());
+  } else if (inst->is_cond_jump()) {
+    address pc = (address) (inst);
+    return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc);
   } else {
     fatal("unsupported type of instruction for call site");
     return 0;
@@ -155,11 +158,19 @@
     NativeMovConstReg* mov = nativeMovConstReg_at((address) (inst));
     mov->set_data((intptr_t) foreign_call_destination);
     _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand);
-  } else {
+  } else if (inst->is_jump()) {
     NativeJump* jump = nativeJump_at((address) (inst));
     jump->set_jump_destination((address) foreign_call_destination);
-    _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand);
+    _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
+  } else if (inst->is_cond_jump()) {
+    address old_dest = nativeGeneralJump_at((address) (inst))->jump_destination();
+    address disp = Assembler::locate_operand((address) (inst), Assembler::call32_operand);
+    *(jint*) disp += ((address) foreign_call_destination) - old_dest;
+    _instructions->relocate((address) (inst), runtime_call_Relocation::spec(), Assembler::call32_operand);
+  } else {
+    fatal("unsupported relocation for foreign call");
   }
+
   TRACE_graal_3("relocating (foreign call)  at %p", inst);
 }