Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/relocInfo_x86.cpp @ 304:dc7f315e41f7
5108146: Merge i486 and amd64 cpu directories
6459804: Want client (c1) compiler for x86_64 (amd64) for faster start-up
Reviewed-by: kvn
author | never |
---|---|
date | Wed, 27 Aug 2008 00:21:55 -0700 |
parents | d1605aabd0a1 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
303:fa4d1d240383 | 304:dc7f315e41f7 |
---|---|
28 | 28 |
29 void Relocation::pd_set_data_value(address x, intptr_t o) { | 29 void Relocation::pd_set_data_value(address x, intptr_t o) { |
30 #ifdef AMD64 | 30 #ifdef AMD64 |
31 x += o; | 31 x += o; |
32 typedef Assembler::WhichOperand WhichOperand; | 32 typedef Assembler::WhichOperand WhichOperand; |
33 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64, call32, narrow oop | 33 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm, call32, narrow oop |
34 assert(which == Assembler::disp32_operand || | 34 assert(which == Assembler::disp32_operand || |
35 which == Assembler::narrow_oop_operand || | 35 which == Assembler::narrow_oop_operand || |
36 which == Assembler::imm64_operand, "format unpacks ok"); | 36 which == Assembler::imm_operand, "format unpacks ok"); |
37 if (which == Assembler::imm64_operand) { | 37 if (which == Assembler::imm_operand) { |
38 *pd_address_in_code() = x; | 38 *pd_address_in_code() = x; |
39 } else if (which == Assembler::narrow_oop_operand) { | 39 } else if (which == Assembler::narrow_oop_operand) { |
40 address disp = Assembler::locate_operand(addr(), which); | 40 address disp = Assembler::locate_operand(addr(), which); |
41 *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x); | 41 *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x); |
42 } else { | 42 } else { |
79 NativeInstruction* ni = nativeInstruction_at(addr()); | 79 NativeInstruction* ni = nativeInstruction_at(addr()); |
80 if (ni->is_call()) { | 80 if (ni->is_call()) { |
81 nativeCall_at(addr())->set_destination(x); | 81 nativeCall_at(addr())->set_destination(x); |
82 } else if (ni->is_jump()) { | 82 } else if (ni->is_jump()) { |
83 NativeJump* nj = nativeJump_at(addr()); | 83 NativeJump* nj = nativeJump_at(addr()); |
84 #ifdef AMD64 | 84 |
85 // Unresolved jumps are recognized by a destination of -1 | |
86 // However 64bit can't actually produce such an address | |
87 // and encodes a jump to self but jump_destination will | |
88 // return a -1 as the signal. We must not relocate this | |
89 // jmp or the ic code will not see it as unresolved. | |
90 | |
85 if (nj->jump_destination() == (address) -1) { | 91 if (nj->jump_destination() == (address) -1) { |
86 x = (address) -1; // retain jump to self | 92 x = addr(); // jump to self |
87 } | 93 } |
88 #endif // AMD64 | |
89 nj->set_jump_destination(x); | 94 nj->set_jump_destination(x); |
90 } else if (ni->is_cond_jump()) { | 95 } else if (ni->is_cond_jump()) { |
91 // %%%% kludge this, for now, until we get a jump_destination method | 96 // %%%% kludge this, for now, until we get a jump_destination method |
92 address old_dest = nativeGeneralJump_at(addr())->jump_destination(); | 97 address old_dest = nativeGeneralJump_at(addr())->jump_destination(); |
93 address disp = Assembler::locate_operand(addr(), Assembler::call32_operand); | 98 address disp = Assembler::locate_operand(addr(), Assembler::call32_operand); |
104 // All embedded Intel addresses are stored in 32-bit words. | 109 // All embedded Intel addresses are stored in 32-bit words. |
105 // Since the addr points at the start of the instruction, | 110 // Since the addr points at the start of the instruction, |
106 // we must parse the instruction a bit to find the embedded word. | 111 // we must parse the instruction a bit to find the embedded word. |
107 assert(is_data(), "must be a DataRelocation"); | 112 assert(is_data(), "must be a DataRelocation"); |
108 typedef Assembler::WhichOperand WhichOperand; | 113 typedef Assembler::WhichOperand WhichOperand; |
109 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64/imm32 | 114 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32 |
110 #ifdef AMD64 | 115 #ifdef AMD64 |
111 assert(which == Assembler::disp32_operand || | 116 assert(which == Assembler::disp32_operand || |
112 which == Assembler::call32_operand || | 117 which == Assembler::call32_operand || |
113 which == Assembler::imm64_operand, "format unpacks ok"); | 118 which == Assembler::imm_operand, "format unpacks ok"); |
114 if (which != Assembler::imm64_operand) { | 119 if (which != Assembler::imm_operand) { |
115 // The "address" in the code is a displacement can't return it as | 120 // The "address" in the code is a displacement can't return it as |
116 // and address* since it is really a jint* | 121 // and address* since it is really a jint* |
117 ShouldNotReachHere(); | 122 ShouldNotReachHere(); |
118 return NULL; | 123 return NULL; |
119 } | 124 } |
120 #else | 125 #else |
121 assert(which == Assembler::disp32_operand || which == Assembler::imm32_operand, "format unpacks ok"); | 126 assert(which == Assembler::disp32_operand || which == Assembler::imm_operand, "format unpacks ok"); |
122 #endif // AMD64 | 127 #endif // AMD64 |
123 return (address*) Assembler::locate_operand(addr(), which); | 128 return (address*) Assembler::locate_operand(addr(), which); |
124 } | 129 } |
125 | 130 |
126 | 131 |
129 // All embedded Intel addresses are stored in 32-bit words. | 134 // All embedded Intel addresses are stored in 32-bit words. |
130 // Since the addr points at the start of the instruction, | 135 // Since the addr points at the start of the instruction, |
131 // we must parse the instruction a bit to find the embedded word. | 136 // we must parse the instruction a bit to find the embedded word. |
132 assert(is_data(), "must be a DataRelocation"); | 137 assert(is_data(), "must be a DataRelocation"); |
133 typedef Assembler::WhichOperand WhichOperand; | 138 typedef Assembler::WhichOperand WhichOperand; |
134 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm64/imm32 | 139 WhichOperand which = (WhichOperand) format(); // that is, disp32 or imm/imm32 |
135 assert(which == Assembler::disp32_operand || | 140 assert(which == Assembler::disp32_operand || |
136 which == Assembler::call32_operand || | 141 which == Assembler::call32_operand || |
137 which == Assembler::imm64_operand, "format unpacks ok"); | 142 which == Assembler::imm_operand, "format unpacks ok"); |
138 if (which != Assembler::imm64_operand) { | 143 if (which != Assembler::imm_operand) { |
139 address ip = addr(); | 144 address ip = addr(); |
140 address disp = Assembler::locate_operand(ip, which); | 145 address disp = Assembler::locate_operand(ip, which); |
141 address next_ip = Assembler::locate_next_instruction(ip); | 146 address next_ip = Assembler::locate_next_instruction(ip); |
142 address a = next_ip + *(int32_t*) disp; | 147 address a = next_ip + *(int32_t*) disp; |
143 return a; | 148 return a; |
167 Untested("pd_swap_out_breakpoint"); | 172 Untested("pd_swap_out_breakpoint"); |
168 assert(NativeIllegalInstruction::instruction_size == sizeof(short), "right address unit for update"); | 173 assert(NativeIllegalInstruction::instruction_size == sizeof(short), "right address unit for update"); |
169 NativeInstruction* ni = nativeInstruction_at(x); | 174 NativeInstruction* ni = nativeInstruction_at(x); |
170 *(short*)ni->addr_at(0) = instrs[0]; | 175 *(short*)ni->addr_at(0) = instrs[0]; |
171 } | 176 } |
177 | |
178 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { | |
179 #ifdef _LP64 | |
180 typedef Assembler::WhichOperand WhichOperand; | |
181 WhichOperand which = (WhichOperand) format(); | |
182 // This format is imm but it is really disp32 | |
183 which = Assembler::disp32_operand; | |
184 address orig_addr = old_addr_for(addr(), src, dest); | |
185 NativeInstruction* oni = nativeInstruction_at(orig_addr); | |
186 int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which); | |
187 // This poll_addr is incorrect by the size of the instruction it is irrelevant | |
188 intptr_t poll_addr = (intptr_t)oni + *orig_disp; | |
189 | |
190 NativeInstruction* ni = nativeInstruction_at(addr()); | |
191 intptr_t new_disp = poll_addr - (intptr_t) ni; | |
192 | |
193 int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which); | |
194 * disp = (int32_t)new_disp; | |
195 | |
196 #endif // _LP64 | |
197 } | |
198 | |
199 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { | |
200 #ifdef _LP64 | |
201 typedef Assembler::WhichOperand WhichOperand; | |
202 WhichOperand which = (WhichOperand) format(); | |
203 // This format is imm but it is really disp32 | |
204 which = Assembler::disp32_operand; | |
205 address orig_addr = old_addr_for(addr(), src, dest); | |
206 NativeInstruction* oni = nativeInstruction_at(orig_addr); | |
207 int32_t* orig_disp = (int32_t*) Assembler::locate_operand(orig_addr, which); | |
208 // This poll_addr is incorrect by the size of the instruction it is irrelevant | |
209 intptr_t poll_addr = (intptr_t)oni + *orig_disp; | |
210 | |
211 NativeInstruction* ni = nativeInstruction_at(addr()); | |
212 intptr_t new_disp = poll_addr - (intptr_t) ni; | |
213 | |
214 int32_t* disp = (int32_t*) Assembler::locate_operand(addr(), which); | |
215 * disp = (int32_t)new_disp; | |
216 #endif // _LP64 | |
217 } |