src/share/vm/code/relocInfo.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/code

src/share/vm/code/relocInfo.cpp

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "code/compiledIC.hpp"
  28 #include "code/nmethod.hpp"
  29 #include "code/relocInfo.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "runtime/stubCodeGenerator.hpp"
  32 #include "utilities/copy.hpp"

  33 
  34 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  35 
  36 const RelocationHolder RelocationHolder::none; // its type is relocInfo::none
  37 
  38 
  39 // Implementation of relocInfo
  40 
  41 #ifdef ASSERT
  42 relocInfo::relocInfo(relocType t, int off, int f) {
  43   assert(t != data_prefix_tag, "cannot build a prefix this way");
  44   assert((t & type_mask) == t, "wrong type");
  45   assert((f & format_mask) == f, "wrong format");
  46   assert(off >= 0 && off < offset_limit(), "offset out off bounds");
  47   assert((off & (offset_unit-1)) == 0, "misaligned offset");
  48   (*this) = relocInfo(t, RAW_BITS, off, f);
  49 }
  50 #endif
  51 
  52 void relocInfo::initialize(CodeSection* dest, Relocation* reloc) {


 407   }
 408   return (*this);
 409 }
 410 
 411 
 412 void Relocation::guarantee_size() {
 413   guarantee(false, "Make _relocbuf bigger!");
 414 }
 415 
 416     // some relocations can compute their own values
 417 address Relocation::value() {
 418   ShouldNotReachHere();
 419   return NULL;
 420 }
 421 
 422 
 423 void Relocation::set_value(address x) {
 424   ShouldNotReachHere();
 425 }
 426 
























 427 
 428 RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) {
 429   if (rtype == relocInfo::none)  return RelocationHolder::none;
 430   relocInfo ri = relocInfo(rtype, 0);
 431   RelocIterator itr;
 432   itr.set_current(ri);
 433   itr.reloc();
 434   return itr._rh;
 435 }
 436 
 437 int32_t Relocation::runtime_address_to_index(address runtime_address) {
 438   assert(!is_reloc_index((intptr_t)runtime_address), "must not look like an index");
 439 
 440   if (runtime_address == NULL)  return 0;
 441 
 442   StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address);
 443   if (p != NULL && p->begin() == runtime_address) {
 444     assert(is_reloc_index(p->index()), "there must not be too many stubs");
 445     return (int32_t)p->index();
 446   } else {


 563 }
 564 
 565 
 566 void virtual_call_Relocation::unpack_data() {
 567   jint x0 = unpack_1_int();
 568   address point = addr();
 569   _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point);
 570 }
 571 
 572 
 573 void static_stub_Relocation::pack_data_to(CodeSection* dest) {
 574   short* p = (short*) dest->locs_end();
 575   CodeSection* insts = dest->outer()->insts();
 576   normalize_address(_static_call, insts);
 577   p = pack_1_int_to(p, scaled_offset(_static_call, insts->start()));
 578   dest->set_locs_end((relocInfo*) p);
 579 }
 580 
 581 void static_stub_Relocation::unpack_data() {
 582   address base = binding()->section_start(CodeBuffer::SECT_INSTS);
 583   _static_call = address_from_scaled_offset(unpack_1_int(), base);

 584 }
 585 
 586 void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) {
 587   short* p = (short*) dest->locs_end();
 588   CodeSection* insts = dest->outer()->insts();
 589   normalize_address(_owner, insts);
 590   p = pack_1_int_to(p, scaled_offset(_owner, insts->start()));
 591   dest->set_locs_end((relocInfo*) p);
 592 }
 593 
 594 void trampoline_stub_Relocation::unpack_data() {
 595   address base = binding()->section_start(CodeBuffer::SECT_INSTS);
 596   _owner = address_from_scaled_offset(unpack_1_int(), base);
 597 }
 598 
 599 void external_word_Relocation::pack_data_to(CodeSection* dest) {
 600   short* p = (short*) dest->locs_end();
 601   int32_t index = runtime_address_to_index(_target);
 602 #ifndef _LP64
 603   p = pack_1_int_to(p, index);


 777   CompiledIC* icache = CompiledIC_at(this);
 778   icache->set_to_clean();
 779 }
 780 
 781 
 782 void opt_virtual_call_Relocation::clear_inline_cache() {
 783   // No stubs for ICs
 784   // Clean IC
 785   ResourceMark rm;
 786   CompiledIC* icache = CompiledIC_at(this);
 787   icache->set_to_clean();
 788 }
 789 
 790 
 791 address opt_virtual_call_Relocation::static_stub() {
 792   // search for the static stub who points back to this static call
 793   address static_call_addr = addr();
 794   RelocIterator iter(code());
 795   while (iter.next()) {
 796     if (iter.type() == relocInfo::static_stub_type) {
 797       if (iter.static_stub_reloc()->static_call() == static_call_addr) {

 798         return iter.addr();
 799       }
 800     }
 801   }
 802   return NULL;
 803 }
 804 
 805 
 806 void static_call_Relocation::clear_inline_cache() {
 807   // Safe call site info
 808   CompiledStaticCall* handler = compiledStaticCall_at(this);
 809   handler->set_to_clean();
 810 }
 811 
 812 
 813 address static_call_Relocation::static_stub() {
 814   // search for the static stub who points back to this static call
 815   address static_call_addr = addr();
 816   RelocIterator iter(code());
 817   while (iter.next()) {
 818     if (iter.type() == relocInfo::static_stub_type) {
 819       if (iter.static_stub_reloc()->static_call() == static_call_addr) {

 820         return iter.addr();
 821       }
 822     }
 823   }
 824   return NULL;
 825 }
 826 
 827 // Finds the trampoline address for a call. If no trampoline stub is
 828 // found NULL is returned which can be handled by the caller.
 829 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) {
 830   // There are no relocations available when the code gets relocated
 831   // because of CodeBuffer expansion.
 832   if (code->relocation_size() == 0)
 833     return NULL;
 834 
 835   RelocIterator iter(code, call);
 836   while (iter.next()) {
 837     if (iter.type() == relocInfo::trampoline_stub_type) {
 838       if (iter.trampoline_stub_reloc()->owner() == call) {
 839         return iter.addr();




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "code/compiledIC.hpp"
  28 #include "code/nmethod.hpp"
  29 #include "code/relocInfo.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "runtime/stubCodeGenerator.hpp"
  32 #include "utilities/copy.hpp"
  33 #include "oops/oop.inline.hpp"
  34 
  35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  36 
  37 const RelocationHolder RelocationHolder::none; // its type is relocInfo::none
  38 
  39 
  40 // Implementation of relocInfo
  41 
  42 #ifdef ASSERT
  43 relocInfo::relocInfo(relocType t, int off, int f) {
  44   assert(t != data_prefix_tag, "cannot build a prefix this way");
  45   assert((t & type_mask) == t, "wrong type");
  46   assert((f & format_mask) == f, "wrong format");
  47   assert(off >= 0 && off < offset_limit(), "offset out off bounds");
  48   assert((off & (offset_unit-1)) == 0, "misaligned offset");
  49   (*this) = relocInfo(t, RAW_BITS, off, f);
  50 }
  51 #endif
  52 
  53 void relocInfo::initialize(CodeSection* dest, Relocation* reloc) {


 408   }
 409   return (*this);
 410 }
 411 
 412 
 413 void Relocation::guarantee_size() {
 414   guarantee(false, "Make _relocbuf bigger!");
 415 }
 416 
 417     // some relocations can compute their own values
 418 address Relocation::value() {
 419   ShouldNotReachHere();
 420   return NULL;
 421 }
 422 
 423 
 424 void Relocation::set_value(address x) {
 425   ShouldNotReachHere();
 426 }
 427 
 428 void Relocation::const_set_data_value(address x) {
 429 #ifdef _LP64
 430   if (format() == relocInfo::narrow_oop_in_const) {
 431     *(narrowOop*)addr() = oopDesc::encode_heap_oop((oop) x);
 432   } else {
 433 #endif
 434     *(address*)addr() = x;
 435 #ifdef _LP64
 436   }
 437 #endif
 438 }
 439 
 440 void Relocation::const_verify_data_value(address x) {
 441 #ifdef _LP64
 442   if (format() == relocInfo::narrow_oop_in_const) {
 443     assert(*(narrowOop*)addr() == oopDesc::encode_heap_oop((oop) x), "must agree");
 444   } else {
 445 #endif
 446     assert(*(address*)addr() == x, "must agree");
 447 #ifdef _LP64
 448   }
 449 #endif
 450 }
 451 
 452 
 453 RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) {
 454   if (rtype == relocInfo::none)  return RelocationHolder::none;
 455   relocInfo ri = relocInfo(rtype, 0);
 456   RelocIterator itr;
 457   itr.set_current(ri);
 458   itr.reloc();
 459   return itr._rh;
 460 }
 461 
 462 int32_t Relocation::runtime_address_to_index(address runtime_address) {
 463   assert(!is_reloc_index((intptr_t)runtime_address), "must not look like an index");
 464 
 465   if (runtime_address == NULL)  return 0;
 466 
 467   StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address);
 468   if (p != NULL && p->begin() == runtime_address) {
 469     assert(is_reloc_index(p->index()), "there must not be too many stubs");
 470     return (int32_t)p->index();
 471   } else {


 588 }
 589 
 590 
 591 void virtual_call_Relocation::unpack_data() {
 592   jint x0 = unpack_1_int();
 593   address point = addr();
 594   _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point);
 595 }
 596 
 597 
 598 void static_stub_Relocation::pack_data_to(CodeSection* dest) {
 599   short* p = (short*) dest->locs_end();
 600   CodeSection* insts = dest->outer()->insts();
 601   normalize_address(_static_call, insts);
 602   p = pack_1_int_to(p, scaled_offset(_static_call, insts->start()));
 603   dest->set_locs_end((relocInfo*) p);
 604 }
 605 
 606 void static_stub_Relocation::unpack_data() {
 607   address base = binding()->section_start(CodeBuffer::SECT_INSTS);
 608   jint offset = unpack_1_int();
 609   _static_call = address_from_scaled_offset(offset, base);
 610 }
 611 
 612 void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) {
 613   short* p = (short*) dest->locs_end();
 614   CodeSection* insts = dest->outer()->insts();
 615   normalize_address(_owner, insts);
 616   p = pack_1_int_to(p, scaled_offset(_owner, insts->start()));
 617   dest->set_locs_end((relocInfo*) p);
 618 }
 619 
 620 void trampoline_stub_Relocation::unpack_data() {
 621   address base = binding()->section_start(CodeBuffer::SECT_INSTS);
 622   _owner = address_from_scaled_offset(unpack_1_int(), base);
 623 }
 624 
 625 void external_word_Relocation::pack_data_to(CodeSection* dest) {
 626   short* p = (short*) dest->locs_end();
 627   int32_t index = runtime_address_to_index(_target);
 628 #ifndef _LP64
 629   p = pack_1_int_to(p, index);


 803   CompiledIC* icache = CompiledIC_at(this);
 804   icache->set_to_clean();
 805 }
 806 
 807 
 808 void opt_virtual_call_Relocation::clear_inline_cache() {
 809   // No stubs for ICs
 810   // Clean IC
 811   ResourceMark rm;
 812   CompiledIC* icache = CompiledIC_at(this);
 813   icache->set_to_clean();
 814 }
 815 
 816 
 817 address opt_virtual_call_Relocation::static_stub() {
 818   // search for the static stub who points back to this static call
 819   address static_call_addr = addr();
 820   RelocIterator iter(code());
 821   while (iter.next()) {
 822     if (iter.type() == relocInfo::static_stub_type) {
 823       static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
 824       if (stub_reloc->static_call() == static_call_addr) {
 825         return iter.addr();
 826       }
 827     }
 828   }
 829   return NULL;
 830 }
 831 
 832 
 833 void static_call_Relocation::clear_inline_cache() {
 834   // Safe call site info
 835   CompiledStaticCall* handler = compiledStaticCall_at(this);
 836   handler->set_to_clean();
 837 }
 838 
 839 
 840 address static_call_Relocation::static_stub() {
 841   // search for the static stub who points back to this static call
 842   address static_call_addr = addr();
 843   RelocIterator iter(code());
 844   while (iter.next()) {
 845     if (iter.type() == relocInfo::static_stub_type) {
 846       static_stub_Relocation* stub_reloc = iter.static_stub_reloc();
 847       if (stub_reloc->static_call() == static_call_addr) {
 848         return iter.addr();
 849       }
 850     }
 851   }
 852   return NULL;
 853 }
 854 
 855 // Finds the trampoline address for a call. If no trampoline stub is
 856 // found NULL is returned which can be handled by the caller.
 857 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) {
 858   // There are no relocations available when the code gets relocated
 859   // because of CodeBuffer expansion.
 860   if (code->relocation_size() == 0)
 861     return NULL;
 862 
 863   RelocIterator iter(code, call);
 864   while (iter.next()) {
 865     if (iter.type() == relocInfo::trampoline_stub_type) {
 866       if (iter.trampoline_stub_reloc()->owner() == call) {
 867         return iter.addr();


src/share/vm/code/relocInfo.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File