diff hotspot/src/cpu/x86/vm/icBuffer_x86.cpp @ 42650:1f304d0c888b

8171008: Integrate AOT compiler into JDK Reviewed-by: erikj, mchung, psandoz, coleenp, iklam, stefank, simonis Contributed-by: Bharadwaj Yadavalli <bharadwaj.yadavalli@oracle.com>, Christian Thalinger <cthalinger@twitter.com>, Dean Long <dean.long@oracle.com>, Dmitrij Pochepko <dmitrij.pochepko@oracle.com>, Dmitry Chuyko <dmitry.chuyko@oracle.com>, Doug Simon <doug.simon@oracle.com>, Eric Caspole <eric.caspole@oracle.com>, Igor Ignatyev <igor.ignatyev@oracle.com>, Igor Veresov <igor.veresov@oracle.com>, John Rose <john.r.rose@oracle.com>, Morris Meyer <morris.meyer@oracle.com>, Niclas Adlertz <niclas.adlertz@oracle.com>, Rickard Backman <rickard.backman@oracle.com>
author kvn
date Sun, 11 Dec 2016 19:07:04 -0800
parents fec48bf5a827
children
line wrap: on
line diff
--- a/hotspot/src/cpu/x86/vm/icBuffer_x86.cpp	Sun Dec 11 12:05:57 2016 -0800
+++ b/hotspot/src/cpu/x86/vm/icBuffer_x86.cpp	Sun Dec 11 19:07:04 2016 -0800
@@ -33,12 +33,18 @@
 #include "oops/oop.inline.hpp"
 
 int InlineCacheBuffer::ic_stub_code_size() {
-  return NativeMovConstReg::instruction_size +
-         NativeJump::instruction_size +
-         1;
-  // so that code_end can be set in CodeBuffer
-  // 64bit 16 = 5 + 10 bytes + 1 byte
-  // 32bit 11 = 10 bytes + 1 byte
+  // Worst case, if destination is not a near call:
+  // lea rax, lit1
+  // lea scratch, lit2
+  // jmp scratch
+
+  // Best case
+  // lea rax, lit1
+  // jmp lit2
+
+  int best = NativeMovConstReg::instruction_size + NativeJump::instruction_size;
+  int worst = 2 * NativeMovConstReg::instruction_size + 3;
+  return MAX2(best, worst);
 }
 
 
@@ -59,8 +65,16 @@
 
 address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) {
   NativeMovConstReg* move = nativeMovConstReg_at(code_begin);   // creation also verifies the object
-  NativeJump*        jump = nativeJump_at(move->next_instruction_address());
-  return jump->jump_destination();
+  address jmp = move->next_instruction_address();
+  NativeInstruction* ni = nativeInstruction_at(jmp);
+  if (ni->is_jump()) {
+    NativeJump*        jump = nativeJump_at(jmp);
+    return jump->jump_destination();
+  } else {
+    assert(ni->is_far_jump(), "unexpected instruction");
+    NativeFarJump*     jump = nativeFarJump_at(jmp);
+    return jump->jump_destination();
+  }
 }
 
 
@@ -68,7 +82,14 @@
   // creation also verifies the object
   NativeMovConstReg* move = nativeMovConstReg_at(code_begin);
   // Verifies the jump
-  NativeJump*        jump = nativeJump_at(move->next_instruction_address());
+  address jmp = move->next_instruction_address();
+  NativeInstruction* ni = nativeInstruction_at(jmp);
+  if (ni->is_jump()) {
+    NativeJump*        jump = nativeJump_at(jmp);
+  } else {
+    assert(ni->is_far_jump(), "unexpected instruction");
+    NativeFarJump*     jump = nativeFarJump_at(jmp);
+  }
   void* o = (void*)move->data();
   return o;
 }