< prev index next >

src/hotspot/share/runtime/vframe.cpp

Print this page
rev 57232 : v2.00 -> v2.08 (CR8/v2.08/11-for-jdk14) patches combined into one; merge with jdk-14+25 snapshot; merge with jdk-14+26 snapshot.
rev 57233 : See CR8-to-CR9-changes; merge with 8230876.patch (2019.11.15); merge with jdk-14+25 snapshot; fuzzy merge with jdk-14+26 snapshot.


 105 javaVFrame* vframe::java_sender() const {
 106   vframe* f = sender();
 107   while (f != NULL) {
 108     if (f->is_java_frame()) return javaVFrame::cast(f);
 109     f = f->sender();
 110   }
 111   return NULL;
 112 }
 113 
 114 // ------------- javaVFrame --------------
 115 
 116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
 117   assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
 118          "must be at safepoint or it's a java frame of the current thread");
 119 
 120   GrowableArray<MonitorInfo*>* mons = monitors();
 121   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
 122   if (mons->is_empty()) return result;
 123 
 124   bool found_first_monitor = false;



 125   ObjectMonitorHandle omh;
 126   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor(&omh);
 127   ObjectMonitor *pending_monitor = NULL;
 128   if (waiting_monitor == NULL) {
 129     pending_monitor = thread()->current_pending_monitor(&omh);
 130   }
 131   oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
 132   oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
 133 
 134   for (int index = (mons->length()-1); index >= 0; index--) {
 135     MonitorInfo* monitor = mons->at(index);
 136     if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
 137     oop obj = monitor->owner();
 138     if (obj == NULL) continue; // skip unowned monitor
 139     //
 140     // Skip the monitor that the thread is blocked to enter or waiting on
 141     //
 142     if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
 143       continue;
 144     }


 218           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 219         } else {
 220           Handle obj(THREAD, monitor->owner());
 221           if (obj() != NULL) {
 222             print_locked_object_class_name(st, obj, "eliminated");
 223           }
 224         }
 225         continue;
 226       }
 227       if (monitor->owner() != NULL) {
 228         // the monitor is associated with an object, i.e., it is locked
 229 
 230         const char *lock_state = "locked"; // assume we have the monitor locked
 231         if (!found_first_monitor && frame_count == 0) {
 232           // If this is the first frame and we haven't found an owned
 233           // monitor before, then we need to see if we have completed
 234           // the lock or if we are blocked trying to acquire it. Only
 235           // an inflated monitor that is first on the monitor list in
 236           // the first frame can block us on a monitor enter.
 237           markWord mark = monitor->owner()->mark();


 238           ObjectMonitorHandle omh;
 239           if (mark.has_monitor() &&
 240               ( // we have marked ourself as pending on this monitor
 241                 mark.monitor() == thread()->current_pending_monitor(&omh) ||
 242                 // we are not the owner of this monitor
 243                 !mark.monitor()->is_entered(thread())
 244               )) {
 245             lock_state = "waiting to lock";
 246           }
 247         }
 248         print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
 249 
 250         found_first_monitor = true;
 251       }
 252     }
 253   }
 254 }
 255 
 256 // ------------- interpretedVFrame --------------
 257 




 105 javaVFrame* vframe::java_sender() const {
 106   vframe* f = sender();
 107   while (f != NULL) {
 108     if (f->is_java_frame()) return javaVFrame::cast(f);
 109     f = f->sender();
 110   }
 111   return NULL;
 112 }
 113 
 114 // ------------- javaVFrame --------------
 115 
 116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
 117   assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
 118          "must be at safepoint or it's a java frame of the current thread");
 119 
 120   GrowableArray<MonitorInfo*>* mons = monitors();
 121   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
 122   if (mons->is_empty()) return result;
 123 
 124   bool found_first_monitor = false;
 125   // For all of the javaVFrame::locked_monitors()() call sites, we
 126   // are either at a safepoint or the calling thread is operating
 127   // on itself so this ObjectMonitorHandle is not strictly necessary.
 128   ObjectMonitorHandle omh;
 129   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor(&omh);
 130   ObjectMonitor *pending_monitor = NULL;
 131   if (waiting_monitor == NULL) {
 132     pending_monitor = thread()->current_pending_monitor(&omh);
 133   }
 134   oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
 135   oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
 136 
 137   for (int index = (mons->length()-1); index >= 0; index--) {
 138     MonitorInfo* monitor = mons->at(index);
 139     if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
 140     oop obj = monitor->owner();
 141     if (obj == NULL) continue; // skip unowned monitor
 142     //
 143     // Skip the monitor that the thread is blocked to enter or waiting on
 144     //
 145     if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
 146       continue;
 147     }


 221           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 222         } else {
 223           Handle obj(THREAD, monitor->owner());
 224           if (obj() != NULL) {
 225             print_locked_object_class_name(st, obj, "eliminated");
 226           }
 227         }
 228         continue;
 229       }
 230       if (monitor->owner() != NULL) {
 231         // the monitor is associated with an object, i.e., it is locked
 232 
 233         const char *lock_state = "locked"; // assume we have the monitor locked
 234         if (!found_first_monitor && frame_count == 0) {
 235           // If this is the first frame and we haven't found an owned
 236           // monitor before, then we need to see if we have completed
 237           // the lock or if we are blocked trying to acquire it. Only
 238           // an inflated monitor that is first on the monitor list in
 239           // the first frame can block us on a monitor enter.
 240           markWord mark = monitor->owner()->mark();
 241           // The calling thread is operating on itself so this
 242           // ObjectMonitorHandle is not strictly necessary.
 243           ObjectMonitorHandle omh;
 244           if (mark.has_monitor() &&
 245               ( // we have marked ourself as pending on this monitor
 246                 mark.monitor() == thread()->current_pending_monitor(&omh) ||
 247                 // we are not the owner of this monitor
 248                 !mark.monitor()->is_entered(thread())
 249               )) {
 250             lock_state = "waiting to lock";
 251           }
 252         }
 253         print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
 254 
 255         found_first_monitor = true;
 256       }
 257     }
 258   }
 259 }
 260 
 261 // ------------- interpretedVFrame --------------
 262 


< prev index next >