< prev index next >

src/hotspot/share/code/relocInfo.cpp

Print this page

 162   _end     = cs->locs_end();
 163   _addr    = cs->start();
 164   _code    = nullptr; // Not cb->blob();
 165 
 166   CodeBuffer* cb = cs->outer();
 167   assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
 168   for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
 169     CodeSection* cs = cb->code_section(n);
 170     _section_start[n] = cs->start();
 171     _section_end  [n] = cs->end();
 172   }
 173 
 174   assert(!has_current(), "just checking");
 175 
 176   assert(begin == nullptr || begin >= cs->start(), "in bounds");
 177   assert(limit == nullptr || limit <= cs->end(),   "in bounds");
 178   set_limits(begin, limit);
 179 }
 180 
 181 RelocIterator::RelocIterator(CodeBlob* cb) {
 182   initialize_misc();
 183   if (cb->is_nmethod()) {
 184     _code = cb->as_nmethod();
 185   } else {
 186     _code = nullptr;
 187   }


 188   _current = cb->relocation_begin() - 1;
 189   _end     = cb->relocation_end();
 190   _addr    = cb->content_begin();
 191 
 192   _section_start[CodeBuffer::SECT_CONSTS] = cb->content_begin();
 193   _section_start[CodeBuffer::SECT_INSTS ] = cb->code_begin();
 194   _section_start[CodeBuffer::SECT_STUBS ] = cb->code_end();
 195 
 196   _section_end  [CodeBuffer::SECT_CONSTS] = cb->code_begin();
 197   _section_end  [CodeBuffer::SECT_INSTS ] = cb->code_end();
 198   _section_end  [CodeBuffer::SECT_STUBS ] = cb->code_end();
 199 
 200   assert(!has_current(), "just checking");
 201   set_limits(nullptr, nullptr);
 202 }
 203 
 204 bool RelocIterator::addr_in_const() const {
 205   const int n = CodeBuffer::SECT_CONSTS;
 206   if (_section_start[n] == nullptr) {
 207     return false;

 847   } else if (datalen() > 0) {
 848     st->print(" data={");
 849     for (int i = 0; i < datalen(); i++) {
 850       st->print("%04x", data()[i] & 0xFFFF);
 851     }
 852     st->print("}");
 853   }
 854   st->print("]");
 855   switch (type()) {
 856   case relocInfo::oop_type:
 857     {
 858       oop_Relocation* r = oop_reloc();
 859       oop* oop_addr  = nullptr;
 860       oop  raw_oop   = nullptr;
 861       oop  oop_value = nullptr;
 862       if (code() != nullptr || r->oop_is_immediate()) {
 863         oop_addr  = r->oop_addr();
 864         raw_oop   = *oop_addr;
 865         oop_value = r->oop_value();
 866       }
 867       st->print(" | [oop_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT "]",
 868                  p2i(oop_addr), p2i(raw_oop));
 869       // Do not print the oop by default--we want this routine to
 870       // work even during GC or other inconvenient times.
 871       if (WizardMode && oop_value != nullptr) {
 872         st->print("oop_value=" INTPTR_FORMAT ": ", p2i(oop_value));
 873         if (oopDesc::is_oop(oop_value)) {
 874           oop_value->print_value_on(st);
 875         }
 876       }
 877       break;
 878     }
 879   case relocInfo::metadata_type:
 880     {
 881       metadata_Relocation* r = metadata_reloc();
 882       Metadata** metadata_addr  = nullptr;
 883       Metadata*    raw_metadata   = nullptr;
 884       Metadata*    metadata_value = nullptr;
 885       if (code() != nullptr || r->metadata_is_immediate()) {
 886         metadata_addr  = r->metadata_addr();
 887         raw_metadata   = *metadata_addr;
 888         metadata_value = r->metadata_value();
 889       }
 890       st->print(" | [metadata_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT "]",
 891                  p2i(metadata_addr), p2i(raw_metadata));
 892       if (metadata_value != nullptr) {
 893         st->print("metadata_value=" INTPTR_FORMAT ": ", p2i(metadata_value));
 894         metadata_value->print_value_on(st);
 895       }
 896       break;
 897     }
 898   case relocInfo::external_word_type:
 899   case relocInfo::internal_word_type:
 900   case relocInfo::section_word_type:
 901     {
 902       DataRelocation* r = (DataRelocation*) reloc();
 903       st->print(" | [target=" INTPTR_FORMAT "]", p2i(r->value())); //value==target
 904       break;
 905     }
 906   case relocInfo::static_call_type:
 907     {
 908       static_call_Relocation* r = (static_call_Relocation*) reloc();
 909       st->print(" | [destination=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]",
 910                  p2i(r->destination()), p2i(r->method_value()));
 911       CodeBlob* cb = CodeCache::find_blob(r->destination());

 914       }
 915       break;
 916     }
 917   case relocInfo::runtime_call_type:
 918   case relocInfo::runtime_call_w_cp_type:
 919     {
 920       CallRelocation* r = (CallRelocation*) reloc();
 921       address dest = r->destination();
 922       st->print(" | [destination=" INTPTR_FORMAT "]", p2i(dest));
 923       if (StubRoutines::contains(dest)) {
 924         StubCodeDesc* desc = StubCodeDesc::desc_for(dest);
 925         if (desc == nullptr) {
 926           desc = StubCodeDesc::desc_for(dest + frame::pc_return_offset);
 927         }
 928         if (desc != nullptr) {
 929           st->print(" Stub::%s", desc->name());
 930         }
 931       } else {
 932         CodeBlob* cb = CodeCache::find_blob(dest);
 933         if (cb != nullptr) {
 934           st->print(" %s", cb->name());
 935         } else {
 936           ResourceMark rm;
 937           const int buflen = 1024;
 938           char* buf = NEW_RESOURCE_ARRAY(char, buflen);
 939           int offset;
 940           if (os::dll_address_to_function_name(dest, buf, buflen, &offset)) {
 941             st->print(" %s", buf);
 942             if (offset != 0) {
 943               st->print("+%d", offset);
 944             }
 945           }
 946         }
 947       }
 948       break;
 949     }
 950   case relocInfo::virtual_call_type:
 951     {
 952       virtual_call_Relocation* r = (virtual_call_Relocation*) reloc();
 953       st->print(" | [destination=" INTPTR_FORMAT " cached_value=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]",
 954                  p2i(r->destination()), p2i(r->cached_value()), p2i(r->method_value()));

 162   _end     = cs->locs_end();
 163   _addr    = cs->start();
 164   _code    = nullptr; // Not cb->blob();
 165 
 166   CodeBuffer* cb = cs->outer();
 167   assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
 168   for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
 169     CodeSection* cs = cb->code_section(n);
 170     _section_start[n] = cs->start();
 171     _section_end  [n] = cs->end();
 172   }
 173 
 174   assert(!has_current(), "just checking");
 175 
 176   assert(begin == nullptr || begin >= cs->start(), "in bounds");
 177   assert(limit == nullptr || limit <= cs->end(),   "in bounds");
 178   set_limits(begin, limit);
 179 }
 180 
 181 RelocIterator::RelocIterator(CodeBlob* cb) {

 182   if (cb->is_nmethod()) {
 183     initialize(cb->as_nmethod(), nullptr, nullptr);
 184     return;

 185   }
 186   initialize_misc();
 187   _code = nullptr;
 188   _current = cb->relocation_begin() - 1;
 189   _end     = cb->relocation_end();
 190   _addr    = cb->content_begin();
 191 
 192   _section_start[CodeBuffer::SECT_CONSTS] = cb->content_begin();
 193   _section_start[CodeBuffer::SECT_INSTS ] = cb->code_begin();
 194   _section_start[CodeBuffer::SECT_STUBS ] = cb->code_end();
 195 
 196   _section_end  [CodeBuffer::SECT_CONSTS] = cb->code_begin();
 197   _section_end  [CodeBuffer::SECT_INSTS ] = cb->code_end();
 198   _section_end  [CodeBuffer::SECT_STUBS ] = cb->code_end();
 199 
 200   assert(!has_current(), "just checking");
 201   set_limits(nullptr, nullptr);
 202 }
 203 
 204 bool RelocIterator::addr_in_const() const {
 205   const int n = CodeBuffer::SECT_CONSTS;
 206   if (_section_start[n] == nullptr) {
 207     return false;

 847   } else if (datalen() > 0) {
 848     st->print(" data={");
 849     for (int i = 0; i < datalen(); i++) {
 850       st->print("%04x", data()[i] & 0xFFFF);
 851     }
 852     st->print("}");
 853   }
 854   st->print("]");
 855   switch (type()) {
 856   case relocInfo::oop_type:
 857     {
 858       oop_Relocation* r = oop_reloc();
 859       oop* oop_addr  = nullptr;
 860       oop  raw_oop   = nullptr;
 861       oop  oop_value = nullptr;
 862       if (code() != nullptr || r->oop_is_immediate()) {
 863         oop_addr  = r->oop_addr();
 864         raw_oop   = *oop_addr;
 865         oop_value = r->oop_value();
 866       }
 867       st->print(" | [oop_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " index=%d]",
 868                  p2i(oop_addr), p2i(raw_oop), r->oop_index());
 869       // Do not print the oop by default--we want this routine to
 870       // work even during GC or other inconvenient times.
 871       if (WizardMode && oop_value != nullptr) {
 872         st->print("oop_value=" INTPTR_FORMAT ": ", p2i(oop_value));
 873         if (oopDesc::is_oop(oop_value)) {
 874           oop_value->print_value_on(st);
 875         }
 876       }
 877       break;
 878     }
 879   case relocInfo::metadata_type:
 880     {
 881       metadata_Relocation* r = metadata_reloc();
 882       Metadata** metadata_addr  = nullptr;
 883       Metadata*    raw_metadata   = nullptr;
 884       Metadata*    metadata_value = nullptr;
 885       if (code() != nullptr || r->metadata_is_immediate()) {
 886         metadata_addr  = r->metadata_addr();
 887         raw_metadata   = *metadata_addr;
 888         metadata_value = r->metadata_value();
 889       }
 890       st->print(" | [metadata_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " index=%d]",
 891                  p2i(metadata_addr), p2i(raw_metadata), r->metadata_index());
 892       if (metadata_value != nullptr) {
 893         st->print("metadata_value=" INTPTR_FORMAT ": ", p2i(metadata_value));
 894         metadata_value->print_value_on(st);
 895       }
 896       break;
 897     }
 898   case relocInfo::external_word_type:
 899   case relocInfo::internal_word_type:
 900   case relocInfo::section_word_type:
 901     {
 902       DataRelocation* r = (DataRelocation*) reloc();
 903       st->print(" | [target=" INTPTR_FORMAT "]", p2i(r->value())); //value==target
 904       break;
 905     }
 906   case relocInfo::static_call_type:
 907     {
 908       static_call_Relocation* r = (static_call_Relocation*) reloc();
 909       st->print(" | [destination=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]",
 910                  p2i(r->destination()), p2i(r->method_value()));
 911       CodeBlob* cb = CodeCache::find_blob(r->destination());

 914       }
 915       break;
 916     }
 917   case relocInfo::runtime_call_type:
 918   case relocInfo::runtime_call_w_cp_type:
 919     {
 920       CallRelocation* r = (CallRelocation*) reloc();
 921       address dest = r->destination();
 922       st->print(" | [destination=" INTPTR_FORMAT "]", p2i(dest));
 923       if (StubRoutines::contains(dest)) {
 924         StubCodeDesc* desc = StubCodeDesc::desc_for(dest);
 925         if (desc == nullptr) {
 926           desc = StubCodeDesc::desc_for(dest + frame::pc_return_offset);
 927         }
 928         if (desc != nullptr) {
 929           st->print(" Stub::%s", desc->name());
 930         }
 931       } else {
 932         CodeBlob* cb = CodeCache::find_blob(dest);
 933         if (cb != nullptr) {
 934           st->print(" Blob::%s", cb->name());
 935         } else {
 936           ResourceMark rm;
 937           const int buflen = 1024;
 938           char* buf = NEW_RESOURCE_ARRAY(char, buflen);
 939           int offset;
 940           if (os::dll_address_to_function_name(dest, buf, buflen, &offset)) {
 941             st->print(" %s", buf);
 942             if (offset != 0) {
 943               st->print("+%d", offset);
 944             }
 945           }
 946         }
 947       }
 948       break;
 949     }
 950   case relocInfo::virtual_call_type:
 951     {
 952       virtual_call_Relocation* r = (virtual_call_Relocation*) reloc();
 953       st->print(" | [destination=" INTPTR_FORMAT " cached_value=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]",
 954                  p2i(r->destination()), p2i(r->cached_value()), p2i(r->method_value()));
< prev index next >