hotspot/src/share/vm/code/nmethod.cpp
changeset 35086 bbf32241d851
parent 34185 ee71c590a456
child 35092 82170e5767c3
equal deleted inserted replaced
35085:839c8ba29724 35086:bbf32241d851
   976     print_pcs();
   976     print_pcs();
   977     if (oop_maps()) {
   977     if (oop_maps()) {
   978       oop_maps()->print();
   978       oop_maps()->print();
   979     }
   979     }
   980   }
   980   }
   981   if (PrintDebugInfo || CompilerOracle::has_option_string(_method, "PrintDebugInfo")) {
   981   if (printmethod || PrintDebugInfo || CompilerOracle::has_option_string(_method, "PrintDebugInfo")) {
   982     print_scopes();
   982     print_scopes();
   983   }
   983   }
   984   if (PrintRelocations || CompilerOracle::has_option_string(_method, "PrintRelocations")) {
   984   if (printmethod || PrintRelocations || CompilerOracle::has_option_string(_method, "PrintRelocations")) {
   985     print_relocations();
   985     print_relocations();
   986   }
   986   }
   987   if (PrintDependencies || CompilerOracle::has_option_string(_method, "PrintDependencies")) {
   987   if (printmethod || PrintDependencies || CompilerOracle::has_option_string(_method, "PrintDependencies")) {
   988     print_dependencies();
   988     print_dependencies();
   989   }
   989   }
   990   if (PrintExceptionHandlers) {
   990   if (printmethod || PrintExceptionHandlers) {
   991     print_handler_table();
   991     print_handler_table();
   992     print_nul_chk_table();
   992     print_nul_chk_table();
       
   993   }
       
   994   if (printmethod) {
       
   995     print_recorded_oops();
       
   996     print_recorded_metadata();
   993   }
   997   }
   994   if (xtty != NULL) {
   998   if (xtty != NULL) {
   995     xtty->tail("print_nmethod");
   999     xtty->tail("print_nmethod");
   996   }
  1000   }
   997 }
  1001 }
  3011   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
  3015   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
  3012     p->print(this);
  3016     p->print(this);
  3013   }
  3017   }
  3014 }
  3018 }
  3015 
  3019 
       
  3020 void nmethod::print_recorded_oops() {
       
  3021   tty->print_cr("Recorded oops:");
       
  3022   for (int i = 0; i < oops_count(); i++) {
       
  3023     oop o = oop_at(i);
       
  3024     tty->print("#%3d: " INTPTR_FORMAT " ", i, p2i(o));
       
  3025     o->print_value();
       
  3026     tty->cr();
       
  3027   }
       
  3028 }
       
  3029 
       
  3030 void nmethod::print_recorded_metadata() {
       
  3031   tty->print_cr("Recorded metadata:");
       
  3032   for (int i = 0; i < metadata_count(); i++) {
       
  3033     Metadata* m = metadata_at(i);
       
  3034     tty->print("#%3d: " INTPTR_FORMAT " ", i, p2i(m));
       
  3035     m->print_value_on_maybe_null(tty);
       
  3036     tty->cr();
       
  3037   }
       
  3038 }
       
  3039 
  3016 #endif // PRODUCT
  3040 #endif // PRODUCT
  3017 
  3041 
  3018 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
  3042 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
  3019   RelocIterator iter(this, begin, end);
  3043   RelocIterator iter(this, begin, end);
  3020   bool have_one = false;
  3044   bool have_one = false;
  3051           if (cb != NULL) {
  3075           if (cb != NULL) {
  3052             st.print(" %s", cb->name());
  3076             st.print(" %s", cb->name());
  3053           }
  3077           }
  3054           return st.as_string();
  3078           return st.as_string();
  3055         }
  3079         }
  3056         case relocInfo::virtual_call_type:     return "virtual_call";
  3080         case relocInfo::virtual_call_type: {
  3057         case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
  3081           stringStream st;
  3058         case relocInfo::static_call_type:      return "static_call";
  3082           st.print_raw("virtual_call");
       
  3083           virtual_call_Relocation* r = iter.virtual_call_reloc();
       
  3084           Method* m = r->method_value();
       
  3085           if (m != NULL) {
       
  3086             assert(m->is_method(), "");
       
  3087             m->print_short_name(&st);
       
  3088           }
       
  3089           return st.as_string();
       
  3090         }
       
  3091         case relocInfo::opt_virtual_call_type: {
       
  3092           stringStream st;
       
  3093           st.print_raw("optimized virtual_call");
       
  3094           opt_virtual_call_Relocation* r = iter.opt_virtual_call_reloc();
       
  3095           Method* m = r->method_value();
       
  3096           if (m != NULL) {
       
  3097             assert(m->is_method(), "");
       
  3098             m->print_short_name(&st);
       
  3099           }
       
  3100           return st.as_string();
       
  3101         }
       
  3102         case relocInfo::static_call_type: {
       
  3103           stringStream st;
       
  3104           st.print_raw("static_call");
       
  3105           static_call_Relocation* r = iter.static_call_reloc();
       
  3106           Method* m = r->method_value();
       
  3107           if (m != NULL) {
       
  3108             assert(m->is_method(), "");
       
  3109             m->print_short_name(&st);
       
  3110           }
       
  3111           return st.as_string();
       
  3112         }
  3059         case relocInfo::static_stub_type:      return "static_stub";
  3113         case relocInfo::static_stub_type:      return "static_stub";
  3060         case relocInfo::external_word_type:    return "external_word";
  3114         case relocInfo::external_word_type:    return "external_word";
  3061         case relocInfo::internal_word_type:    return "internal_word";
  3115         case relocInfo::internal_word_type:    return "internal_word";
  3062         case relocInfo::section_word_type:     return "section_word";
  3116         case relocInfo::section_word_type:     return "section_word";
  3063         case relocInfo::poll_type:             return "poll";
  3117         case relocInfo::poll_type:             return "poll";
  3391   }
  3445   }
  3392   jio_snprintf(buf, buflen, "noInstalledCode");
  3446   jio_snprintf(buf, buflen, "noInstalledCode");
  3393   return buf;
  3447   return buf;
  3394 }
  3448 }
  3395 #endif
  3449 #endif
       
  3450 
       
  3451 Method* nmethod::attached_method(address call_instr) {
       
  3452   assert(code_contains(call_instr), "not part of the nmethod");
       
  3453   RelocIterator iter(this, call_instr, call_instr + 1);
       
  3454   while (iter.next()) {
       
  3455     if (iter.addr() == call_instr) {
       
  3456       switch(iter.type()) {
       
  3457         case relocInfo::static_call_type:      return iter.static_call_reloc()->method_value();
       
  3458         case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value();
       
  3459         case relocInfo::virtual_call_type:     return iter.virtual_call_reloc()->method_value();
       
  3460       }
       
  3461     }
       
  3462   }
       
  3463   return NULL; // not found
       
  3464 }
       
  3465