--- old/src/cpu/x86/vm/icBuffer_x86.cpp 2016-11-03 14:16:03.000000000 -0700 +++ new/src/cpu/x86/vm/icBuffer_x86.cpp 2016-11-03 14:16:03.000000000 -0700 @@ -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; }