415 } |
415 } |
416 // End code for unit testing implementation of NativeMovConstReg class |
416 // End code for unit testing implementation of NativeMovConstReg class |
417 |
417 |
418 //------------------------------------------------------------------- |
418 //------------------------------------------------------------------- |
419 |
419 |
|
420 void NativeMovConstReg32::verify() { |
|
421 NativeInstruction::verify(); |
|
422 // make sure code pattern is actually a "set_metadata" synthetic instruction |
|
423 // see MacroAssembler::set_oop() |
|
424 int i0 = long_at(sethi_offset); |
|
425 int i1 = long_at(add_offset); |
|
426 |
|
427 // verify the pattern "sethi %hi22(imm), reg ; add reg, %lo10(imm), reg" |
|
428 Register rd = inv_rd(i0); |
|
429 if (!is_op2(i0, Assembler::sethi_op2) && rd != G0 ) { |
|
430 fatal("not a set_metadata"); |
|
431 } |
|
432 } |
|
433 |
|
434 |
|
435 void NativeMovConstReg32::print() { |
|
436 tty->print_cr(INTPTR_FORMAT ": mov reg, " INTPTR_FORMAT, instruction_address(), data()); |
|
437 } |
|
438 |
|
439 |
|
440 intptr_t NativeMovConstReg32::data() const { |
|
441 return data32(long_at(sethi_offset), long_at(add_offset)); |
|
442 } |
|
443 |
|
444 |
|
445 void NativeMovConstReg32::set_data(intptr_t x) { |
|
446 set_long_at(sethi_offset, set_data32_sethi( long_at(sethi_offset), x)); |
|
447 set_long_at(add_offset, set_data32_simm13( long_at(add_offset), x)); |
|
448 |
|
449 // also store the value into an oop_Relocation cell, if any |
|
450 CodeBlob* cb = CodeCache::find_blob(instruction_address()); |
|
451 nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; |
|
452 if (nm != NULL) { |
|
453 RelocIterator iter(nm, instruction_address(), next_instruction_address()); |
|
454 oop* oop_addr = NULL; |
|
455 Metadata** metadata_addr = NULL; |
|
456 while (iter.next()) { |
|
457 if (iter.type() == relocInfo::oop_type) { |
|
458 oop_Relocation *r = iter.oop_reloc(); |
|
459 if (oop_addr == NULL) { |
|
460 oop_addr = r->oop_addr(); |
|
461 *oop_addr = cast_to_oop(x); |
|
462 } else { |
|
463 assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
|
464 } |
|
465 } |
|
466 if (iter.type() == relocInfo::metadata_type) { |
|
467 metadata_Relocation *r = iter.metadata_reloc(); |
|
468 if (metadata_addr == NULL) { |
|
469 metadata_addr = r->metadata_addr(); |
|
470 *metadata_addr = (Metadata*)x; |
|
471 } else { |
|
472 assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); |
|
473 } |
|
474 } |
|
475 } |
|
476 } |
|
477 } |
|
478 |
|
479 //------------------------------------------------------------------- |
|
480 |
420 void NativeMovConstRegPatching::verify() { |
481 void NativeMovConstRegPatching::verify() { |
421 NativeInstruction::verify(); |
482 NativeInstruction::verify(); |
422 // Make sure code pattern is sethi/nop/add. |
483 // Make sure code pattern is sethi/nop/add. |
423 int i0 = long_at(sethi_offset); |
484 int i0 = long_at(sethi_offset); |
424 int i1 = long_at(nop_offset); |
485 int i1 = long_at(nop_offset); |