1.1 --- a/src/cpu/x86/vm/relocInfo_x86.cpp Tue Aug 26 15:49:40 2008 -0700 1.2 +++ b/src/cpu/x86/vm/relocInfo_x86.cpp Wed Aug 27 00:21:55 2008 -0700 1.3 @@ -30,11 +30,11 @@ 1.4 #ifdef AMD64 1.5 x += o; 1.6 typedef Assembler::WhichOperand WhichOperand; 1.7 - WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64, call32, narrow oop 1.8 + WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop 1.9 assert(which == Assembler::disp32_operand || 1.10 which == Assembler::narrow_oop_operand || 1.11 - which == Assembler::imm64_operand, "format unpacks ok"); 1.12 - if (which == Assembler::imm64_operand) { 1.13 + which == Assembler::imm_operand, "format unpacks ok"); 1.14 + if (which == Assembler::imm_operand) { 1.15 *pd_address_in_code() = x; 1.16 } else if (which == Assembler::narrow_oop_operand) { 1.17 address disp = Assembler::locate_operand(addr(), which); 1.18 @@ -81,11 +81,16 @@ 1.19 nativeCall_at(addr())->set_destination(x); 1.20 } else if (ni->is_jump()) { 1.21 NativeJump* nj = nativeJump_at(addr()); 1.22 -#ifdef AMD64 1.23 + 1.24 + // Unresolved jumps are recognized by a destination of -1 1.25 + // However 64bit can't actually produce such an address 1.26 + // and encodes a jump to self but jump_destination will 1.27 + // return a -1 as the signal. We must not relocate this 1.28 + // jmp or the ic code will not see it as unresolved. 1.29 + 1.30 if (nj->jump_destination() == (address) -1) { 1.31 - x = (address) -1; // retain jump to self 1.32 + x = addr(); // jump to self 1.33 } 1.34 -#endif // AMD64 1.35 nj->set_jump_destination(x); 1.36 } else if (ni->is_cond_jump()) { 1.37 // %%%% kludge this, for now, until we get a jump_destination method 1.38 @@ -106,19 +111,19 @@ 1.39 // we must parse the instruction a bit to find the embedded word. 1.40 assert(is_data(), "must be a DataRelocation"); 1.41 typedef Assembler::WhichOperand WhichOperand; 1.42 - WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64/imm32 1.43 + WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32 1.44 #ifdef AMD64 1.45 assert(which == Assembler::disp32_operand || 1.46 which == Assembler::call32_operand || 1.47 - which == Assembler::imm64_operand, "format unpacks ok"); 1.48 - if (which != Assembler::imm64_operand) { 1.49 + which == Assembler::imm_operand, "format unpacks ok"); 1.50 + if (which != Assembler::imm_operand) { 1.51 // The "address" in the code is a displacement can't return it as 1.52 // and address* since it is really a jint* 1.53 ShouldNotReachHere(); 1.54 return NULL; 1.55 } 1.56 #else 1.57 - assert(which == Assembler::disp32_operand || which == Assembler::imm32_operand, "format unpacks ok"); 1.58 + assert(which == Assembler::disp32_operand || which == Assembler::imm_operand, "format unpacks ok"); 1.59 #endif // AMD64 1.60 return (address*) Assembler::locate_operand(addr(), which); 1.61 } 1.62 @@ -131,11 +136,11 @@ 1.63 // we must parse the instruction a bit to find the embedded word. 1.64 assert(is_data(), "must be a DataRelocation"); 1.65 typedef Assembler::WhichOperand WhichOperand; 1.66 - WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64/imm32 1.67 + WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32 1.68 assert(which == Assembler::disp32_operand || 1.69 which == Assembler::call32_operand || 1.70 - which == Assembler::imm64_operand, "format unpacks ok"); 1.71 - if (which != Assembler::imm64_operand) { 1.72 + which == Assembler::imm_operand, "format unpacks ok"); 1.73 + if (which != Assembler::imm_operand) { 1.74 address ip = addr(); 1.75 address disp = Assembler::locate_operand(ip, which); 1.76 address next_ip = Assembler::locate_next_instruction(ip); 1.77 @@ -169,3 +174,44 @@ 1.78 NativeInstruction* ni = nativeInstruction_at(x); 1.79 *(short*)ni->addr_at(0) = instrs[0]; 1.80 } 1.81 + 1.82 +void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { 1.83 +#ifdef _LP64 1.84 + typedef Assembler::WhichOperand WhichOperand; 1.85 + WhichOperand which = (WhichOperand) format(); 1.86 + // This format is imm but it is really disp32 1.87 + which = Assembler::disp32_operand; 1.88 + address orig_addr = old_addr_for(addr(), src, dest); 1.89 + NativeInstruction* oni = nativeInstruction_at(orig_addr); 1.90 + int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which); 1.91 + // This poll_addr is incorrect by the size of the instruction it is irrelevant 1.92 + intptr_t poll_addr = (intptr_t)oni + *orig_disp; 1.93 + 1.94 + NativeInstruction* ni = nativeInstruction_at(addr()); 1.95 + intptr_t new_disp = poll_addr - (intptr_t) ni; 1.96 + 1.97 + int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which); 1.98 + * disp = (int32_t)new_disp; 1.99 + 1.100 +#endif // _LP64 1.101 +} 1.102 + 1.103 +void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { 1.104 +#ifdef _LP64 1.105 + typedef Assembler::WhichOperand WhichOperand; 1.106 + WhichOperand which = (WhichOperand) format(); 1.107 + // This format is imm but it is really disp32 1.108 + which = Assembler::disp32_operand; 1.109 + address orig_addr = old_addr_for(addr(), src, dest); 1.110 + NativeInstruction* oni = nativeInstruction_at(orig_addr); 1.111 + int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which); 1.112 + // This poll_addr is incorrect by the size of the instruction it is irrelevant 1.113 + intptr_t poll_addr = (intptr_t)oni + *orig_disp; 1.114 + 1.115 + NativeInstruction* ni = nativeInstruction_at(addr()); 1.116 + intptr_t new_disp = poll_addr - (intptr_t) ni; 1.117 + 1.118 + int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which); 1.119 + * disp = (int32_t)new_disp; 1.120 +#endif // _LP64 1.121 +}