< prev index next >

src/hotspot/share/runtime/vframe.cpp

Print this page
rev 59866 : 8249192: MonitorInfo stores raw oops across safepoints
Summary: Change raw oops in MonitorInfo to Handles and update Resource/HandleMarks.
Reviewed-by: sspitsyn, dholmes, coleenp, dcubed


 148     result->append(monitor);
 149   }
 150   return result;
 151 }
 152 
 153 void javaVFrame::print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) {
 154   if (obj.not_null()) {
 155     st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, p2i(obj()));
 156     if (obj->klass() == SystemDictionary::Class_klass()) {
 157       st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj()));
 158     } else {
 159       Klass* k = obj->klass();
 160       st->print_cr("(a %s)", k->external_name());
 161     }
 162   }
 163 }
 164 
 165 void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
 166   Thread* THREAD = Thread::current();
 167   ResourceMark rm(THREAD);

 168 
 169   // If this is the first frame and it is java.lang.Object.wait(...)
 170   // then print out the receiver. Locals are not always available,
 171   // e.g., compiled native frames have no scope so there are no locals.
 172   if (frame_count == 0) {
 173     if (method()->name() == vmSymbols::wait_name() &&
 174         method()->method_holder()->name() == vmSymbols::java_lang_Object()) {
 175       const char *wait_state = "waiting on"; // assume we are waiting
 176       // If earlier in the output we reported java.lang.Thread.State ==
 177       // "WAITING (on object monitor)" and now we report "waiting on", then
 178       // we are still waiting for notification or timeout. Otherwise if
 179       // we earlier reported java.lang.Thread.State == "BLOCKED (on object
 180       // monitor)", then we are actually waiting to re-lock the monitor.
 181       StackValueCollection* locs = locals();
 182       if (!locs->is_empty()) {
 183         StackValue* sv = locs->at(0);
 184         if (sv->type() == T_OBJECT) {
 185           Handle o = locs->at(0)->get_obj();
 186           if (java_lang_Thread::get_thread_status(thread()->threadObj()) ==
 187                                 java_lang_Thread::BLOCKED_ON_MONITOR_ENTER) {


 430   for (int i = 0; i < max_locals; i++) {
 431     // Find stack location
 432     intptr_t *addr = locals_addr_at(i);
 433 
 434     // Depending on oop/int put it in the right package
 435     const StackValue* const sv = values->at(i);
 436     assert(sv != NULL, "sanity check");
 437     if (sv->type() == T_OBJECT) {
 438       *(oop *) addr = (sv->get_obj())();
 439     } else {                   // integer
 440       *addr = sv->get_int();
 441     }
 442   }
 443 }
 444 
 445 // ------------- cChunk --------------
 446 
 447 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
 448 : externalVFrame(fr, reg_map, thread) {}
 449 















 450 #ifdef ASSERT
 451 void vframeStreamCommon::found_bad_method_frame() const {
 452   // 6379830 Cut point for an assertion that occasionally fires when
 453   // we are using the performance analyzer.
 454   // Disable this assert when testing the analyzer with fastdebug.
 455   // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
 456   fatal("invalid bci or invalid scope desc");
 457 }
 458 #endif
 459 
 460 // top-frame will be skipped
 461 vframeStream::vframeStream(JavaThread* thread, frame top_frame,
 462   bool stop_at_java_call_stub) : vframeStreamCommon(thread) {
 463   _stop_at_java_call_stub = stop_at_java_call_stub;
 464 
 465   // skip top frame, as it may not be at safepoint
 466   _prev_frame = top_frame;
 467   _frame  = top_frame.sender(&_reg_map);
 468   while (!fill_from_frame()) {
 469     _prev_frame = _frame;


 595 }
 596 
 597 void entryVFrame::print() {
 598   vframe::print();
 599   tty->print_cr("C Chunk inbetween Java");
 600   tty->print_cr("C     link " INTPTR_FORMAT, p2i(_fr.link()));
 601 }
 602 
 603 
 604 // ------------- javaVFrame --------------
 605 
 606 static void print_stack_values(const char* title, StackValueCollection* values) {
 607   if (values->is_empty()) return;
 608   tty->print_cr("\t%s:", title);
 609   values->print();
 610 }
 611 
 612 
 613 void javaVFrame::print() {
 614   ResourceMark rm;


 615   vframe::print();
 616   tty->print("\t");
 617   method()->print_value();
 618   tty->cr();
 619   tty->print_cr("\tbci:    %d", bci());
 620 
 621   print_stack_values("locals",      locals());
 622   print_stack_values("expressions", expressions());
 623 
 624   GrowableArray<MonitorInfo*>* list = monitors();
 625   if (list->is_empty()) return;
 626   tty->print_cr("\tmonitor list:");
 627   for (int index = (list->length()-1); index >= 0; index--) {
 628     MonitorInfo* monitor = list->at(index);
 629     tty->print("\t  obj\t");
 630     if (monitor->owner_is_scalar_replaced()) {
 631       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 632       tty->print("( is scalar replaced %s)", k->external_name());
 633     } else if (monitor->owner() == NULL) {
 634       tty->print("( null )");




 148     result->append(monitor);
 149   }
 150   return result;
 151 }
 152 
 153 void javaVFrame::print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) {
 154   if (obj.not_null()) {
 155     st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, p2i(obj()));
 156     if (obj->klass() == SystemDictionary::Class_klass()) {
 157       st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj()));
 158     } else {
 159       Klass* k = obj->klass();
 160       st->print_cr("(a %s)", k->external_name());
 161     }
 162   }
 163 }
 164 
 165 void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
 166   Thread* THREAD = Thread::current();
 167   ResourceMark rm(THREAD);
 168   HandleMark hm(THREAD);
 169 
 170   // If this is the first frame and it is java.lang.Object.wait(...)
 171   // then print out the receiver. Locals are not always available,
 172   // e.g., compiled native frames have no scope so there are no locals.
 173   if (frame_count == 0) {
 174     if (method()->name() == vmSymbols::wait_name() &&
 175         method()->method_holder()->name() == vmSymbols::java_lang_Object()) {
 176       const char *wait_state = "waiting on"; // assume we are waiting
 177       // If earlier in the output we reported java.lang.Thread.State ==
 178       // "WAITING (on object monitor)" and now we report "waiting on", then
 179       // we are still waiting for notification or timeout. Otherwise if
 180       // we earlier reported java.lang.Thread.State == "BLOCKED (on object
 181       // monitor)", then we are actually waiting to re-lock the monitor.
 182       StackValueCollection* locs = locals();
 183       if (!locs->is_empty()) {
 184         StackValue* sv = locs->at(0);
 185         if (sv->type() == T_OBJECT) {
 186           Handle o = locs->at(0)->get_obj();
 187           if (java_lang_Thread::get_thread_status(thread()->threadObj()) ==
 188                                 java_lang_Thread::BLOCKED_ON_MONITOR_ENTER) {


 431   for (int i = 0; i < max_locals; i++) {
 432     // Find stack location
 433     intptr_t *addr = locals_addr_at(i);
 434 
 435     // Depending on oop/int put it in the right package
 436     const StackValue* const sv = values->at(i);
 437     assert(sv != NULL, "sanity check");
 438     if (sv->type() == T_OBJECT) {
 439       *(oop *) addr = (sv->get_obj())();
 440     } else {                   // integer
 441       *addr = sv->get_int();
 442     }
 443   }
 444 }
 445 
 446 // ------------- cChunk --------------
 447 
 448 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
 449 : externalVFrame(fr, reg_map, thread) {}
 450 
 451 MonitorInfo::MonitorInfo(oop owner, BasicLock* lock, bool eliminated, bool owner_is_scalar_replaced) {
 452   Thread* thread = Thread::current();
 453   if (!owner_is_scalar_replaced) {
 454     _owner = Handle(thread, owner);
 455     _owner_klass = Handle();
 456   } else {
 457     assert(eliminated, "monitor should be eliminated for scalar replaced object");
 458     _owner = Handle();
 459     _owner_klass = Handle(thread, owner);
 460   }
 461   _lock = lock;
 462   _eliminated = eliminated;
 463   _owner_is_scalar_replaced = owner_is_scalar_replaced;
 464 }
 465 
 466 #ifdef ASSERT
 467 void vframeStreamCommon::found_bad_method_frame() const {
 468   // 6379830 Cut point for an assertion that occasionally fires when
 469   // we are using the performance analyzer.
 470   // Disable this assert when testing the analyzer with fastdebug.
 471   // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
 472   fatal("invalid bci or invalid scope desc");
 473 }
 474 #endif
 475 
 476 // top-frame will be skipped
 477 vframeStream::vframeStream(JavaThread* thread, frame top_frame,
 478   bool stop_at_java_call_stub) : vframeStreamCommon(thread) {
 479   _stop_at_java_call_stub = stop_at_java_call_stub;
 480 
 481   // skip top frame, as it may not be at safepoint
 482   _prev_frame = top_frame;
 483   _frame  = top_frame.sender(&_reg_map);
 484   while (!fill_from_frame()) {
 485     _prev_frame = _frame;


 611 }
 612 
 613 void entryVFrame::print() {
 614   vframe::print();
 615   tty->print_cr("C Chunk inbetween Java");
 616   tty->print_cr("C     link " INTPTR_FORMAT, p2i(_fr.link()));
 617 }
 618 
 619 
 620 // ------------- javaVFrame --------------
 621 
 622 static void print_stack_values(const char* title, StackValueCollection* values) {
 623   if (values->is_empty()) return;
 624   tty->print_cr("\t%s:", title);
 625   values->print();
 626 }
 627 
 628 
 629 void javaVFrame::print() {
 630   ResourceMark rm;
 631   HandleMark hm;
 632 
 633   vframe::print();
 634   tty->print("\t");
 635   method()->print_value();
 636   tty->cr();
 637   tty->print_cr("\tbci:    %d", bci());
 638 
 639   print_stack_values("locals",      locals());
 640   print_stack_values("expressions", expressions());
 641 
 642   GrowableArray<MonitorInfo*>* list = monitors();
 643   if (list->is_empty()) return;
 644   tty->print_cr("\tmonitor list:");
 645   for (int index = (list->length()-1); index >= 0; index--) {
 646     MonitorInfo* monitor = list->at(index);
 647     tty->print("\t  obj\t");
 648     if (monitor->owner_is_scalar_replaced()) {
 649       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
 650       tty->print("( is scalar replaced %s)", k->external_name());
 651     } else if (monitor->owner() == NULL) {
 652       tty->print("( null )");


< prev index next >