< prev index next >

src/hotspot/share/runtime/frame.cpp

Print this page

 559 #ifndef PRODUCT
 560   assert(is_interpreted_frame(), "Not an interpreted frame");
 561   jint i;
 562   for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
 563     intptr_t x = *interpreter_frame_local_at(i);
 564     st->print(" - local  [" INTPTR_FORMAT "]", x);
 565     st->fill_to(23);
 566     st->print_cr("; #%d", i);
 567   }
 568   for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
 569     intptr_t x = *interpreter_frame_expression_stack_at(i);
 570     st->print(" - stack  [" INTPTR_FORMAT "]", x);
 571     st->fill_to(23);
 572     st->print_cr("; #%d", i);
 573   }
 574   // locks for synchronization
 575   for (BasicObjectLock* current = interpreter_frame_monitor_end();
 576        current < interpreter_frame_monitor_begin();
 577        current = next_monitor_in_interpreter_frame(current)) {
 578     st->print(" - obj    [%s", current->obj() == nullptr ? "null" : "");
 579     if (current->obj() != nullptr) current->obj()->print_value_on(st);









 580     st->print_cr("]");
 581     st->print(" - lock   [");
 582     current->lock()->print_on(st, current->obj());


 583     st->print_cr("]");
 584   }
 585   // monitor
 586   st->print_cr(" - monitor[" INTPTR_FORMAT "]", p2i(interpreter_frame_monitor_begin()));
 587   // bcp
 588   st->print(" - bcp    [" INTPTR_FORMAT "]", p2i(interpreter_frame_bcp()));
 589   st->fill_to(23);
 590   st->print_cr("; @%d", interpreter_frame_bci());
 591   // locals
 592   st->print_cr(" - locals [" INTPTR_FORMAT "]", p2i(interpreter_frame_local_at(0)));
 593   // method
 594   st->print(" - method [" INTPTR_FORMAT "]", p2i(interpreter_frame_method()));
 595   st->fill_to(23);
 596   st->print("; ");
 597   interpreter_frame_method()->print_name(st);
 598   st->cr();
 599 #endif
 600 }
 601 
 602 // Print whether the frame is in the VM or OS indicating a HotSpot problem.

1070 // check local reg_map for it being a callee-save register or argument
1071 // register, both of which are saved in the local frame.  If not found
1072 // there, it must be an in-stack argument of the caller.
1073 // Note: caller.sp() points to callee-arguments
1074 oop frame::retrieve_receiver(RegisterMap* reg_map) {
1075   frame caller = *this;
1076 
1077   // First consult the ADLC on where it puts parameter 0 for this signature.
1078   VMReg reg = SharedRuntime::name_for_receiver();
1079   oop* oop_adr = caller.oopmapreg_to_oop_location(reg, reg_map);
1080   if (oop_adr == nullptr) {
1081     guarantee(oop_adr != nullptr, "bad register save location");
1082     return nullptr;
1083   }
1084   oop r = *oop_adr;
1085   assert(Universe::heap()->is_in_or_null(r), "bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", p2i(r), p2i(r));
1086   return r;
1087 }
1088 
1089 
1090 BasicLock* frame::get_native_monitor() {
1091   nmethod* nm = (nmethod*)_cb;
1092   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1093          "Should not call this unless it's a native nmethod");
1094   int byte_offset = in_bytes(nm->native_basic_lock_sp_offset());
1095   assert(byte_offset >= 0, "should not see invalid offset");
1096   return (BasicLock*) &sp()[byte_offset / wordSize];
1097 }
1098 
1099 oop frame::get_native_receiver() {
1100   nmethod* nm = (nmethod*)_cb;
1101   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1102          "Should not call this unless it's a native nmethod");
1103   int byte_offset = in_bytes(nm->native_receiver_sp_offset());
1104   assert(byte_offset >= 0, "should not see invalid offset");
1105   oop owner = ((oop*) sp())[byte_offset / wordSize];
1106   assert( Universe::heap()->is_in(owner), "bad receiver" );
1107   return owner;
1108 }
1109 
1110 void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) const {
1111   assert(map != nullptr, "map must be set");
1112   if (map->include_argument_oops()) {
1113     // must collect argument oops, as nobody else is doing it
1114     Thread *thread = Thread::current();
1115     methodHandle m (thread, entry_frame_call_wrapper()->callee_method());
1116     EntryFrameOopFinder finder(this, m->signature(), m->is_static());
1117     finder.arguments_do(f);
1118   }
1119   // Traverse the Handle Block saved in the entry frame

1259     _oops = new (mtThread) GrowableArray<oop*>(100, mtThread);
1260     _narrow_oops = new (mtThread) GrowableArray<narrowOop*>(100, mtThread);
1261     _base = new (mtThread) GrowableArray<derived_base*>(100, mtThread);
1262     _derived = new (mtThread) GrowableArray<derived_pointer*>(100, mtThread);
1263   }
1264   ~FrameValuesOopClosure() {
1265     delete _oops;
1266     delete _narrow_oops;
1267     delete _base;
1268     delete _derived;
1269   }
1270 
1271   virtual void do_oop(oop* p) override { _oops->push(p); }
1272   virtual void do_oop(narrowOop* p) override { _narrow_oops->push(p); }
1273   virtual void do_derived_oop(derived_base* base_loc, derived_pointer* derived_loc) override {
1274     _base->push(base_loc);
1275     _derived->push(derived_loc);
1276   }
1277 
1278   bool is_good(oop* p) {
1279     return *p == nullptr || (dbg_is_safe(*p, -1) && dbg_is_safe((*p)->klass(), -1) && oopDesc::is_oop_or_null(*p));
1280   }
1281   void describe(FrameValues& values, int frame_no) {
1282     for (int i = 0; i < _oops->length(); i++) {
1283       oop* p = _oops->at(i);
1284       values.describe(frame_no, (intptr_t*)p, err_msg("oop%s for #%d", is_good(p) ? "" : " (BAD)", frame_no));
1285     }
1286     for (int i = 0; i < _narrow_oops->length(); i++) {
1287       narrowOop* p = _narrow_oops->at(i);
1288       // we can't check for bad compressed oops, as decoding them might crash
1289       values.describe(frame_no, (intptr_t*)p, err_msg("narrow oop for #%d", frame_no));
1290     }
1291     assert(_base->length() == _derived->length(), "should be the same");
1292     for (int i = 0; i < _base->length(); i++) {
1293       derived_base* base = _base->at(i);
1294       derived_pointer* derived = _derived->at(i);
1295       values.describe(frame_no, (intptr_t*)derived, err_msg("derived pointer (base: " INTPTR_FORMAT ") for #%d", p2i(base), frame_no));
1296     }
1297   }
1298 };
1299 

1312     intptr_t* p = (intptr_t*)_fr->oopmapreg_to_location(reg, _reg_map);
1313     if (p != nullptr && (((intptr_t)p & WordAlignmentMask) == 0)) {
1314       const char* type_name = nullptr;
1315       switch(type) {
1316         case OopMapValue::oop_value:          type_name = "oop";          break;
1317         case OopMapValue::narrowoop_value:    type_name = "narrow oop";   break;
1318         case OopMapValue::callee_saved_value: type_name = "callee-saved"; break;
1319         case OopMapValue::derived_oop_value:  type_name = "derived";      break;
1320         // case OopMapValue::live_value:         type_name = "live";         break;
1321         default: break;
1322       }
1323       if (type_name != nullptr) {
1324         _values.describe(_frame_no, p, err_msg("%s for #%d", type_name, _frame_no));
1325       }
1326     }
1327   }
1328 };
1329 
1330 // callers need a ResourceMark because of name_and_sig_as_C_string() usage,
1331 // RA allocated string is returned to the caller
1332 void frame::describe(FrameValues& values, int frame_no, const RegisterMap* reg_map) {
1333   // boundaries: sp and the 'real' frame pointer
1334   values.describe(-1, sp(), err_msg("sp for #%d", frame_no), 0);





1335   intptr_t* frame_pointer = real_fp(); // Note: may differ from fp()
1336 
1337   // print frame info at the highest boundary
1338   intptr_t* info_address = MAX2(sp(), frame_pointer);
1339 
1340   if (info_address != frame_pointer) {
1341     // print frame_pointer explicitly if not marked by the frame info
1342     values.describe(-1, frame_pointer, err_msg("frame pointer for #%d", frame_no), 1);
1343   }
1344 
1345   if (is_entry_frame() || is_compiled_frame() || is_interpreted_frame() || is_native_frame()) {
1346     // Label values common to most frames
1347     values.describe(-1, unextended_sp(), err_msg("unextended_sp for #%d", frame_no), 0);
1348   }
1349 
1350   if (is_interpreted_frame()) {
1351     Method* m = interpreter_frame_method();
1352     int bci = interpreter_frame_bci();
1353     InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
1354 

1386     OopMapCache::compute_one_oop_map(methodHandle(Thread::current(), m), bci, &mask);
1387     intptr_t* tos = nullptr;
1388     // Report each stack element and mark as owned by this frame
1389     for (int e = 0; e < mask.expression_stack_size(); e++) {
1390       tos = MAX2(tos, interpreter_frame_expression_stack_at(e));
1391       values.describe(frame_no, interpreter_frame_expression_stack_at(e),
1392                       err_msg("stack %d", e), 1);
1393     }
1394     if (tos != nullptr) {
1395       values.describe(-1, tos, err_msg("expression stack for #%d", frame_no), 2);
1396     }
1397 
1398     if (reg_map != nullptr) {
1399       FrameValuesOopClosure oopsFn;
1400       oops_do(&oopsFn, nullptr, &oopsFn, reg_map);
1401       oopsFn.describe(values, frame_no);
1402     }
1403   } else if (is_entry_frame()) {
1404     // For now just label the frame
1405     values.describe(-1, info_address, err_msg("#%d entry frame", frame_no), 2);
1406   } else if (cb()->is_compiled()) {
1407     // For now just label the frame
1408     CompiledMethod* cm = cb()->as_compiled_method();
1409     values.describe(-1, info_address,
1410                     FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for method J %s%s", frame_no,
1411                                        p2i(cm),
1412                                        cm->method()->name_and_sig_as_C_string(),
1413                                        (_deopt_state == is_deoptimized) ?
1414                                        " (deoptimized)" :
1415                                        ((_deopt_state == unknown) ? " (state unknown)" : "")),
1416                     3);
1417 
1418     { // mark arguments (see nmethod::print_nmethod_labels)
1419       Method* m = cm->method();
1420 
1421       int stack_slot_offset = cm->frame_size() * wordSize; // offset, in bytes, to caller sp
1422       int sizeargs = m->size_of_parameters();
1423 
1424       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
1425       VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
1426       {

 559 #ifndef PRODUCT
 560   assert(is_interpreted_frame(), "Not an interpreted frame");
 561   jint i;
 562   for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
 563     intptr_t x = *interpreter_frame_local_at(i);
 564     st->print(" - local  [" INTPTR_FORMAT "]", x);
 565     st->fill_to(23);
 566     st->print_cr("; #%d", i);
 567   }
 568   for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
 569     intptr_t x = *interpreter_frame_expression_stack_at(i);
 570     st->print(" - stack  [" INTPTR_FORMAT "]", x);
 571     st->fill_to(23);
 572     st->print_cr("; #%d", i);
 573   }
 574   // locks for synchronization
 575   for (BasicObjectLock* current = interpreter_frame_monitor_end();
 576        current < interpreter_frame_monitor_begin();
 577        current = next_monitor_in_interpreter_frame(current)) {
 578     st->print(" - obj    [%s", current->obj() == nullptr ? "null" : "");
 579     oop obj = current->obj();
 580     if (obj != nullptr) {
 581       if (!is_heap_frame()) {
 582         obj->print_value_on(st);
 583       } else {
 584         // Might be an invalid oop. We don't have the
 585         // stackChunk to correct it so just print address.
 586         st->print(INTPTR_FORMAT, p2i(obj));
 587       }
 588     }
 589     st->print_cr("]");
 590     st->print(" - lock   [");
 591     if (!is_heap_frame()) {
 592       current->lock()->print_on(st, obj);
 593     }
 594     st->print_cr("]");
 595   }
 596   // monitor
 597   st->print_cr(" - monitor[" INTPTR_FORMAT "]", p2i(interpreter_frame_monitor_begin()));
 598   // bcp
 599   st->print(" - bcp    [" INTPTR_FORMAT "]", p2i(interpreter_frame_bcp()));
 600   st->fill_to(23);
 601   st->print_cr("; @%d", interpreter_frame_bci());
 602   // locals
 603   st->print_cr(" - locals [" INTPTR_FORMAT "]", p2i(interpreter_frame_local_at(0)));
 604   // method
 605   st->print(" - method [" INTPTR_FORMAT "]", p2i(interpreter_frame_method()));
 606   st->fill_to(23);
 607   st->print("; ");
 608   interpreter_frame_method()->print_name(st);
 609   st->cr();
 610 #endif
 611 }
 612 
 613 // Print whether the frame is in the VM or OS indicating a HotSpot problem.

1081 // check local reg_map for it being a callee-save register or argument
1082 // register, both of which are saved in the local frame.  If not found
1083 // there, it must be an in-stack argument of the caller.
1084 // Note: caller.sp() points to callee-arguments
1085 oop frame::retrieve_receiver(RegisterMap* reg_map) {
1086   frame caller = *this;
1087 
1088   // First consult the ADLC on where it puts parameter 0 for this signature.
1089   VMReg reg = SharedRuntime::name_for_receiver();
1090   oop* oop_adr = caller.oopmapreg_to_oop_location(reg, reg_map);
1091   if (oop_adr == nullptr) {
1092     guarantee(oop_adr != nullptr, "bad register save location");
1093     return nullptr;
1094   }
1095   oop r = *oop_adr;
1096   assert(Universe::heap()->is_in_or_null(r), "bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", p2i(r), p2i(r));
1097   return r;
1098 }
1099 
1100 
1101 BasicLock* frame::get_native_monitor() const {
1102   nmethod* nm = (nmethod*)_cb;
1103   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1104          "Should not call this unless it's a native nmethod");
1105   int byte_offset = in_bytes(nm->native_basic_lock_sp_offset());
1106   assert(byte_offset >= 0, "should not see invalid offset");
1107   return (BasicLock*) &sp()[byte_offset / wordSize];
1108 }
1109 
1110 oop frame::get_native_receiver() const {
1111   nmethod* nm = (nmethod*)_cb;
1112   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1113          "Should not call this unless it's a native nmethod");
1114   int byte_offset = in_bytes(nm->native_receiver_sp_offset());
1115   assert(byte_offset >= 0, "should not see invalid offset");
1116   oop owner = ((oop*) sp())[byte_offset / wordSize];
1117   assert( Universe::heap()->is_in(owner), "bad receiver" );
1118   return owner;
1119 }
1120 
1121 void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) const {
1122   assert(map != nullptr, "map must be set");
1123   if (map->include_argument_oops()) {
1124     // must collect argument oops, as nobody else is doing it
1125     Thread *thread = Thread::current();
1126     methodHandle m (thread, entry_frame_call_wrapper()->callee_method());
1127     EntryFrameOopFinder finder(this, m->signature(), m->is_static());
1128     finder.arguments_do(f);
1129   }
1130   // Traverse the Handle Block saved in the entry frame

1270     _oops = new (mtThread) GrowableArray<oop*>(100, mtThread);
1271     _narrow_oops = new (mtThread) GrowableArray<narrowOop*>(100, mtThread);
1272     _base = new (mtThread) GrowableArray<derived_base*>(100, mtThread);
1273     _derived = new (mtThread) GrowableArray<derived_pointer*>(100, mtThread);
1274   }
1275   ~FrameValuesOopClosure() {
1276     delete _oops;
1277     delete _narrow_oops;
1278     delete _base;
1279     delete _derived;
1280   }
1281 
1282   virtual void do_oop(oop* p) override { _oops->push(p); }
1283   virtual void do_oop(narrowOop* p) override { _narrow_oops->push(p); }
1284   virtual void do_derived_oop(derived_base* base_loc, derived_pointer* derived_loc) override {
1285     _base->push(base_loc);
1286     _derived->push(derived_loc);
1287   }
1288 
1289   bool is_good(oop* p) {
1290     return *p == nullptr || (dbg_is_safe(*p, -1) && oopDesc::is_oop_or_null(*p));
1291   }
1292   void describe(FrameValues& values, int frame_no) {
1293     for (int i = 0; i < _oops->length(); i++) {
1294       oop* p = _oops->at(i);
1295       values.describe(frame_no, (intptr_t*)p, err_msg("oop%s for #%d", is_good(p) ? "" : " (BAD)", frame_no));
1296     }
1297     for (int i = 0; i < _narrow_oops->length(); i++) {
1298       narrowOop* p = _narrow_oops->at(i);
1299       // we can't check for bad compressed oops, as decoding them might crash
1300       values.describe(frame_no, (intptr_t*)p, err_msg("narrow oop for #%d", frame_no));
1301     }
1302     assert(_base->length() == _derived->length(), "should be the same");
1303     for (int i = 0; i < _base->length(); i++) {
1304       derived_base* base = _base->at(i);
1305       derived_pointer* derived = _derived->at(i);
1306       values.describe(frame_no, (intptr_t*)derived, err_msg("derived pointer (base: " INTPTR_FORMAT ") for #%d", p2i(base), frame_no));
1307     }
1308   }
1309 };
1310 

1323     intptr_t* p = (intptr_t*)_fr->oopmapreg_to_location(reg, _reg_map);
1324     if (p != nullptr && (((intptr_t)p & WordAlignmentMask) == 0)) {
1325       const char* type_name = nullptr;
1326       switch(type) {
1327         case OopMapValue::oop_value:          type_name = "oop";          break;
1328         case OopMapValue::narrowoop_value:    type_name = "narrow oop";   break;
1329         case OopMapValue::callee_saved_value: type_name = "callee-saved"; break;
1330         case OopMapValue::derived_oop_value:  type_name = "derived";      break;
1331         // case OopMapValue::live_value:         type_name = "live";         break;
1332         default: break;
1333       }
1334       if (type_name != nullptr) {
1335         _values.describe(_frame_no, p, err_msg("%s for #%d", type_name, _frame_no));
1336       }
1337     }
1338   }
1339 };
1340 
1341 // callers need a ResourceMark because of name_and_sig_as_C_string() usage,
1342 // RA allocated string is returned to the caller
1343 void frame::describe(FrameValues& values, int frame_no, const RegisterMap* reg_map, bool top) {
1344   // boundaries: sp and the 'real' frame pointer
1345   values.describe(-1, sp(), err_msg("sp for #%d", frame_no), 0);
1346   if (top) {
1347     values.describe(-1, sp() - 1, err_msg("sp[-1] for #%d", frame_no), 0);
1348     values.describe(-1, sp() - 2, err_msg("sp[-2] for #%d", frame_no), 0);
1349   }
1350 
1351   intptr_t* frame_pointer = real_fp(); // Note: may differ from fp()
1352 
1353   // print frame info at the highest boundary
1354   intptr_t* info_address = MAX2(sp(), frame_pointer);
1355 
1356   if (info_address != frame_pointer) {
1357     // print frame_pointer explicitly if not marked by the frame info
1358     values.describe(-1, frame_pointer, err_msg("frame pointer for #%d", frame_no), 1);
1359   }
1360 
1361   if (is_entry_frame() || is_compiled_frame() || is_interpreted_frame() || is_native_frame()) {
1362     // Label values common to most frames
1363     values.describe(-1, unextended_sp(), err_msg("unextended_sp for #%d", frame_no), 0);
1364   }
1365 
1366   if (is_interpreted_frame()) {
1367     Method* m = interpreter_frame_method();
1368     int bci = interpreter_frame_bci();
1369     InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
1370 

1402     OopMapCache::compute_one_oop_map(methodHandle(Thread::current(), m), bci, &mask);
1403     intptr_t* tos = nullptr;
1404     // Report each stack element and mark as owned by this frame
1405     for (int e = 0; e < mask.expression_stack_size(); e++) {
1406       tos = MAX2(tos, interpreter_frame_expression_stack_at(e));
1407       values.describe(frame_no, interpreter_frame_expression_stack_at(e),
1408                       err_msg("stack %d", e), 1);
1409     }
1410     if (tos != nullptr) {
1411       values.describe(-1, tos, err_msg("expression stack for #%d", frame_no), 2);
1412     }
1413 
1414     if (reg_map != nullptr) {
1415       FrameValuesOopClosure oopsFn;
1416       oops_do(&oopsFn, nullptr, &oopsFn, reg_map);
1417       oopsFn.describe(values, frame_no);
1418     }
1419   } else if (is_entry_frame()) {
1420     // For now just label the frame
1421     values.describe(-1, info_address, err_msg("#%d entry frame", frame_no), 2);
1422   } else if (cb() && cb()->is_compiled()) {
1423     // For now just label the frame
1424     CompiledMethod* cm = cb()->as_compiled_method();
1425     values.describe(-1, info_address,
1426                     FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for method J %s%s", frame_no,
1427                                        p2i(cm),
1428                                        cm->method()->name_and_sig_as_C_string(),
1429                                        (_deopt_state == is_deoptimized) ?
1430                                        " (deoptimized)" :
1431                                        ((_deopt_state == unknown) ? " (state unknown)" : "")),
1432                     3);
1433 
1434     { // mark arguments (see nmethod::print_nmethod_labels)
1435       Method* m = cm->method();
1436 
1437       int stack_slot_offset = cm->frame_size() * wordSize; // offset, in bytes, to caller sp
1438       int sizeargs = m->size_of_parameters();
1439 
1440       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
1441       VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
1442       {
< prev index next >