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

src/share/vm/code/nmethod.cpp

Print this page




 961 }
 962 
 963 
 964 void nmethod::print_nmethod(bool printmethod) {
 965   ttyLocker ttyl;  // keep the following output all in one block
 966   if (xtty != NULL) {
 967     xtty->begin_head("print_nmethod");
 968     xtty->stamp();
 969     xtty->end_head();
 970   }
 971   // print the header part first
 972   print();
 973   // then print the requested information
 974   if (printmethod) {
 975     print_code();
 976     print_pcs();
 977     if (oop_maps()) {
 978       oop_maps()->print();
 979     }
 980   }
 981   if (PrintDebugInfo || CompilerOracle::has_option_string(_method, "PrintDebugInfo")) {
 982     print_scopes();
 983   }
 984   if (PrintRelocations || CompilerOracle::has_option_string(_method, "PrintRelocations")) {
 985     print_relocations();
 986   }
 987   if (PrintDependencies || CompilerOracle::has_option_string(_method, "PrintDependencies")) {
 988     print_dependencies();
 989   }
 990   if (PrintExceptionHandlers) {
 991     print_handler_table();
 992     print_nul_chk_table();
 993   }




 994   if (xtty != NULL) {
 995     xtty->tail("print_nmethod");
 996   }
 997 }
 998 
 999 
1000 // Promote one word from an assembly-time handle to a live embedded oop.
1001 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
1002   if (handle == NULL ||
1003       // As a special case, IC oops are initialized to 1 or -1.
1004       handle == (jobject) Universe::non_oop_word()) {
1005     (*dest) = (oop) handle;
1006   } else {
1007     (*dest) = JNIHandles::resolve_non_null(handle);
1008   }
1009 }
1010 
1011 
1012 // Have to have the same name because it's called by a template
1013 void nmethod::copy_values(GrowableArray<jobject>* array) {


2996                       p2i(header_end()+ip[0]),
2997                       p2i(relocation_begin()-1+ip[1]));
2998       for (; ip < index_end; ip++)
2999         tty->print_cr("  (%d ?)", ip[0]);
3000       tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", p2i(ip), *ip);
3001       ip++;
3002       tty->print_cr("reloc_end @" INTPTR_FORMAT ":", p2i(ip));
3003     }
3004   }
3005 }
3006 
3007 
3008 void nmethod::print_pcs() {
3009   ResourceMark m;       // in case methods get printed via debugger
3010   tty->print_cr("pc-bytecode offsets:");
3011   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
3012     p->print(this);
3013   }
3014 }
3015 




















3016 #endif // PRODUCT
3017 
3018 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
3019   RelocIterator iter(this, begin, end);
3020   bool have_one = false;
3021   while (iter.next()) {
3022     have_one = true;
3023     switch (iter.type()) {
3024         case relocInfo::none:                  return "no_reloc";
3025         case relocInfo::oop_type: {
3026           stringStream st;
3027           oop_Relocation* r = iter.oop_reloc();
3028           oop obj = r->oop_value();
3029           st.print("oop(");
3030           if (obj == NULL) st.print("NULL");
3031           else obj->print_value_on(&st);
3032           st.print(")");
3033           return st.as_string();
3034         }
3035         case relocInfo::metadata_type: {
3036           stringStream st;
3037           metadata_Relocation* r = iter.metadata_reloc();
3038           Metadata* obj = r->metadata_value();
3039           st.print("metadata(");
3040           if (obj == NULL) st.print("NULL");
3041           else obj->print_value_on(&st);
3042           st.print(")");
3043           return st.as_string();
3044         }
3045         case relocInfo::runtime_call_type: {
3046           stringStream st;
3047           st.print("runtime_call");
3048           runtime_call_Relocation* r = iter.runtime_call_reloc();
3049           address dest = r->destination();
3050           CodeBlob* cb = CodeCache::find_blob(dest);
3051           if (cb != NULL) {
3052             st.print(" %s", cb->name());
3053           }
3054           return st.as_string();
3055         }
3056         case relocInfo::virtual_call_type:     return "virtual_call";
3057         case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
3058         case relocInfo::static_call_type:      return "static_call";






























3059         case relocInfo::static_stub_type:      return "static_stub";
3060         case relocInfo::external_word_type:    return "external_word";
3061         case relocInfo::internal_word_type:    return "internal_word";
3062         case relocInfo::section_word_type:     return "section_word";
3063         case relocInfo::poll_type:             return "poll";
3064         case relocInfo::poll_return_type:      return "poll_return";
3065         case relocInfo::type_mask:             return "type_bit_mask";
3066     }
3067   }
3068   return have_one ? "other" : NULL;
3069 }
3070 
3071 // Return a the last scope in (begin..end]
3072 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3073   PcDesc* p = pc_desc_near(begin+1);
3074   if (p != NULL && p->real_pc(this) <= end) {
3075     return new ScopeDesc(this, p->scope_decode_offset(),
3076                          p->obj_decode_offset(), p->should_reexecute(), p->rethrow_exception(),
3077                          p->return_oop());
3078   }


3376   if (!this->is_compiled_by_jvmci()) {
3377     return NULL;
3378   }
3379   oop installedCode = this->jvmci_installed_code();
3380   if (installedCode != NULL) {
3381     oop installedCodeName = NULL;
3382     if (installedCode->is_a(InstalledCode::klass())) {
3383       installedCodeName = InstalledCode::name(installedCode);
3384     }
3385     if (installedCodeName != NULL) {
3386       return java_lang_String::as_utf8_string(installedCodeName, buf, (int)buflen);
3387     } else {
3388       jio_snprintf(buf, buflen, "null");
3389       return buf;
3390     }
3391   }
3392   jio_snprintf(buf, buflen, "noInstalledCode");
3393   return buf;
3394 }
3395 #endif


















 961 }
 962 
 963 
 964 void nmethod::print_nmethod(bool printmethod) {
 965   ttyLocker ttyl;  // keep the following output all in one block
 966   if (xtty != NULL) {
 967     xtty->begin_head("print_nmethod");
 968     xtty->stamp();
 969     xtty->end_head();
 970   }
 971   // print the header part first
 972   print();
 973   // then print the requested information
 974   if (printmethod) {
 975     print_code();
 976     print_pcs();
 977     if (oop_maps()) {
 978       oop_maps()->print();
 979     }
 980   }
 981   if (printmethod || PrintDebugInfo || CompilerOracle::has_option_string(_method, "PrintDebugInfo")) {
 982     print_scopes();
 983   }
 984   if (printmethod || PrintRelocations || CompilerOracle::has_option_string(_method, "PrintRelocations")) {
 985     print_relocations();
 986   }
 987   if (printmethod || PrintDependencies || CompilerOracle::has_option_string(_method, "PrintDependencies")) {
 988     print_dependencies();
 989   }
 990   if (printmethod || PrintExceptionHandlers) {
 991     print_handler_table();
 992     print_nul_chk_table();
 993   }
 994   if (printmethod) {
 995     print_recorded_oops();
 996     print_recorded_metadata();
 997   }
 998   if (xtty != NULL) {
 999     xtty->tail("print_nmethod");
1000   }
1001 }
1002 
1003 
1004 // Promote one word from an assembly-time handle to a live embedded oop.
1005 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
1006   if (handle == NULL ||
1007       // As a special case, IC oops are initialized to 1 or -1.
1008       handle == (jobject) Universe::non_oop_word()) {
1009     (*dest) = (oop) handle;
1010   } else {
1011     (*dest) = JNIHandles::resolve_non_null(handle);
1012   }
1013 }
1014 
1015 
1016 // Have to have the same name because it's called by a template
1017 void nmethod::copy_values(GrowableArray<jobject>* array) {


3000                       p2i(header_end()+ip[0]),
3001                       p2i(relocation_begin()-1+ip[1]));
3002       for (; ip < index_end; ip++)
3003         tty->print_cr("  (%d ?)", ip[0]);
3004       tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", p2i(ip), *ip);
3005       ip++;
3006       tty->print_cr("reloc_end @" INTPTR_FORMAT ":", p2i(ip));
3007     }
3008   }
3009 }
3010 
3011 
3012 void nmethod::print_pcs() {
3013   ResourceMark m;       // in case methods get printed via debugger
3014   tty->print_cr("pc-bytecode offsets:");
3015   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
3016     p->print(this);
3017   }
3018 }
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 
3040 #endif // PRODUCT
3041 
3042 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
3043   RelocIterator iter(this, begin, end);
3044   bool have_one = false;
3045   while (iter.next()) {
3046     have_one = true;
3047     switch (iter.type()) {
3048         case relocInfo::none:                  return "no_reloc";
3049         case relocInfo::oop_type: {
3050           stringStream st;
3051           oop_Relocation* r = iter.oop_reloc();
3052           oop obj = r->oop_value();
3053           st.print("oop(");
3054           if (obj == NULL) st.print("NULL");
3055           else obj->print_value_on(&st);
3056           st.print(")");
3057           return st.as_string();
3058         }
3059         case relocInfo::metadata_type: {
3060           stringStream st;
3061           metadata_Relocation* r = iter.metadata_reloc();
3062           Metadata* obj = r->metadata_value();
3063           st.print("metadata(");
3064           if (obj == NULL) st.print("NULL");
3065           else obj->print_value_on(&st);
3066           st.print(")");
3067           return st.as_string();
3068         }
3069         case relocInfo::runtime_call_type: {
3070           stringStream st;
3071           st.print("runtime_call");
3072           runtime_call_Relocation* r = iter.runtime_call_reloc();
3073           address dest = r->destination();
3074           CodeBlob* cb = CodeCache::find_blob(dest);
3075           if (cb != NULL) {
3076             st.print(" %s", cb->name());
3077           }
3078           return st.as_string();
3079         }
3080         case relocInfo::virtual_call_type: {
3081           stringStream st;
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         }
3113         case relocInfo::static_stub_type:      return "static_stub";
3114         case relocInfo::external_word_type:    return "external_word";
3115         case relocInfo::internal_word_type:    return "internal_word";
3116         case relocInfo::section_word_type:     return "section_word";
3117         case relocInfo::poll_type:             return "poll";
3118         case relocInfo::poll_return_type:      return "poll_return";
3119         case relocInfo::type_mask:             return "type_bit_mask";
3120     }
3121   }
3122   return have_one ? "other" : NULL;
3123 }
3124 
3125 // Return a the last scope in (begin..end]
3126 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3127   PcDesc* p = pc_desc_near(begin+1);
3128   if (p != NULL && p->real_pc(this) <= end) {
3129     return new ScopeDesc(this, p->scope_decode_offset(),
3130                          p->obj_decode_offset(), p->should_reexecute(), p->rethrow_exception(),
3131                          p->return_oop());
3132   }


3430   if (!this->is_compiled_by_jvmci()) {
3431     return NULL;
3432   }
3433   oop installedCode = this->jvmci_installed_code();
3434   if (installedCode != NULL) {
3435     oop installedCodeName = NULL;
3436     if (installedCode->is_a(InstalledCode::klass())) {
3437       installedCodeName = InstalledCode::name(installedCode);
3438     }
3439     if (installedCodeName != NULL) {
3440       return java_lang_String::as_utf8_string(installedCodeName, buf, (int)buflen);
3441     } else {
3442       jio_snprintf(buf, buflen, "null");
3443       return buf;
3444     }
3445   }
3446   jio_snprintf(buf, buflen, "noInstalledCode");
3447   return buf;
3448 }
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 
src/share/vm/code/nmethod.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File