Mercurial > hg > graal-compiler
comparison src/cpu/ppc/vm/nativeInst_ppc.cpp @ 14445:67fa91961822
8029940: PPC64 (part 122): C2 compiler port
Reviewed-by: kvn
author | goetz |
---|---|
date | Wed, 11 Dec 2013 00:06:11 +0100 |
parents | 018b357638aa |
children | b858620b0081 |
comparison
equal
deleted
inserted
replaced
14444:492e67693373 | 14445:67fa91961822 |
---|---|
116 // Patch the constant in the call's trampoline stub. | 116 // Patch the constant in the call's trampoline stub. |
117 NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest); | 117 NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest); |
118 | 118 |
119 a->bl(trampoline_stub_addr); | 119 a->bl(trampoline_stub_addr); |
120 } | 120 } |
121 ICache::invalidate_range(addr_call, code_size); | 121 ICache::ppc64_flush_icache_bytes(addr_call, code_size); |
122 } | 122 } |
123 | 123 |
124 address NativeCall::get_trampoline() { | 124 address NativeCall::get_trampoline() { |
125 address call_addr = addr_at(0); | 125 address call_addr = addr_at(0); |
126 | 126 |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 intptr_t NativeMovConstReg::data() const { | 183 intptr_t NativeMovConstReg::data() const { |
184 address addr = addr_at(0); | 184 address addr = addr_at(0); |
185 CodeBlob* cb = CodeCache::find_blob_unsafe(addr); | |
186 | 185 |
187 if (MacroAssembler::is_load_const_at(addr)) { | 186 if (MacroAssembler::is_load_const_at(addr)) { |
188 return MacroAssembler::get_const(addr); | 187 return MacroAssembler::get_const(addr); |
189 } else if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) { | 188 } |
189 | |
190 CodeBlob* cb = CodeCache::find_blob_unsafe(addr); | |
191 if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) { | |
190 narrowOop no = (narrowOop)MacroAssembler::get_narrow_oop(addr, cb->content_begin()); | 192 narrowOop no = (narrowOop)MacroAssembler::get_narrow_oop(addr, cb->content_begin()); |
191 return cast_from_oop<intptr_t>(oopDesc::decode_heap_oop(no)); | 193 return cast_from_oop<intptr_t>(oopDesc::decode_heap_oop(no)); |
192 } else { | 194 } else { |
193 assert(MacroAssembler::is_load_const_from_method_toc_at(addr), "must be load_const_from_pool"); | 195 assert(MacroAssembler::is_load_const_from_method_toc_at(addr), "must be load_const_from_pool"); |
194 | 196 |
211 *(intptr_t *)(ctable + toc_offset) = data; | 213 *(intptr_t *)(ctable + toc_offset) = data; |
212 next_address = addr + BytesPerInstWord; | 214 next_address = addr + BytesPerInstWord; |
213 } else if (cb != NULL && | 215 } else if (cb != NULL && |
214 MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) { | 216 MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) { |
215 // A calculation relative to the global TOC. | 217 // A calculation relative to the global TOC. |
216 const int invalidated_range = | 218 if (MacroAssembler::get_address_of_calculate_address_from_global_toc_at(addr, cb->content_begin()) != |
217 MacroAssembler::patch_calculate_address_from_global_toc_at(addr, cb->content_begin(), | 219 (address)data) { |
218 (address)data); | 220 const int invalidated_range = |
219 const address start = invalidated_range < 0 ? addr + invalidated_range : addr; | 221 MacroAssembler::patch_calculate_address_from_global_toc_at(addr, cb->content_begin(), |
220 // FIXME: | 222 (address)data); |
221 const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; | 223 const address start = invalidated_range < 0 ? addr + invalidated_range : addr; |
222 ICache::invalidate_range(start, range); | 224 // FIXME: |
225 const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; | |
226 ICache::ppc64_flush_icache_bytes(start, range); | |
227 } | |
223 next_address = addr + 1 * BytesPerInstWord; | 228 next_address = addr + 1 * BytesPerInstWord; |
224 } else if (MacroAssembler::is_load_const_at(addr)) { | 229 } else if (MacroAssembler::is_load_const_at(addr)) { |
225 // A normal 5 instruction load_const code sequence. | 230 // A normal 5 instruction load_const code sequence. |
226 // This is not mt safe, ok in methods like CodeBuffer::copy_code(). | 231 if (MacroAssembler::get_const(addr) != (long)data) { |
227 MacroAssembler::patch_const(addr, (long)data); | 232 // This is not mt safe, ok in methods like CodeBuffer::copy_code(). |
228 ICache::invalidate_range(addr, load_const_instruction_size); | 233 MacroAssembler::patch_const(addr, (long)data); |
234 ICache::ppc64_flush_icache_bytes(addr, load_const_instruction_size); | |
235 } | |
229 next_address = addr + 5 * BytesPerInstWord; | 236 next_address = addr + 5 * BytesPerInstWord; |
230 } else if (MacroAssembler::is_bl(* (int*) addr)) { | 237 } else if (MacroAssembler::is_bl(* (int*) addr)) { |
231 // A single branch-and-link instruction. | 238 // A single branch-and-link instruction. |
232 ResourceMark rm; | 239 ResourceMark rm; |
233 const int code_size = 1 * BytesPerInstWord; | 240 const int code_size = 1 * BytesPerInstWord; |
234 CodeBuffer cb(addr, code_size + 1); | 241 CodeBuffer cb(addr, code_size + 1); |
235 MacroAssembler* a = new MacroAssembler(&cb); | 242 MacroAssembler* a = new MacroAssembler(&cb); |
236 a->bl((address) data); | 243 a->bl((address) data); |
237 ICache::invalidate_range(addr, code_size); | 244 ICache::ppc64_flush_icache_bytes(addr, code_size); |
238 next_address = addr + code_size; | 245 next_address = addr + code_size; |
239 } else { | 246 } else { |
240 ShouldNotReachHere(); | 247 ShouldNotReachHere(); |
241 } | 248 } |
242 | 249 |
277 } | 284 } |
278 | 285 |
279 void NativeMovConstReg::set_narrow_oop(narrowOop data, CodeBlob *code /* = NULL */) { | 286 void NativeMovConstReg::set_narrow_oop(narrowOop data, CodeBlob *code /* = NULL */) { |
280 address addr = addr_at(0); | 287 address addr = addr_at(0); |
281 CodeBlob* cb = (code) ? code : CodeCache::find_blob(instruction_address()); | 288 CodeBlob* cb = (code) ? code : CodeCache::find_blob(instruction_address()); |
289 if (MacroAssembler::get_narrow_oop(addr, cb->content_begin()) == (long)data) return; | |
282 const int invalidated_range = | 290 const int invalidated_range = |
283 MacroAssembler::patch_set_narrow_oop(addr, cb->content_begin(), (long)data); | 291 MacroAssembler::patch_set_narrow_oop(addr, cb->content_begin(), (long)data); |
284 const address start = invalidated_range < 0 ? addr + invalidated_range : addr; | 292 const address start = invalidated_range < 0 ? addr + invalidated_range : addr; |
285 // FIXME: | 293 // FIXME: |
286 const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; | 294 const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; |
287 ICache::invalidate_range(start, range); | 295 ICache::ppc64_flush_icache_bytes(start, range); |
288 } | 296 } |
289 | 297 |
290 // Do not use an assertion here. Let clients decide whether they only | 298 // Do not use an assertion here. Let clients decide whether they only |
291 // want this when assertions are enabled. | 299 // want this when assertions are enabled. |
292 #ifdef ASSERT | 300 #ifdef ASSERT |
293 void NativeMovConstReg::verify() { | 301 void NativeMovConstReg::verify() { |
294 address addr = addr_at(0); | 302 address addr = addr_at(0); |
295 CodeBlob* cb = CodeCache::find_blob_unsafe(addr); // find_nmethod() asserts if nmethod is zombie. | |
296 if (! MacroAssembler::is_load_const_at(addr) && | 303 if (! MacroAssembler::is_load_const_at(addr) && |
297 ! MacroAssembler::is_load_const_from_method_toc_at(addr) && | 304 ! MacroAssembler::is_load_const_from_method_toc_at(addr)) { |
298 ! (cb != NULL && MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) && | 305 CodeBlob* cb = CodeCache::find_blob_unsafe(addr); // find_nmethod() asserts if nmethod is zombie. |
299 ! (cb != NULL && MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) && | 306 if (! (cb != NULL && MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) && |
300 ! MacroAssembler::is_bl(*((int*) addr))) { | 307 ! (cb != NULL && MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) && |
301 tty->print_cr("not a NativeMovConstReg at " PTR_FORMAT, addr); | 308 ! MacroAssembler::is_bl(*((int*) addr))) { |
302 // TODO: PPC port Disassembler::decode(addr, 20, 20, tty); | 309 tty->print_cr("not a NativeMovConstReg at " PTR_FORMAT, addr); |
303 fatal(err_msg("not a NativeMovConstReg at " PTR_FORMAT, addr)); | 310 // TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); |
311 fatal(err_msg("not a NativeMovConstReg at " PTR_FORMAT, addr)); | |
312 } | |
304 } | 313 } |
305 } | 314 } |
306 #endif // ASSERT | 315 #endif // ASSERT |
307 | 316 |
308 void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { | 317 void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { |
324 } else { | 333 } else { |
325 // We use an illtrap for marking a method as not_entrant or zombie. | 334 // We use an illtrap for marking a method as not_entrant or zombie. |
326 a->illtrap(); | 335 a->illtrap(); |
327 } | 336 } |
328 } | 337 } |
329 ICache::invalidate_range(verified_entry, code_size); | 338 ICache::ppc64_flush_icache_bytes(verified_entry, code_size); |
330 } | 339 } |
331 | 340 |
332 #ifdef ASSERT | 341 #ifdef ASSERT |
333 void NativeJump::verify() { | 342 void NativeJump::verify() { |
334 address addr = addr_at(0); | 343 address addr = addr_at(0); |