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




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




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


3032                       p2i(header_end()+ip[0]),
3033                       p2i(relocation_begin()-1+ip[1]));
3034       for (; ip < index_end; ip++)
3035         tty->print_cr("  (%d ?)", ip[0]);
3036       tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", p2i(ip), *ip);
3037       ip++;
3038       tty->print_cr("reloc_end @" INTPTR_FORMAT ":", p2i(ip));
3039     }
3040   }
3041 }
3042 
3043 
3044 void nmethod::print_pcs() {
3045   ResourceMark m;       // in case methods get printed via debugger
3046   tty->print_cr("pc-bytecode offsets:");
3047   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
3048     p->print(this);
3049   }
3050 }
3051 




















3052 #endif // PRODUCT
3053 
3054 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
3055   RelocIterator iter(this, begin, end);
3056   bool have_one = false;
3057   while (iter.next()) {
3058     have_one = true;
3059     switch (iter.type()) {
3060         case relocInfo::none:                  return "no_reloc";
3061         case relocInfo::oop_type: {
3062           stringStream st;
3063           oop_Relocation* r = iter.oop_reloc();
3064           oop obj = r->oop_value();
3065           st.print("oop(");
3066           if (obj == NULL) st.print("NULL");
3067           else obj->print_value_on(&st);
3068           st.print(")");
3069           return st.as_string();
3070         }
3071         case relocInfo::metadata_type: {
3072           stringStream st;
3073           metadata_Relocation* r = iter.metadata_reloc();
3074           Metadata* obj = r->metadata_value();
3075           st.print("metadata(");
3076           if (obj == NULL) st.print("NULL");
3077           else obj->print_value_on(&st);
3078           st.print(")");
3079           return st.as_string();
3080         }
3081         case relocInfo::runtime_call_type: {
3082           stringStream st;
3083           st.print("runtime_call");
3084           runtime_call_Relocation* r = iter.runtime_call_reloc();
3085           address dest = r->destination();
3086           CodeBlob* cb = CodeCache::find_blob(dest);
3087           if (cb != NULL) {
3088             st.print(" %s", cb->name());
3089           }
3090           return st.as_string();
3091         }
3092         case relocInfo::virtual_call_type:     return "virtual_call";
3093         case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
3094         case relocInfo::static_call_type:      return "static_call";






























3095         case relocInfo::static_stub_type:      return "static_stub";
3096         case relocInfo::external_word_type:    return "external_word";
3097         case relocInfo::internal_word_type:    return "internal_word";
3098         case relocInfo::section_word_type:     return "section_word";
3099         case relocInfo::poll_type:             return "poll";
3100         case relocInfo::poll_return_type:      return "poll_return";
3101         case relocInfo::type_mask:             return "type_bit_mask";
3102     }
3103   }
3104   return have_one ? "other" : NULL;
3105 }
3106 
3107 // Return a the last scope in (begin..end]
3108 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3109   PcDesc* p = pc_desc_near(begin+1);
3110   if (p != NULL && p->real_pc(this) <= end) {
3111     return new ScopeDesc(this, p->scope_decode_offset(),
3112                          p->obj_decode_offset(), p->should_reexecute(), p->rethrow_exception(),
3113                          p->return_oop());
3114   }




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


3036                       p2i(header_end()+ip[0]),
3037                       p2i(relocation_begin()-1+ip[1]));
3038       for (; ip < index_end; ip++)
3039         tty->print_cr("  (%d ?)", ip[0]);
3040       tty->print_cr("          @" INTPTR_FORMAT ": index_size=%d", p2i(ip), *ip);
3041       ip++;
3042       tty->print_cr("reloc_end @" INTPTR_FORMAT ":", p2i(ip));
3043     }
3044   }
3045 }
3046 
3047 
3048 void nmethod::print_pcs() {
3049   ResourceMark m;       // in case methods get printed via debugger
3050   tty->print_cr("pc-bytecode offsets:");
3051   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
3052     p->print(this);
3053   }
3054 }
3055 
3056 void nmethod::print_recorded_oops() {
3057   tty->print_cr("Recorded oops:");
3058   for (int i = 0; i < oops_count(); i++) {
3059     oop o = oop_at(i);
3060     tty->print("#%3d: " INTPTR_FORMAT " ", i, p2i(o));
3061     o->print_value();
3062     tty->cr();
3063   }
3064 }
3065 
3066 void nmethod::print_recorded_metadata() {
3067   tty->print_cr("Recorded metadata:");
3068   for (int i = 0; i < metadata_count(); i++) {
3069     Metadata* m = metadata_at(i);
3070     tty->print("#%3d: " INTPTR_FORMAT " ", i, p2i(m));
3071     m->print_value_on_maybe_null(tty);
3072     tty->cr();
3073   }
3074 }
3075 
3076 #endif // PRODUCT
3077 
3078 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
3079   RelocIterator iter(this, begin, end);
3080   bool have_one = false;
3081   while (iter.next()) {
3082     have_one = true;
3083     switch (iter.type()) {
3084         case relocInfo::none:                  return "no_reloc";
3085         case relocInfo::oop_type: {
3086           stringStream st;
3087           oop_Relocation* r = iter.oop_reloc();
3088           oop obj = r->oop_value();
3089           st.print("oop(");
3090           if (obj == NULL) st.print("NULL");
3091           else obj->print_value_on(&st);
3092           st.print(")");
3093           return st.as_string();
3094         }
3095         case relocInfo::metadata_type: {
3096           stringStream st;
3097           metadata_Relocation* r = iter.metadata_reloc();
3098           Metadata* obj = r->metadata_value();
3099           st.print("metadata(");
3100           if (obj == NULL) st.print("NULL");
3101           else obj->print_value_on(&st);
3102           st.print(")");
3103           return st.as_string();
3104         }
3105         case relocInfo::runtime_call_type: {
3106           stringStream st;
3107           st.print("runtime_call");
3108           runtime_call_Relocation* r = iter.runtime_call_reloc();
3109           address dest = r->destination();
3110           CodeBlob* cb = CodeCache::find_blob(dest);
3111           if (cb != NULL) {
3112             st.print(" %s", cb->name());
3113           }
3114           return st.as_string();
3115         }
3116         case relocInfo::virtual_call_type: {
3117           stringStream st;
3118           st.print_raw("virtual_call");
3119           virtual_call_Relocation* r = iter.virtual_call_reloc();
3120           Method* m = r->method_value();
3121           if (m != NULL) {
3122             assert(m->is_method(), "");
3123             m->print_short_name(&st);
3124           }
3125           return st.as_string();
3126         }
3127         case relocInfo::opt_virtual_call_type: {
3128           stringStream st;
3129           st.print_raw("optimized virtual_call");
3130           opt_virtual_call_Relocation* r = iter.opt_virtual_call_reloc();
3131           Method* m = r->method_value();
3132           if (m != NULL) {
3133             assert(m->is_method(), "");
3134             m->print_short_name(&st);
3135           }
3136           return st.as_string();
3137         }
3138         case relocInfo::static_call_type: {
3139           stringStream st;
3140           st.print_raw("static_call");
3141           static_call_Relocation* r = iter.static_call_reloc();
3142           Method* m = r->method_value();
3143           if (m != NULL) {
3144             assert(m->is_method(), "");
3145             m->print_short_name(&st);
3146           }
3147           return st.as_string();
3148         }
3149         case relocInfo::static_stub_type:      return "static_stub";
3150         case relocInfo::external_word_type:    return "external_word";
3151         case relocInfo::internal_word_type:    return "internal_word";
3152         case relocInfo::section_word_type:     return "section_word";
3153         case relocInfo::poll_type:             return "poll";
3154         case relocInfo::poll_return_type:      return "poll_return";
3155         case relocInfo::type_mask:             return "type_bit_mask";
3156     }
3157   }
3158   return have_one ? "other" : NULL;
3159 }
3160 
3161 // Return a the last scope in (begin..end]
3162 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3163   PcDesc* p = pc_desc_near(begin+1);
3164   if (p != NULL && p->real_pc(this) <= end) {
3165     return new ScopeDesc(this, p->scope_decode_offset(),
3166                          p->obj_decode_offset(), p->should_reexecute(), p->rethrow_exception(),
3167                          p->return_oop());
3168   }


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