< prev index next >

src/hotspot/share/runtime/vframe.cpp

Print this page

 27 #include "classfile/javaThreadStatus.hpp"
 28 #include "classfile/vmClasses.hpp"
 29 #include "classfile/vmSymbols.hpp"
 30 #include "code/codeCache.hpp"
 31 #include "code/debugInfoRec.hpp"
 32 #include "code/nmethod.hpp"
 33 #include "code/pcDesc.hpp"
 34 #include "code/scopeDesc.hpp"
 35 #include "interpreter/interpreter.hpp"
 36 #include "interpreter/oopMapCache.hpp"
 37 #include "memory/resourceArea.hpp"
 38 #include "oops/instanceKlass.hpp"
 39 #include "oops/method.inline.hpp"
 40 #include "oops/oop.inline.hpp"
 41 #include "oops/stackChunkOop.hpp"
 42 #include "prims/jvmtiExport.hpp"
 43 #include "runtime/frame.inline.hpp"
 44 #include "runtime/globals.hpp"
 45 #include "runtime/handles.inline.hpp"
 46 #include "runtime/javaThread.inline.hpp"

 47 #include "runtime/objectMonitor.hpp"
 48 #include "runtime/objectMonitor.inline.hpp"
 49 #include "runtime/osThread.hpp"
 50 #include "runtime/signature.hpp"
 51 #include "runtime/stackFrameStream.inline.hpp"
 52 #include "runtime/stubRoutines.hpp"
 53 #include "runtime/synchronizer.hpp"
 54 #include "runtime/vframe.inline.hpp"
 55 #include "runtime/vframeArray.hpp"
 56 #include "runtime/vframe_hp.hpp"
 57 
 58 vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
 59 : _reg_map(reg_map), _thread(thread),
 60   _chunk(Thread::current(), reg_map->stack_chunk()()) {
 61   assert(fr != NULL, "must have frame");
 62   _fr = *fr;
 63 }
 64 
 65 vframe::vframe(const frame* fr, JavaThread* thread)
 66 : _reg_map(thread,

255           Handle obj(current, monitor->owner());
256           if (obj() != NULL) {
257             print_locked_object_class_name(st, obj, "eliminated");
258           }
259         }
260         continue;
261       }
262       if (monitor->owner() != NULL) {
263         // the monitor is associated with an object, i.e., it is locked
264 
265         const char *lock_state = "locked"; // assume we have the monitor locked
266         if (!found_first_monitor && frame_count == 0) {
267           // If this is the first frame and we haven't found an owned
268           // monitor before, then we need to see if we have completed
269           // the lock or if we are blocked trying to acquire it. Only
270           // an inflated monitor that is first on the monitor list in
271           // the first frame can block us on a monitor enter.
272           markWord mark = monitor->owner()->mark();
273           // The first stage of async deflation does not affect any field
274           // used by this comparison so the ObjectMonitor* is usable here.
275           if (mark.has_monitor() &&
276               ( // we have marked ourself as pending on this monitor
277                 mark.monitor() == thread()->current_pending_monitor() ||
278                 // we are not the owner of this monitor
279                 !mark.monitor()->is_entered(thread())
280               )) {
281             lock_state = "waiting to lock";




282           }
283         }
284         print_locked_object_class_name(st, Handle(current, monitor->owner()), lock_state);
285 
286         found_first_monitor = true;
287       }
288     }
289   }
290 }
291 
292 // ------------- interpretedVFrame --------------
293 
294 u_char* interpretedVFrame::bcp() const {
295   return stack_chunk() == NULL ? fr().interpreter_frame_bcp() : stack_chunk()->interpreter_frame_bcp(fr());
296 }
297 
298 void interpretedVFrame::set_bcp(u_char* bcp) {
299   assert(stack_chunk() == NULL, "Not supported for heap frames"); // unsupported for now because seems to be unused
300   fr().interpreter_frame_set_bcp(bcp);
301 }
302 
303 intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
304   assert(stack_chunk() == NULL, "Not supported for heap frames"); // unsupported for now because seems to be unused
305   assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
306   return fr().interpreter_frame_local_at(offset);
307 }
308 
309 
310 GrowableArray<MonitorInfo*>* interpretedVFrame::monitors() const {
311   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(5);
312   if (stack_chunk() == NULL) { // no monitors in continuations
313     for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin()));
314         current >= fr().interpreter_frame_monitor_end();
315         current = fr().previous_monitor_in_interpreter_frame(current)) {
316       result->push(new MonitorInfo(current->obj(), current->lock(), false, false));
317     }
318   }
319   return result;
320 }
321 
322 int interpretedVFrame::bci() const {
323   return method()->bci_from(bcp());
324 }
325 
326 Method* interpretedVFrame::method() const {
327   return stack_chunk() == NULL ? fr().interpreter_frame_method() : stack_chunk()->interpreter_frame_method(fr());
328 }
329 
330 static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask,
331                                                    int index,
332                                                    const intptr_t* const addr,
333                                                    stackChunkOop chunk) {
334 
335   assert(index >= 0 &&
336          index < oop_mask.number_of_entries(), "invariant");

489   for (int i = 0; i < max_locals; i++) {
490     // Find stack location
491     intptr_t *addr = locals_addr_at(i);
492 
493     // Depending on oop/int put it in the right package
494     const StackValue* const sv = values->at(i);
495     assert(sv != NULL, "sanity check");
496     if (sv->type() == T_OBJECT) {
497       *(oop *) addr = (sv->get_obj())();
498     } else {                   // integer
499       *addr = sv->get_int();
500     }
501   }
502 }
503 
504 // ------------- cChunk --------------
505 
506 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
507 : externalVFrame(fr, reg_map, thread) {}
508 
509 MonitorInfo::MonitorInfo(oop owner, BasicLock* lock, bool eliminated, bool owner_is_scalar_replaced) {
510   Thread* thread = Thread::current();
511   if (!owner_is_scalar_replaced) {
512     _owner = Handle(thread, owner);
513     _owner_klass = Handle();
514   } else {
515     assert(eliminated, "monitor should be eliminated for scalar replaced object");
516     _owner = Handle();
517     _owner_klass = Handle(thread, owner);
518   }
519   _lock = lock;
520   _eliminated = eliminated;
521   _owner_is_scalar_replaced = owner_is_scalar_replaced;
522 }
523 
524 #ifdef ASSERT
525 void vframeStreamCommon::found_bad_method_frame() const {
526   // 6379830 Cut point for an assertion that occasionally fires when
527   // we are using the performance analyzer.
528   // Disable this assert when testing the analyzer with fastdebug.
529   // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
530   fatal("invalid bci or invalid scope desc");
531 }
532 #endif
533 
534 // top-frame will be skipped
535 vframeStream::vframeStream(JavaThread* thread, frame top_frame,
536                           bool stop_at_java_call_stub) :
537     vframeStreamCommon(RegisterMap(thread,
538                                    RegisterMap::UpdateMap::include,
539                                    RegisterMap::ProcessFrames::include,

726   for (int index = (list->length()-1); index >= 0; index--) {
727     MonitorInfo* monitor = list->at(index);
728     tty->print("\t  obj\t");
729     if (monitor->owner_is_scalar_replaced()) {
730       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
731       tty->print("( is scalar replaced %s)", k->external_name());
732     } else if (monitor->owner() == NULL) {
733       tty->print("( null )");
734     } else {
735       monitor->owner()->print_value();
736       tty->print("(owner=" INTPTR_FORMAT ")", p2i(monitor->owner()));
737     }
738     if (monitor->eliminated()) {
739       if(is_compiled_frame()) {
740         tty->print(" ( lock is eliminated in compiled frame )");
741       } else {
742         tty->print(" ( lock is eliminated, frame not compiled )");
743       }
744     }
745     tty->cr();
746     tty->print("\t  ");
747     monitor->lock()->print_on(tty, monitor->owner());
748     tty->cr();
749   }
750 }
751 
752 
753 void javaVFrame::print_value() const {
754   Method*    m = method();
755   InstanceKlass*     k = m->method_holder();
756   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
757                 p2i(_fr.sp()),  p2i(_fr.unextended_sp()), p2i(_fr.fp()), p2i(_fr.pc()));
758   tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
759 
760   if (!m->is_native()) {
761     Symbol*  source_name = k->source_file_name();
762     int        line_number = m->line_number_from_bci(bci());
763     if (source_name != NULL && (line_number != -1)) {
764       tty->print("(%s:%d)", source_name->as_C_string(), line_number);
765     }
766   } else {
767     tty->print("(Native Method)");
768   }

 27 #include "classfile/javaThreadStatus.hpp"
 28 #include "classfile/vmClasses.hpp"
 29 #include "classfile/vmSymbols.hpp"
 30 #include "code/codeCache.hpp"
 31 #include "code/debugInfoRec.hpp"
 32 #include "code/nmethod.hpp"
 33 #include "code/pcDesc.hpp"
 34 #include "code/scopeDesc.hpp"
 35 #include "interpreter/interpreter.hpp"
 36 #include "interpreter/oopMapCache.hpp"
 37 #include "memory/resourceArea.hpp"
 38 #include "oops/instanceKlass.hpp"
 39 #include "oops/method.inline.hpp"
 40 #include "oops/oop.inline.hpp"
 41 #include "oops/stackChunkOop.hpp"
 42 #include "prims/jvmtiExport.hpp"
 43 #include "runtime/frame.inline.hpp"
 44 #include "runtime/globals.hpp"
 45 #include "runtime/handles.inline.hpp"
 46 #include "runtime/javaThread.inline.hpp"
 47 #include "runtime/lockStack.inline.hpp"
 48 #include "runtime/objectMonitor.hpp"
 49 #include "runtime/objectMonitor.inline.hpp"
 50 #include "runtime/osThread.hpp"
 51 #include "runtime/signature.hpp"
 52 #include "runtime/stackFrameStream.inline.hpp"
 53 #include "runtime/stubRoutines.hpp"
 54 #include "runtime/synchronizer.hpp"
 55 #include "runtime/vframe.inline.hpp"
 56 #include "runtime/vframeArray.hpp"
 57 #include "runtime/vframe_hp.hpp"
 58 
 59 vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
 60 : _reg_map(reg_map), _thread(thread),
 61   _chunk(Thread::current(), reg_map->stack_chunk()()) {
 62   assert(fr != NULL, "must have frame");
 63   _fr = *fr;
 64 }
 65 
 66 vframe::vframe(const frame* fr, JavaThread* thread)
 67 : _reg_map(thread,

256           Handle obj(current, monitor->owner());
257           if (obj() != NULL) {
258             print_locked_object_class_name(st, obj, "eliminated");
259           }
260         }
261         continue;
262       }
263       if (monitor->owner() != NULL) {
264         // the monitor is associated with an object, i.e., it is locked
265 
266         const char *lock_state = "locked"; // assume we have the monitor locked
267         if (!found_first_monitor && frame_count == 0) {
268           // If this is the first frame and we haven't found an owned
269           // monitor before, then we need to see if we have completed
270           // the lock or if we are blocked trying to acquire it. Only
271           // an inflated monitor that is first on the monitor list in
272           // the first frame can block us on a monitor enter.
273           markWord mark = monitor->owner()->mark();
274           // The first stage of async deflation does not affect any field
275           // used by this comparison so the ObjectMonitor* is usable here.
276           if (mark.has_monitor()) {
277             if (mark.monitor()->is_owner_anonymous()) {
278               if (!thread()->lock_stack().contains(monitor->owner())) {
279                 lock_state = "waiting to lock";
280               }
281             } else if (// we have marked ourself as pending on this monitor
282                     mark.monitor() == thread()->current_pending_monitor() ||
283                     // we are not the owner of this monitor
284                     !mark.monitor()->is_entered(thread())) {
285               lock_state = "waiting to lock";
286             }
287           }
288         }
289         print_locked_object_class_name(st, Handle(current, monitor->owner()), lock_state);
290 
291         found_first_monitor = true;
292       }
293     }
294   }
295 }
296 
297 // ------------- interpretedVFrame --------------
298 
299 u_char* interpretedVFrame::bcp() const {
300   return stack_chunk() == NULL ? fr().interpreter_frame_bcp() : stack_chunk()->interpreter_frame_bcp(fr());
301 }
302 
303 void interpretedVFrame::set_bcp(u_char* bcp) {
304   assert(stack_chunk() == NULL, "Not supported for heap frames"); // unsupported for now because seems to be unused
305   fr().interpreter_frame_set_bcp(bcp);
306 }
307 
308 intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
309   assert(stack_chunk() == NULL, "Not supported for heap frames"); // unsupported for now because seems to be unused
310   assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
311   return fr().interpreter_frame_local_at(offset);
312 }
313 
314 
315 GrowableArray<MonitorInfo*>* interpretedVFrame::monitors() const {
316   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(5);
317   if (stack_chunk() == NULL) { // no monitors in continuations
318     for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin()));
319         current >= fr().interpreter_frame_monitor_end();
320         current = fr().previous_monitor_in_interpreter_frame(current)) {
321       result->push(new MonitorInfo(current->obj(), false, false));
322     }
323   }
324   return result;
325 }
326 
327 int interpretedVFrame::bci() const {
328   return method()->bci_from(bcp());
329 }
330 
331 Method* interpretedVFrame::method() const {
332   return stack_chunk() == NULL ? fr().interpreter_frame_method() : stack_chunk()->interpreter_frame_method(fr());
333 }
334 
335 static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask,
336                                                    int index,
337                                                    const intptr_t* const addr,
338                                                    stackChunkOop chunk) {
339 
340   assert(index >= 0 &&
341          index < oop_mask.number_of_entries(), "invariant");

494   for (int i = 0; i < max_locals; i++) {
495     // Find stack location
496     intptr_t *addr = locals_addr_at(i);
497 
498     // Depending on oop/int put it in the right package
499     const StackValue* const sv = values->at(i);
500     assert(sv != NULL, "sanity check");
501     if (sv->type() == T_OBJECT) {
502       *(oop *) addr = (sv->get_obj())();
503     } else {                   // integer
504       *addr = sv->get_int();
505     }
506   }
507 }
508 
509 // ------------- cChunk --------------
510 
511 entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
512 : externalVFrame(fr, reg_map, thread) {}
513 
514 MonitorInfo::MonitorInfo(oop owner, bool eliminated, bool owner_is_scalar_replaced) {
515   Thread* thread = Thread::current();
516   if (!owner_is_scalar_replaced) {
517     _owner = Handle(thread, owner);
518     _owner_klass = Handle();
519   } else {
520     assert(eliminated, "monitor should be eliminated for scalar replaced object");
521     _owner = Handle();
522     _owner_klass = Handle(thread, owner);
523   }

524   _eliminated = eliminated;
525   _owner_is_scalar_replaced = owner_is_scalar_replaced;
526 }
527 
528 #ifdef ASSERT
529 void vframeStreamCommon::found_bad_method_frame() const {
530   // 6379830 Cut point for an assertion that occasionally fires when
531   // we are using the performance analyzer.
532   // Disable this assert when testing the analyzer with fastdebug.
533   // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
534   fatal("invalid bci or invalid scope desc");
535 }
536 #endif
537 
538 // top-frame will be skipped
539 vframeStream::vframeStream(JavaThread* thread, frame top_frame,
540                           bool stop_at_java_call_stub) :
541     vframeStreamCommon(RegisterMap(thread,
542                                    RegisterMap::UpdateMap::include,
543                                    RegisterMap::ProcessFrames::include,

730   for (int index = (list->length()-1); index >= 0; index--) {
731     MonitorInfo* monitor = list->at(index);
732     tty->print("\t  obj\t");
733     if (monitor->owner_is_scalar_replaced()) {
734       Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
735       tty->print("( is scalar replaced %s)", k->external_name());
736     } else if (monitor->owner() == NULL) {
737       tty->print("( null )");
738     } else {
739       monitor->owner()->print_value();
740       tty->print("(owner=" INTPTR_FORMAT ")", p2i(monitor->owner()));
741     }
742     if (monitor->eliminated()) {
743       if(is_compiled_frame()) {
744         tty->print(" ( lock is eliminated in compiled frame )");
745       } else {
746         tty->print(" ( lock is eliminated, frame not compiled )");
747       }
748     }
749     tty->cr();



750   }
751 }
752 
753 
754 void javaVFrame::print_value() const {
755   Method*    m = method();
756   InstanceKlass*     k = m->method_holder();
757   tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
758                 p2i(_fr.sp()),  p2i(_fr.unextended_sp()), p2i(_fr.fp()), p2i(_fr.pc()));
759   tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
760 
761   if (!m->is_native()) {
762     Symbol*  source_name = k->source_file_name();
763     int        line_number = m->line_number_from_bci(bci());
764     if (source_name != NULL && (line_number != -1)) {
765       tty->print("(%s:%d)", source_name->as_C_string(), line_number);
766     }
767   } else {
768     tty->print("(Native Method)");
769   }
< prev index next >