1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
298 //------------------------------------------------------------------- |
298 //------------------------------------------------------------------- |
299 |
299 |
300 |
300 |
301 void NativeMovConstReg::verify() { |
301 void NativeMovConstReg::verify() { |
302 NativeInstruction::verify(); |
302 NativeInstruction::verify(); |
303 // make sure code pattern is actually a "set_oop" synthetic instruction |
303 // make sure code pattern is actually a "set_metadata" synthetic instruction |
304 // see MacroAssembler::set_oop() |
304 // see MacroAssembler::set_oop() |
305 int i0 = long_at(sethi_offset); |
305 int i0 = long_at(sethi_offset); |
306 int i1 = long_at(add_offset); |
306 int i1 = long_at(add_offset); |
307 |
307 |
308 // verify the pattern "sethi %hi22(imm), reg ; add reg, %lo10(imm), reg" |
308 // verify the pattern "sethi %hi22(imm), reg ; add reg, %lo10(imm), reg" |
310 #ifndef _LP64 |
310 #ifndef _LP64 |
311 if (!(is_op2(i0, Assembler::sethi_op2) && rd != G0 && |
311 if (!(is_op2(i0, Assembler::sethi_op2) && rd != G0 && |
312 is_op3(i1, Assembler::add_op3, Assembler::arith_op) && |
312 is_op3(i1, Assembler::add_op3, Assembler::arith_op) && |
313 inv_immed(i1) && (unsigned)get_simm13(i1) < (1 << 10) && |
313 inv_immed(i1) && (unsigned)get_simm13(i1) < (1 << 10) && |
314 rd == inv_rs1(i1) && rd == inv_rd(i1))) { |
314 rd == inv_rs1(i1) && rd == inv_rd(i1))) { |
315 fatal("not a set_oop"); |
315 fatal("not a set_metadata"); |
316 } |
316 } |
317 #else |
317 #else |
318 if (!is_op2(i0, Assembler::sethi_op2) && rd != G0 ) { |
318 if (!is_op2(i0, Assembler::sethi_op2) && rd != G0 ) { |
319 fatal("not a set_oop"); |
319 fatal("not a set_metadata"); |
320 } |
320 } |
321 #endif |
321 #endif |
322 } |
322 } |
323 |
323 |
324 |
324 |
350 CodeBlob* cb = CodeCache::find_blob(instruction_address()); |
350 CodeBlob* cb = CodeCache::find_blob(instruction_address()); |
351 nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; |
351 nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; |
352 if (nm != NULL) { |
352 if (nm != NULL) { |
353 RelocIterator iter(nm, instruction_address(), next_instruction_address()); |
353 RelocIterator iter(nm, instruction_address(), next_instruction_address()); |
354 oop* oop_addr = NULL; |
354 oop* oop_addr = NULL; |
|
355 Metadata** metadata_addr = NULL; |
355 while (iter.next()) { |
356 while (iter.next()) { |
356 if (iter.type() == relocInfo::oop_type) { |
357 if (iter.type() == relocInfo::oop_type) { |
357 oop_Relocation *r = iter.oop_reloc(); |
358 oop_Relocation *r = iter.oop_reloc(); |
358 if (oop_addr == NULL) { |
359 if (oop_addr == NULL) { |
359 oop_addr = r->oop_addr(); |
360 oop_addr = r->oop_addr(); |
360 *oop_addr = (oop)x; |
361 *oop_addr = (oop)x; |
361 } else { |
362 } else { |
362 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
363 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
|
364 } |
|
365 } |
|
366 if (iter.type() == relocInfo::metadata_type) { |
|
367 metadata_Relocation *r = iter.metadata_reloc(); |
|
368 if (metadata_addr == NULL) { |
|
369 metadata_addr = r->metadata_addr(); |
|
370 *metadata_addr = (Metadata*)x; |
|
371 } else { |
|
372 assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); |
363 } |
373 } |
364 } |
374 } |
365 } |
375 } |
366 } |
376 } |
367 } |
377 } |
427 if (!(is_op2(i0, Assembler::sethi_op2) && rd0 != G0 && |
437 if (!(is_op2(i0, Assembler::sethi_op2) && rd0 != G0 && |
428 is_op2(i1, Assembler::sethi_op2) && rd1 == G0 && // nop is a special case of sethi |
438 is_op2(i1, Assembler::sethi_op2) && rd1 == G0 && // nop is a special case of sethi |
429 is_op3(i2, Assembler::add_op3, Assembler::arith_op) && |
439 is_op3(i2, Assembler::add_op3, Assembler::arith_op) && |
430 inv_immed(i2) && (unsigned)get_simm13(i2) < (1 << 10) && |
440 inv_immed(i2) && (unsigned)get_simm13(i2) < (1 << 10) && |
431 rd0 == inv_rs1(i2) && rd0 == inv_rd(i2))) { |
441 rd0 == inv_rs1(i2) && rd0 == inv_rd(i2))) { |
432 fatal("not a set_oop"); |
442 fatal("not a set_metadata"); |
433 } |
443 } |
434 } |
444 } |
435 |
445 |
436 |
446 |
437 void NativeMovConstRegPatching::print() { |
447 void NativeMovConstRegPatching::print() { |
460 CodeBlob* cb = CodeCache::find_blob(instruction_address()); |
470 CodeBlob* cb = CodeCache::find_blob(instruction_address()); |
461 nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; |
471 nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; |
462 if (nm != NULL) { |
472 if (nm != NULL) { |
463 RelocIterator iter(nm, instruction_address(), next_instruction_address()); |
473 RelocIterator iter(nm, instruction_address(), next_instruction_address()); |
464 oop* oop_addr = NULL; |
474 oop* oop_addr = NULL; |
|
475 Metadata** metadata_addr = NULL; |
465 while (iter.next()) { |
476 while (iter.next()) { |
466 if (iter.type() == relocInfo::oop_type) { |
477 if (iter.type() == relocInfo::oop_type) { |
467 oop_Relocation *r = iter.oop_reloc(); |
478 oop_Relocation *r = iter.oop_reloc(); |
468 if (oop_addr == NULL) { |
479 if (oop_addr == NULL) { |
469 oop_addr = r->oop_addr(); |
480 oop_addr = r->oop_addr(); |
470 *oop_addr = (oop)x; |
481 *oop_addr = (oop)x; |
471 } else { |
482 } else { |
472 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
483 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
|
484 } |
|
485 } |
|
486 if (iter.type() == relocInfo::metadata_type) { |
|
487 metadata_Relocation *r = iter.metadata_reloc(); |
|
488 if (metadata_addr == NULL) { |
|
489 metadata_addr = r->metadata_addr(); |
|
490 *metadata_addr = (Metadata*)x; |
|
491 } else { |
|
492 assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); |
473 } |
493 } |
474 } |
494 } |
475 } |
495 } |
476 } |
496 } |
477 } |
497 } |