< prev index next >

src/hotspot/cpu/s390/nativeInst_s390.cpp

Print this page




 458     // before. The value of the src argument is not related to the
 459     // branch target.
 460     next_address = next_instruction_address();
 461   }
 462 
 463   else {
 464     tty->print_cr("WARNING: detected an unrecognized code pattern at loc = %p -> 0x%8.8x %8.8x",
 465                   loc, *((unsigned int*)loc), *((unsigned int*)(loc+4)));
 466     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().
 467 #ifdef LUCY_DBG
 468     VM_Version::z_SIGSEGV();
 469 #endif
 470   }
 471 
 472   return next_address;
 473 }
 474 
 475 // Divided up in set_data_plain() which patches the instruction in the
 476 // code stream and set_data() which additionally patches the oop pool
 477 // if necessary.
 478 void NativeMovConstReg::set_data(intptr_t data, relocInfo::relocType expected_type) {
 479   // Also store the value into an oop_Relocation cell, if any.
 480   CodeBlob *cb = CodeCache::find_blob(instruction_address());
 481   address next_address = set_data_plain(data, cb);
 482 
 483   // 'RelocIterator' requires an nmethod
 484   nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL;
 485   if (nm != NULL) {
 486     RelocIterator iter(nm, instruction_address(), next_address);
 487     oop* oop_addr = NULL;
 488     Metadata** metadata_addr = NULL;
 489     while (iter.next()) {
 490       if (iter.type() == relocInfo::oop_type) {
 491         oop_Relocation *r = iter.oop_reloc();
 492         if (oop_addr == NULL) {
 493           oop_addr = r->oop_addr();
 494           *oop_addr = cast_to_oop(data);
 495         } else {
 496           assert(oop_addr == r->oop_addr(), "must be only one set-oop here");
 497         }
 498       }
 499       if (iter.type() == relocInfo::metadata_type) {
 500         metadata_Relocation *r = iter.metadata_reloc();
 501         if (metadata_addr == NULL) {
 502           metadata_addr = r->metadata_addr();
 503           *metadata_addr = (Metadata*)data;
 504         } else {
 505           assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here");
 506         }
 507       }
 508     }
 509     assert(expected_type == relocInfo::none ||
 510           (expected_type == relocInfo::metadata_type && metadata_addr != NULL) ||
 511           (expected_type == relocInfo::oop_type && oop_addr != NULL),
 512           "%s relocation not found", expected_type == relocInfo::oop_type ? "oop" : "metadata");
 513   }
 514 }
 515 
 516 void NativeMovConstReg::set_narrow_oop(intptr_t data) {
 517   const address start = addr_at(0);
 518   int           range = 0;
 519   if (MacroAssembler::is_load_narrow_oop(start)) {
 520     range = MacroAssembler::patch_load_narrow_oop(start, cast_to_oop <intptr_t> (data));
 521   } else if (MacroAssembler::is_compare_immediate_narrow_oop(start)) {
 522     range = MacroAssembler::patch_compare_immediate_narrow_oop(start, cast_to_oop <intptr_t>(data));
 523   } else {
 524     fatal("this is not a `NativeMovConstReg::narrow_oop' site");
 525   }
 526   ICache::invalidate_range(start, range);
 527 }
 528 
 529 // Compressed klass ptrs. patch narrow klass constant.
 530 void NativeMovConstReg::set_narrow_klass(intptr_t data) {
 531   const address start = addr_at(0);
 532   int           range = 0;
 533   if (MacroAssembler::is_load_narrow_klass(start)) {
 534     range = MacroAssembler::patch_load_narrow_klass(start, (Klass*)data);
 535   } else if (MacroAssembler::is_compare_immediate_narrow_klass(start)) {
 536     range = MacroAssembler::patch_compare_immediate_narrow_klass(start, (Klass*)data);
 537   } else {
 538     fatal("this is not a `NativeMovConstReg::narrow_klass' site");
 539   }
 540   ICache::invalidate_range(start, range);
 541 }
 542 
 543 void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */) {
 544   address next_address;
 545   address loc = addr_at(0);
 546 
 547   if (MacroAssembler::is_load_addr_pcrel(loc)) {
 548     address oldTarget = MacroAssembler::get_target_addr_pcrel(loc);
 549     MacroAssembler::patch_target_addr_pcrel(loc, (address)newTarget);
 550 
 551     ICache::invalidate_range(loc, MacroAssembler::load_addr_pcrel_size());
 552     next_address = loc + MacroAssembler::load_addr_pcrel_size();
 553   } else if (MacroAssembler::is_load_const_from_toc_pcrelative(loc) ) {  // Load constant from TOC.
 554     address oldTarget = MacroAssembler::get_target_addr_pcrel(loc);
 555     MacroAssembler::patch_target_addr_pcrel(loc, (address)newTarget);
 556 
 557     ICache::invalidate_range(loc, MacroAssembler::load_const_from_toc_size());
 558     next_address = loc + MacroAssembler::load_const_from_toc_size();
 559   } else if (MacroAssembler::is_call_far_patchable_pcrelative_at(loc)) {
 560     assert(ShortenBranches, "Wait a minute! A pc-relative call w/o ShortenBranches?");
 561     next_address = next_instruction_address();
 562   } else {
 563     assert(false, "Not a NativeMovConstReg site for set_pcrel_addr");
 564     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().
 565   }











 566 }
 567 
 568 void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */) {
 569   address  next_address;
 570   address  loc = addr_at(0);
 571 
 572   if (MacroAssembler::is_load_const_from_toc(loc) ) {  // Load constant from TOC.
 573     // Offset is +/- 2**32 -> use long.
 574     long     offset  = MacroAssembler::get_load_const_from_toc_offset(loc);
 575     address  target  = MacroAssembler::get_target_addr_pcrel(loc);
 576     intptr_t oldData = *(intptr_t*)target;
 577     if (oldData != newData) { // Update only if data changes. Prevents cache invalidation.
 578       *(intptr_t *)(target) = newData;
 579     }
 580 
 581     // ICache::invalidate_range(target, sizeof(unsigned long));  // No ICache invalidate for CP data.
 582     next_address = loc + MacroAssembler::load_const_from_toc_size();
 583   } else if (MacroAssembler::is_call_far_pcrelative(loc)) {
 584     ((NativeMovConstReg*)loc)->dump(64, "NativeMovConstReg::set_pcrel_data() has a problem: setting data for a pc-relative call?");
 585 #ifdef LUCY_DBG
 586     VM_Version::z_SIGSEGV();
 587 #else
 588     assert(false, "Ooooops: setting data for a pc-relative call");
 589 #endif
 590     next_address = next_instruction_address();
 591   } else {
 592     assert(false, "Not a NativeMovConstReg site for set_pcrel_data");
 593     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().











 594   }
 595 }
 596 
 597 #ifdef COMPILER1
 598 //--------------------------------
 599 //  N a t i v e M o v R e g M e m
 600 //--------------------------------
 601 
 602 void NativeMovRegMem::verify() {
 603   address l1 = addr_at(0);
 604   address l2 = addr_at(MacroAssembler::load_const_size());
 605 
 606   if (!MacroAssembler::is_load_const(l1)) {
 607     tty->cr();
 608     tty->print_cr("NativeMovRegMem::verify(): verifying addr " PTR_FORMAT, p2i(l1));
 609     tty->cr();
 610     ((NativeMovRegMem*)l1)->dump(64, "NativeMovConstReg::verify()");
 611     fatal("this is not a `NativeMovRegMem' site");
 612   }
 613 




 458     // before. The value of the src argument is not related to the
 459     // branch target.
 460     next_address = next_instruction_address();
 461   }
 462 
 463   else {
 464     tty->print_cr("WARNING: detected an unrecognized code pattern at loc = %p -> 0x%8.8x %8.8x",
 465                   loc, *((unsigned int*)loc), *((unsigned int*)(loc+4)));
 466     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().
 467 #ifdef LUCY_DBG
 468     VM_Version::z_SIGSEGV();
 469 #endif
 470   }
 471 
 472   return next_address;
 473 }
 474 
 475 // Divided up in set_data_plain() which patches the instruction in the
 476 // code stream and set_data() which additionally patches the oop pool
 477 // if necessary.
 478 void NativeMovConstReg::set_data(intptr_t src) {
 479   // Also store the value into an oop_Relocation cell, if any.
 480   CodeBlob *cb = CodeCache::find_blob(instruction_address());
 481   address next_address = set_data_plain(src, cb);
 482 
 483   relocInfo::update_oop_pool(instruction_address(), next_address, (address)src, cb);






























 484 }
 485 
 486 void NativeMovConstReg::set_narrow_oop(intptr_t data) {
 487   const address start = addr_at(0);
 488   int           range = 0;
 489   if (MacroAssembler::is_load_narrow_oop(start)) {
 490     range = MacroAssembler::patch_load_narrow_oop(start, cast_to_oop <intptr_t> (data));
 491   } else if (MacroAssembler::is_compare_immediate_narrow_oop(start)) {
 492     range = MacroAssembler::patch_compare_immediate_narrow_oop(start, cast_to_oop <intptr_t>(data));
 493   } else {
 494     fatal("this is not a `NativeMovConstReg::narrow_oop' site");
 495   }
 496   ICache::invalidate_range(start, range);
 497 }
 498 
 499 // Compressed klass ptrs. patch narrow klass constant.
 500 void NativeMovConstReg::set_narrow_klass(intptr_t data) {
 501   const address start = addr_at(0);
 502   int           range = 0;
 503   if (MacroAssembler::is_load_narrow_klass(start)) {
 504     range = MacroAssembler::patch_load_narrow_klass(start, (Klass*)data);
 505   } else if (MacroAssembler::is_compare_immediate_narrow_klass(start)) {
 506     range = MacroAssembler::patch_compare_immediate_narrow_klass(start, (Klass*)data);
 507   } else {
 508     fatal("this is not a `NativeMovConstReg::narrow_klass' site");
 509   }
 510   ICache::invalidate_range(start, range);
 511 }
 512 
 513 void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) {
 514   address next_address;
 515   address loc = addr_at(0);
 516 
 517   if (MacroAssembler::is_load_addr_pcrel(loc)) {
 518     address oldTarget = MacroAssembler::get_target_addr_pcrel(loc);
 519     MacroAssembler::patch_target_addr_pcrel(loc, (address)newTarget);
 520 
 521     ICache::invalidate_range(loc, MacroAssembler::load_addr_pcrel_size());
 522     next_address = loc + MacroAssembler::load_addr_pcrel_size();
 523   } else if (MacroAssembler::is_load_const_from_toc_pcrelative(loc) ) {  // Load constant from TOC.
 524     address oldTarget = MacroAssembler::get_target_addr_pcrel(loc);
 525     MacroAssembler::patch_target_addr_pcrel(loc, (address)newTarget);
 526 
 527     ICache::invalidate_range(loc, MacroAssembler::load_const_from_toc_size());
 528     next_address = loc + MacroAssembler::load_const_from_toc_size();
 529   } else if (MacroAssembler::is_call_far_patchable_pcrelative_at(loc)) {
 530     assert(ShortenBranches, "Wait a minute! A pc-relative call w/o ShortenBranches?");
 531     next_address = next_instruction_address();
 532   } else {
 533     assert(false, "Not a NativeMovConstReg site for set_pcrel_addr");
 534     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().
 535   }
 536 
 537   if (copy_back_to_oop_pool) {
 538     if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newTarget, NULL)) {
 539       ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_addr(): found oop reloc for pcrel_addr");
 540 #ifdef LUCY_DBG
 541       VM_Version::z_SIGSEGV();
 542 #else
 543       assert(false, "Ooooops: found oop reloc for pcrel_addr");
 544 #endif
 545     }
 546   }
 547 }
 548 
 549 void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) {
 550   address  next_address;
 551   address  loc = addr_at(0);
 552 
 553   if (MacroAssembler::is_load_const_from_toc(loc) ) {  // Load constant from TOC.
 554     // Offset is +/- 2**32 -> use long.
 555     long     offset  = MacroAssembler::get_load_const_from_toc_offset(loc);
 556     address  target  = MacroAssembler::get_target_addr_pcrel(loc);
 557     intptr_t oldData = *(intptr_t*)target;
 558     if (oldData != newData) { // Update only if data changes. Prevents cache invalidation.
 559       *(intptr_t *)(target) = newData;
 560     }
 561 
 562     // ICache::invalidate_range(target, sizeof(unsigned long));  // No ICache invalidate for CP data.
 563     next_address = loc + MacroAssembler::load_const_from_toc_size();
 564   } else if (MacroAssembler::is_call_far_pcrelative(loc)) {
 565     ((NativeMovConstReg*)loc)->dump(64, "NativeMovConstReg::set_pcrel_data() has a problem: setting data for a pc-relative call?");
 566 #ifdef LUCY_DBG
 567     VM_Version::z_SIGSEGV();
 568 #else
 569     assert(false, "Ooooops: setting data for a pc-relative call");
 570 #endif
 571     next_address = next_instruction_address();
 572   } else {
 573     assert(false, "Not a NativeMovConstReg site for set_pcrel_data");
 574     next_address = next_instruction_address(); // Failure should be handled in next_instruction_address().
 575   }
 576 
 577   if (copy_back_to_oop_pool) {
 578     if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newData, NULL)) {
 579       ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_data(): found oop reloc for pcrel_data");
 580 #ifdef LUCY_DBG
 581       VM_Version::z_SIGSEGV();
 582 #else
 583       assert(false, "Ooooops: found oop reloc for pcrel_data");
 584 #endif
 585     }
 586   }
 587 }
 588 
 589 #ifdef COMPILER1
 590 //--------------------------------
 591 //  N a t i v e M o v R e g M e m
 592 //--------------------------------
 593 
 594 void NativeMovRegMem::verify() {
 595   address l1 = addr_at(0);
 596   address l2 = addr_at(MacroAssembler::load_const_size());
 597 
 598   if (!MacroAssembler::is_load_const(l1)) {
 599     tty->cr();
 600     tty->print_cr("NativeMovRegMem::verify(): verifying addr " PTR_FORMAT, p2i(l1));
 601     tty->cr();
 602     ((NativeMovRegMem*)l1)->dump(64, "NativeMovConstReg::verify()");
 603     fatal("this is not a `NativeMovRegMem' site");
 604   }
 605 


< prev index next >