< prev index next >

src/hotspot/share/code/nmethod.cpp

Print this page

 626     _stub_offset             = data_offset();
 627     _oops_offset             = data_offset();
 628     _metadata_offset         = _oops_offset         + align_up(code_buffer->total_oop_size(), oopSize);
 629     scopes_data_offset       = _metadata_offset     + align_up(code_buffer->total_metadata_size(), wordSize);
 630     _scopes_pcs_offset       = scopes_data_offset;
 631     _dependencies_offset     = _scopes_pcs_offset;
 632     _native_invokers_offset     = _dependencies_offset;
 633     _handler_table_offset    = _native_invokers_offset;
 634     _nul_chk_table_offset    = _handler_table_offset;
 635 #if INCLUDE_JVMCI
 636     _speculations_offset     = _nul_chk_table_offset;
 637     _jvmci_data_offset       = _speculations_offset;
 638     _nmethod_end_offset      = _jvmci_data_offset;
 639 #else
 640     _nmethod_end_offset      = _nul_chk_table_offset;
 641 #endif
 642     _compile_id              = compile_id;
 643     _comp_level              = CompLevel_none;
 644     _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
 645     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);






 646     _osr_entry_point         = NULL;
 647     _exception_cache         = NULL;
 648     _pc_desc_container.reset_to(NULL);
 649     _hotness_counter         = NMethodSweeper::hotness_counter_reset_val();
 650 
 651     _scopes_data_begin = (address) this + scopes_data_offset;
 652     _deopt_handler_begin = (address) this + deoptimize_offset;
 653     _deopt_mh_handler_begin = (address) this + deoptimize_mh_offset;
 654 
 655     code_buffer->copy_code_and_locs_to(this);
 656     code_buffer->copy_values_to(this);
 657 
 658     clear_unloading_state();
 659 
 660     Universe::heap()->register_nmethod(this);
 661     debug_only(Universe::heap()->verify_nmethod(this));
 662 
 663     CodeCache::commit(this);
 664   }
 665 

 799     }
 800 
 801     _oops_offset             = data_offset();
 802     _metadata_offset         = _oops_offset          + align_up(code_buffer->total_oop_size(), oopSize);
 803     int scopes_data_offset   = _metadata_offset      + align_up(code_buffer->total_metadata_size(), wordSize);
 804 
 805     _scopes_pcs_offset       = scopes_data_offset    + align_up(debug_info->data_size       (), oopSize);
 806     _dependencies_offset     = _scopes_pcs_offset    + adjust_pcs_size(debug_info->pcs_size());
 807     _native_invokers_offset  = _dependencies_offset  + align_up((int)dependencies->size_in_bytes(), oopSize);
 808     _handler_table_offset    = _native_invokers_offset + align_up(checked_cast<int>(native_invokers.data_size_in_bytes()), oopSize);
 809     _nul_chk_table_offset    = _handler_table_offset + align_up(handler_table->size_in_bytes(), oopSize);
 810 #if INCLUDE_JVMCI
 811     _speculations_offset     = _nul_chk_table_offset + align_up(nul_chk_table->size_in_bytes(), oopSize);
 812     _jvmci_data_offset       = _speculations_offset  + align_up(speculations_len, oopSize);
 813     _nmethod_end_offset      = _jvmci_data_offset    + align_up(jvmci_data_size, oopSize);
 814 #else
 815     _nmethod_end_offset      = _nul_chk_table_offset + align_up(nul_chk_table->size_in_bytes(), oopSize);
 816 #endif
 817     _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
 818     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);



 819     _osr_entry_point         = code_begin()          + offsets->value(CodeOffsets::OSR_Entry);
 820     _exception_cache         = NULL;
 821     _scopes_data_begin       = (address) this + scopes_data_offset;
 822 
 823     _pc_desc_container.reset_to(scopes_pcs_begin());
 824 
 825     code_buffer->copy_code_and_locs_to(this);
 826     // Copy contents of ScopeDescRecorder to nmethod
 827     code_buffer->copy_values_to(this);
 828     debug_info->copy_to(this);
 829     dependencies->copy_to(this);
 830     if (native_invokers.is_nonempty()) { // can not get address of zero-length array
 831       // Copy native stubs
 832       memcpy(native_invokers_begin(), native_invokers.adr_at(0), native_invokers.data_size_in_bytes());
 833     }
 834     clear_unloading_state();
 835 
 836     Universe::heap()->register_nmethod(this);
 837     debug_only(Universe::heap()->verify_nmethod(this));
 838 

 918 // Print out more verbose output usually for a newly created nmethod.
 919 void nmethod::print_on(outputStream* st, const char* msg) const {
 920   if (st != NULL) {
 921     ttyLocker ttyl;
 922     if (WizardMode) {
 923       CompileTask::print(st, this, msg, /*short_form:*/ true);
 924       st->print_cr(" (" INTPTR_FORMAT ")", p2i(this));
 925     } else {
 926       CompileTask::print(st, this, msg, /*short_form:*/ false);
 927     }
 928   }
 929 }
 930 
 931 void nmethod::maybe_print_nmethod(DirectiveSet* directive) {
 932   bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
 933   if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
 934     print_nmethod(printnmethods);
 935   }
 936 }
 937 



 938 void nmethod::print_nmethod(bool printmethod) {
 939   run_nmethod_entry_barrier(); // ensure all embedded OOPs are valid before printing
 940 






 941   ttyLocker ttyl;  // keep the following output all in one block



 942   if (xtty != NULL) {
 943     xtty->begin_head("print_nmethod");
 944     log_identity(xtty);
 945     xtty->stamp();
 946     xtty->end_head();
 947   }
 948   // Print the header part, then print the requested information.
 949   // This is both handled in decode2().
 950   if (printmethod) {
 951     ResourceMark m;
 952     if (is_compiled_by_c1()) {
 953       tty->cr();
 954       tty->print_cr("============================= C1-compiled nmethod ==============================");
 955     }
 956     if (is_compiled_by_jvmci()) {
 957       tty->cr();
 958       tty->print_cr("=========================== JVMCI-compiled nmethod =============================");
 959     }
 960     tty->print_cr("----------------------------------- Assembly -----------------------------------");
 961     decode2(tty);

1001     }
1002     if (printmethod || PrintExceptionHandlers) {
1003       print_handler_table();
1004       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1005       print_nul_chk_table();
1006       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1007     }
1008 
1009     if (printmethod) {
1010       print_recorded_oops();
1011       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1012       print_recorded_metadata();
1013       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1014     }
1015   }
1016 #endif
1017 
1018   if (xtty != NULL) {
1019     xtty->tail("print_nmethod");
1020   }



1021 }
1022 
1023 
1024 // Promote one word from an assembly-time handle to a live embedded oop.
1025 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
1026   if (handle == NULL ||
1027       // As a special case, IC oops are initialized to 1 or -1.
1028       handle == (jobject) Universe::non_oop_word()) {
1029     *(void**)dest = handle;
1030   } else {
1031     *dest = JNIHandles::resolve_non_null(handle);
1032   }
1033 }
1034 
1035 
1036 // Have to have the same name because it's called by a template
1037 void nmethod::copy_values(GrowableArray<jobject>* array) {
1038   int length = array->length();
1039   assert((address)(oops_begin() + length) <= (address)oops_end(), "oops big enough");
1040   oop* dest = oops_begin();

3119         default:
3120           break;
3121     }
3122   }
3123   return have_one ? "other" : NULL;
3124 }
3125 
3126 // Return a the last scope in (begin..end]
3127 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3128   PcDesc* p = pc_desc_near(begin+1);
3129   if (p != NULL && p->real_pc(this) <= end) {
3130     return new ScopeDesc(this, p);
3131   }
3132   return NULL;
3133 }
3134 
3135 const char* nmethod::nmethod_section_label(address pos) const {
3136   const char* label = NULL;
3137   if (pos == code_begin())                                              label = "[Instructions begin]";
3138   if (pos == entry_point())                                             label = "[Entry Point]";

3139   if (pos == verified_entry_point())                                    label = "[Verified Entry Point]";


3140   if (has_method_handle_invokes() && (pos == deopt_mh_handler_begin())) label = "[Deopt MH Handler Code]";
3141   if (pos == consts_begin() && pos != insts_begin())                    label = "[Constants]";
3142   // Check stub_code before checking exception_handler or deopt_handler.
3143   if (pos == this->stub_begin())                                        label = "[Stub Code]";
3144   if (JVMCI_ONLY(_exception_offset >= 0 &&) pos == exception_begin())           label = "[Exception Handler]";
3145   if (JVMCI_ONLY(_deopt_handler_begin != NULL &&) pos == deopt_handler_begin()) label = "[Deopt Handler Code]";
3146   return label;
3147 }
3148 










3149 void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels) const {
3150   if (print_section_labels) {
3151     const char* label = nmethod_section_label(block_begin);
3152     if (label != NULL) {
3153       stream->bol();
3154       stream->print_cr("%s", label);
3155     }
3156   }
3157 
3158   if (block_begin == entry_point()) {
3159     Method* m = method();
3160     if (m != NULL) {
3161       stream->print("  # ");
3162       m->print_value_on(stream);
3163       stream->cr();
3164     }
3165     if (m != NULL && !is_osr_method()) {
3166       ResourceMark rm;
3167       int sizeargs = m->size_of_parameters();
3168       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
3169       VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
3170       {
3171         int sig_index = 0;
3172         if (!m->is_static())
3173           sig_bt[sig_index++] = T_OBJECT; // 'this'
3174         for (SignatureStream ss(m->signature()); !ss.at_return_type(); ss.next()) {
3175           BasicType t = ss.type();
3176           sig_bt[sig_index++] = t;
3177           if (type2size[t] == 2) {
3178             sig_bt[sig_index++] = T_VOID;
3179           } else {
3180             assert(type2size[t] == 1, "size is 1 or 2");
3181           }
3182         }
3183         assert(sig_index == sizeargs, "");
3184       }
3185       const char* spname = "sp"; // make arch-specific?
3186       intptr_t out_preserve = SharedRuntime::java_calling_convention(sig_bt, regs, sizeargs);
3187       int stack_slot_offset = this->frame_size() * wordSize;
3188       int tab1 = 14, tab2 = 24;
3189       int sig_index = 0;
3190       int arg_index = (m->is_static() ? 0 : -1);
3191       bool did_old_sp = false;
3192       for (SignatureStream ss(m->signature()); !ss.at_return_type(); ) {
3193         bool at_this = (arg_index == -1);
3194         bool at_old_sp = false;
3195         BasicType t = (at_this ? T_OBJECT : ss.type());
3196         assert(t == sig_bt[sig_index], "sigs in sync");
3197         if (at_this)
3198           stream->print("  # this: ");
3199         else
3200           stream->print("  # parm%d: ", arg_index);
3201         stream->move_to(tab1);
3202         VMReg fst = regs[sig_index].first();
3203         VMReg snd = regs[sig_index].second();
3204         if (fst->is_reg()) {
3205           stream->print("%s", fst->name());
3206           if (snd->is_valid())  {
3207             stream->print(":%s", snd->name());
3208           }
3209         } else if (fst->is_stack()) {
3210           int offset = fst->reg2stack() * VMRegImpl::stack_slot_size + stack_slot_offset;
3211           if (offset == stack_slot_offset)  at_old_sp = true;
3212           stream->print("[%s+0x%x]", spname, offset);
3213         } else {
3214           stream->print("reg%d:%d??", (int)(intptr_t)fst, (int)(intptr_t)snd);
3215         }
3216         stream->print(" ");
3217         stream->move_to(tab2);
3218         stream->print("= ");
3219         if (at_this) {
3220           m->method_holder()->print_value_on(stream);
3221         } else {
3222           bool did_name = false;
3223           if (!at_this && ss.is_reference()) {
3224             Symbol* name = ss.as_symbol();
3225             name->print_value_on(stream);
3226             did_name = true;
3227           }
3228           if (!did_name)
3229             stream->print("%s", type2name(t));
3230         }
3231         if (at_old_sp) {
3232           stream->print("  (%s of caller)", spname);
3233           did_old_sp = true;
3234         }
3235         stream->cr();
3236         sig_index += type2size[t];
3237         arg_index += 1;
3238         if (!at_this)  ss.next();











3239       }
3240       if (!did_old_sp) {
3241         stream->print("  # ");
3242         stream->move_to(tab1);
3243         stream->print("[%s+0x%x]", spname, stack_slot_offset);
3244         stream->print("  (%s of caller)", spname);
3245         stream->cr();












3246       }


3247     }














3248   }
3249 }
3250 
3251 // Returns whether this nmethod has code comments.
3252 bool nmethod::has_code_comment(address begin, address end) {
3253   // scopes?
3254   ScopeDesc* sd  = scope_desc_in(begin, end);
3255   if (sd != NULL) return true;
3256 
3257   // relocations?
3258   const char* str = reloc_string_for(begin, end);
3259   if (str != NULL) return true;
3260 
3261   // implicit exceptions?
3262   int cont_offset = ImplicitExceptionTable(this).continuation_offset(begin - code_begin());
3263   if (cont_offset != 0) return true;
3264 
3265   return false;
3266 }
3267 

3351             else
3352               st->print("<UNKNOWN>");
3353             break;
3354           }
3355         case Bytecodes::_getfield:
3356         case Bytecodes::_putfield:
3357         case Bytecodes::_getstatic:
3358         case Bytecodes::_putstatic:
3359           {
3360             Bytecode_field field(methodHandle(thread, sd->method()), sd->bci());
3361             st->print(" ");
3362             if (field.name() != NULL)
3363               field.name()->print_symbol_on(st);
3364             else
3365               st->print("<UNKNOWN>");
3366           }
3367         default:
3368           break;
3369         }
3370       }
3371       st->print(" {reexecute=%d rethrow=%d return_oop=%d}", sd->should_reexecute(), sd->rethrow_exception(), sd->return_oop());
3372     }
3373 
3374     // Print all scopes
3375     for (;sd != NULL; sd = sd->sender()) {
3376       st->move_to(column, 6, 0);
3377       st->print("; -");
3378       if (sd->should_reexecute()) {
3379         st->print(" (reexecute)");
3380       }
3381       if (sd->method() == NULL) {
3382         st->print("method is NULL");
3383       } else {
3384         sd->method()->print_short_name(st);
3385       }
3386       int lineno = sd->method()->line_number_from_bci(sd->bci());
3387       if (lineno != -1) {
3388         st->print("@%d (line %d)", sd->bci(), lineno);
3389       } else {
3390         st->print("@%d", sd->bci());
3391       }

 626     _stub_offset             = data_offset();
 627     _oops_offset             = data_offset();
 628     _metadata_offset         = _oops_offset         + align_up(code_buffer->total_oop_size(), oopSize);
 629     scopes_data_offset       = _metadata_offset     + align_up(code_buffer->total_metadata_size(), wordSize);
 630     _scopes_pcs_offset       = scopes_data_offset;
 631     _dependencies_offset     = _scopes_pcs_offset;
 632     _native_invokers_offset     = _dependencies_offset;
 633     _handler_table_offset    = _native_invokers_offset;
 634     _nul_chk_table_offset    = _handler_table_offset;
 635 #if INCLUDE_JVMCI
 636     _speculations_offset     = _nul_chk_table_offset;
 637     _jvmci_data_offset       = _speculations_offset;
 638     _nmethod_end_offset      = _jvmci_data_offset;
 639 #else
 640     _nmethod_end_offset      = _nul_chk_table_offset;
 641 #endif
 642     _compile_id              = compile_id;
 643     _comp_level              = CompLevel_none;
 644     _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
 645     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
 646 
 647     assert(!method->has_scalarized_args(), "scalarized native wrappers not supported yet"); // for the next 3 fields
 648     _inline_entry_point       = _entry_point;
 649     _verified_inline_entry_point = _verified_entry_point;
 650     _verified_inline_ro_entry_point = _verified_entry_point;
 651 
 652     _osr_entry_point         = NULL;
 653     _exception_cache         = NULL;
 654     _pc_desc_container.reset_to(NULL);
 655     _hotness_counter         = NMethodSweeper::hotness_counter_reset_val();
 656 
 657     _scopes_data_begin = (address) this + scopes_data_offset;
 658     _deopt_handler_begin = (address) this + deoptimize_offset;
 659     _deopt_mh_handler_begin = (address) this + deoptimize_mh_offset;
 660 
 661     code_buffer->copy_code_and_locs_to(this);
 662     code_buffer->copy_values_to(this);
 663 
 664     clear_unloading_state();
 665 
 666     Universe::heap()->register_nmethod(this);
 667     debug_only(Universe::heap()->verify_nmethod(this));
 668 
 669     CodeCache::commit(this);
 670   }
 671 

 805     }
 806 
 807     _oops_offset             = data_offset();
 808     _metadata_offset         = _oops_offset          + align_up(code_buffer->total_oop_size(), oopSize);
 809     int scopes_data_offset   = _metadata_offset      + align_up(code_buffer->total_metadata_size(), wordSize);
 810 
 811     _scopes_pcs_offset       = scopes_data_offset    + align_up(debug_info->data_size       (), oopSize);
 812     _dependencies_offset     = _scopes_pcs_offset    + adjust_pcs_size(debug_info->pcs_size());
 813     _native_invokers_offset  = _dependencies_offset  + align_up((int)dependencies->size_in_bytes(), oopSize);
 814     _handler_table_offset    = _native_invokers_offset + align_up(checked_cast<int>(native_invokers.data_size_in_bytes()), oopSize);
 815     _nul_chk_table_offset    = _handler_table_offset + align_up(handler_table->size_in_bytes(), oopSize);
 816 #if INCLUDE_JVMCI
 817     _speculations_offset     = _nul_chk_table_offset + align_up(nul_chk_table->size_in_bytes(), oopSize);
 818     _jvmci_data_offset       = _speculations_offset  + align_up(speculations_len, oopSize);
 819     _nmethod_end_offset      = _jvmci_data_offset    + align_up(jvmci_data_size, oopSize);
 820 #else
 821     _nmethod_end_offset      = _nul_chk_table_offset + align_up(nul_chk_table->size_in_bytes(), oopSize);
 822 #endif
 823     _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
 824     _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
 825     _inline_entry_point       = code_begin()         + offsets->value(CodeOffsets::Inline_Entry);
 826     _verified_inline_entry_point = code_begin()      + offsets->value(CodeOffsets::Verified_Inline_Entry);
 827     _verified_inline_ro_entry_point = code_begin()   + offsets->value(CodeOffsets::Verified_Inline_Entry_RO);
 828     _osr_entry_point         = code_begin()          + offsets->value(CodeOffsets::OSR_Entry);
 829     _exception_cache         = NULL;
 830     _scopes_data_begin       = (address) this + scopes_data_offset;
 831 
 832     _pc_desc_container.reset_to(scopes_pcs_begin());
 833 
 834     code_buffer->copy_code_and_locs_to(this);
 835     // Copy contents of ScopeDescRecorder to nmethod
 836     code_buffer->copy_values_to(this);
 837     debug_info->copy_to(this);
 838     dependencies->copy_to(this);
 839     if (native_invokers.is_nonempty()) { // can not get address of zero-length array
 840       // Copy native stubs
 841       memcpy(native_invokers_begin(), native_invokers.adr_at(0), native_invokers.data_size_in_bytes());
 842     }
 843     clear_unloading_state();
 844 
 845     Universe::heap()->register_nmethod(this);
 846     debug_only(Universe::heap()->verify_nmethod(this));
 847 

 927 // Print out more verbose output usually for a newly created nmethod.
 928 void nmethod::print_on(outputStream* st, const char* msg) const {
 929   if (st != NULL) {
 930     ttyLocker ttyl;
 931     if (WizardMode) {
 932       CompileTask::print(st, this, msg, /*short_form:*/ true);
 933       st->print_cr(" (" INTPTR_FORMAT ")", p2i(this));
 934     } else {
 935       CompileTask::print(st, this, msg, /*short_form:*/ false);
 936     }
 937   }
 938 }
 939 
 940 void nmethod::maybe_print_nmethod(DirectiveSet* directive) {
 941   bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
 942   if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
 943     print_nmethod(printnmethods);
 944   }
 945 }
 946 
 947 static nmethod* _nmethod_to_print = NULL;
 948 static const CompiledEntrySignature* _nmethod_to_print_ces = NULL;
 949 
 950 void nmethod::print_nmethod(bool printmethod) {
 951   run_nmethod_entry_barrier(); // ensure all embedded OOPs are valid before printing
 952 
 953   ResourceMark rm;
 954   CompiledEntrySignature ces(method());
 955   ces.compute_calling_conventions();
 956   // ces.compute_calling_conventions() needs to grab the ProtectionDomainSet_lock, so we
 957   // can't do that (inside nmethod::print_entry_parameters) while holding the ttyLocker.
 958   // Hence we have do compute it here and pass via a global. Yuck.
 959   ttyLocker ttyl;  // keep the following output all in one block
 960   assert(_nmethod_to_print == NULL && _nmethod_to_print_ces == NULL, "no nesting");
 961   _nmethod_to_print = this;
 962   _nmethod_to_print_ces = &ces;
 963   if (xtty != NULL) {
 964     xtty->begin_head("print_nmethod");
 965     log_identity(xtty);
 966     xtty->stamp();
 967     xtty->end_head();
 968   }
 969   // Print the header part, then print the requested information.
 970   // This is both handled in decode2().
 971   if (printmethod) {
 972     ResourceMark m;
 973     if (is_compiled_by_c1()) {
 974       tty->cr();
 975       tty->print_cr("============================= C1-compiled nmethod ==============================");
 976     }
 977     if (is_compiled_by_jvmci()) {
 978       tty->cr();
 979       tty->print_cr("=========================== JVMCI-compiled nmethod =============================");
 980     }
 981     tty->print_cr("----------------------------------- Assembly -----------------------------------");
 982     decode2(tty);

1022     }
1023     if (printmethod || PrintExceptionHandlers) {
1024       print_handler_table();
1025       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1026       print_nul_chk_table();
1027       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1028     }
1029 
1030     if (printmethod) {
1031       print_recorded_oops();
1032       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1033       print_recorded_metadata();
1034       tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ");
1035     }
1036   }
1037 #endif
1038 
1039   if (xtty != NULL) {
1040     xtty->tail("print_nmethod");
1041   }
1042 
1043   _nmethod_to_print = NULL;
1044   _nmethod_to_print_ces = NULL;
1045 }
1046 
1047 
1048 // Promote one word from an assembly-time handle to a live embedded oop.
1049 inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
1050   if (handle == NULL ||
1051       // As a special case, IC oops are initialized to 1 or -1.
1052       handle == (jobject) Universe::non_oop_word()) {
1053     *(void**)dest = handle;
1054   } else {
1055     *dest = JNIHandles::resolve_non_null(handle);
1056   }
1057 }
1058 
1059 
1060 // Have to have the same name because it's called by a template
1061 void nmethod::copy_values(GrowableArray<jobject>* array) {
1062   int length = array->length();
1063   assert((address)(oops_begin() + length) <= (address)oops_end(), "oops big enough");
1064   oop* dest = oops_begin();

3143         default:
3144           break;
3145     }
3146   }
3147   return have_one ? "other" : NULL;
3148 }
3149 
3150 // Return a the last scope in (begin..end]
3151 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3152   PcDesc* p = pc_desc_near(begin+1);
3153   if (p != NULL && p->real_pc(this) <= end) {
3154     return new ScopeDesc(this, p);
3155   }
3156   return NULL;
3157 }
3158 
3159 const char* nmethod::nmethod_section_label(address pos) const {
3160   const char* label = NULL;
3161   if (pos == code_begin())                                              label = "[Instructions begin]";
3162   if (pos == entry_point())                                             label = "[Entry Point]";
3163   if (pos == inline_entry_point())                                      label = "[Inline Entry Point]";
3164   if (pos == verified_entry_point())                                    label = "[Verified Entry Point]";
3165   if (pos == verified_inline_entry_point())                             label = "[Verified Inline Entry Point]";
3166   if (pos == verified_inline_ro_entry_point())                          label = "[Verified Inline Entry Point (RO)]";
3167   if (has_method_handle_invokes() && (pos == deopt_mh_handler_begin())) label = "[Deopt MH Handler Code]";
3168   if (pos == consts_begin() && pos != insts_begin())                    label = "[Constants]";
3169   // Check stub_code before checking exception_handler or deopt_handler.
3170   if (pos == this->stub_begin())                                        label = "[Stub Code]";
3171   if (JVMCI_ONLY(_exception_offset >= 0 &&) pos == exception_begin())           label = "[Exception Handler]";
3172   if (JVMCI_ONLY(_deopt_handler_begin != NULL &&) pos == deopt_handler_begin()) label = "[Deopt Handler Code]";
3173   return label;
3174 }
3175 
3176 static int maybe_print_entry_label(outputStream* stream, address pos, address entry, const char* label) {
3177   if (pos == entry) {
3178     stream->bol();
3179     stream->print_cr("%s", label);
3180     return 1;
3181   } else {
3182     return 0;
3183   }
3184 }
3185 
3186 void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels) const {
3187   if (print_section_labels) {
3188     int n = 0;
3189     // Multiple entry points may be at the same position. Print them all.
3190     n += maybe_print_entry_label(stream, block_begin, entry_point(),                    "[Entry Point]");
3191     n += maybe_print_entry_label(stream, block_begin, inline_entry_point(),             "[Inline Entry Point]");
3192     n += maybe_print_entry_label(stream, block_begin, verified_entry_point(),           "[Verified Entry Point]");
3193     n += maybe_print_entry_label(stream, block_begin, verified_inline_entry_point(),    "[Verified Inline Entry Point]");
3194     n += maybe_print_entry_label(stream, block_begin, verified_inline_ro_entry_point(), "[Verified Inline Entry Point (RO)]");
3195     if (n == 0) {
3196       const char* label = nmethod_section_label(block_begin);
3197       if (label != NULL) {
3198         stream->bol();
3199         stream->print_cr("%s", label);





















3200       }
3201     }
3202   }
3203 
3204   if (_nmethod_to_print != this) {
3205     return;
3206   }
3207   Method* m = method();
3208   if (m == NULL || is_osr_method()) {
3209     return;
3210   }
3211 
3212   // Print the name of the method (only once)
3213   address low = MIN4(entry_point(), verified_entry_point(), verified_inline_entry_point(), verified_inline_ro_entry_point());
3214   low = MIN2(low, inline_entry_point());
3215   assert(low != 0, "sanity");
3216   if (block_begin == low) {
3217     stream->print("  # ");
3218     m->print_value_on(stream);
3219     stream->cr();
3220   }
3221 
3222   // Print the arguments for the 3 types of verified entry points
3223   const CompiledEntrySignature* ces = _nmethod_to_print_ces;
3224   const GrowableArray<SigEntry>* sig_cc;
3225   const VMRegPair* regs;
3226   if (block_begin == verified_entry_point()) {
3227     sig_cc = &ces->sig_cc();
3228     regs = ces->regs_cc();
3229   } else if (block_begin == verified_inline_entry_point()) {
3230     sig_cc = &ces->sig();
3231     regs = ces->regs();
3232   } else if (block_begin == verified_inline_ro_entry_point()) {
3233     sig_cc = &ces->sig_cc_ro();
3234     regs = ces->regs_cc_ro();
3235   } else {
3236     return;
3237   }
3238 
3239   bool has_this = !m->is_static();
3240   if (ces->has_inline_recv() && block_begin == verified_entry_point()) {
3241     // <this> argument is scalarized for verified_entry_point()
3242     has_this = false;
3243   }
3244   const char* spname = "sp"; // make arch-specific?
3245   int stack_slot_offset = this->frame_size() * wordSize;
3246   int tab1 = 14, tab2 = 24;
3247   int sig_index = 0;
3248   int arg_index = has_this ? -1 : 0;
3249   bool did_old_sp = false;
3250   for (ExtendedSignature sig = ExtendedSignature(sig_cc, SigEntryFilter()); !sig.at_end(); ++sig) {
3251     bool at_this = (arg_index == -1);
3252     bool at_old_sp = false;
3253     BasicType t = (*sig)._bt;
3254     if (at_this) {
3255       stream->print("  # this: ");
3256     } else {
3257       stream->print("  # parm%d: ", arg_index);
3258     }
3259     stream->move_to(tab1);
3260     VMReg fst = regs[sig_index].first();
3261     VMReg snd = regs[sig_index].second();
3262     if (fst->is_reg()) {
3263       stream->print("%s", fst->name());
3264       if (snd->is_valid())  {
3265         stream->print(":%s", snd->name());
3266       }
3267     } else if (fst->is_stack()) {
3268       int offset = fst->reg2stack() * VMRegImpl::stack_slot_size + stack_slot_offset;
3269       if (offset == stack_slot_offset)  at_old_sp = true;
3270       stream->print("[%s+0x%x]", spname, offset);
3271     } else {
3272       stream->print("reg%d:%d??", (int)(intptr_t)fst, (int)(intptr_t)snd);
3273     }
3274     stream->print(" ");
3275     stream->move_to(tab2);
3276     stream->print("= ");
3277     if (at_this) {
3278       m->method_holder()->print_value_on(stream);
3279     } else {
3280       bool did_name = false;
3281       if (is_reference_type(t)) {
3282         Symbol* name = (*sig)._symbol;
3283         name->print_value_on(stream);
3284         did_name = true;
3285       }
3286       if (!did_name)
3287         stream->print("%s", type2name(t));
3288     }
3289     if (at_old_sp) {
3290       stream->print("  (%s of caller)", spname);
3291       did_old_sp = true;
3292     }
3293     stream->cr();
3294     sig_index += type2size[t];
3295     arg_index += 1;
3296   }
3297   if (!did_old_sp) {
3298     stream->print("  # ");
3299     stream->move_to(tab1);
3300     stream->print("[%s+0x%x]", spname, stack_slot_offset);
3301     stream->print("  (%s of caller)", spname);
3302     stream->cr();
3303   }
3304 }
3305 
3306 // Returns whether this nmethod has code comments.
3307 bool nmethod::has_code_comment(address begin, address end) {
3308   // scopes?
3309   ScopeDesc* sd  = scope_desc_in(begin, end);
3310   if (sd != NULL) return true;
3311 
3312   // relocations?
3313   const char* str = reloc_string_for(begin, end);
3314   if (str != NULL) return true;
3315 
3316   // implicit exceptions?
3317   int cont_offset = ImplicitExceptionTable(this).continuation_offset(begin - code_begin());
3318   if (cont_offset != 0) return true;
3319 
3320   return false;
3321 }
3322 

3406             else
3407               st->print("<UNKNOWN>");
3408             break;
3409           }
3410         case Bytecodes::_getfield:
3411         case Bytecodes::_putfield:
3412         case Bytecodes::_getstatic:
3413         case Bytecodes::_putstatic:
3414           {
3415             Bytecode_field field(methodHandle(thread, sd->method()), sd->bci());
3416             st->print(" ");
3417             if (field.name() != NULL)
3418               field.name()->print_symbol_on(st);
3419             else
3420               st->print("<UNKNOWN>");
3421           }
3422         default:
3423           break;
3424         }
3425       }
3426       st->print(" {reexecute=%d rethrow=%d return_oop=%d return_scalarized=%d}", sd->should_reexecute(), sd->rethrow_exception(), sd->return_oop(), sd->return_scalarized());
3427     }
3428 
3429     // Print all scopes
3430     for (;sd != NULL; sd = sd->sender()) {
3431       st->move_to(column, 6, 0);
3432       st->print("; -");
3433       if (sd->should_reexecute()) {
3434         st->print(" (reexecute)");
3435       }
3436       if (sd->method() == NULL) {
3437         st->print("method is NULL");
3438       } else {
3439         sd->method()->print_short_name(st);
3440       }
3441       int lineno = sd->method()->line_number_from_bci(sd->bci());
3442       if (lineno != -1) {
3443         st->print("@%d (line %d)", sd->bci(), lineno);
3444       } else {
3445         st->print("@%d", sd->bci());
3446       }
< prev index next >