< 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   ObjectMonitor *pending_monitor = thread()->current_pending_monitor();
 126   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();







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


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



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




 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     }
 148     found_first_monitor = true;
 149     result->append(monitor);
 150   }
 151   return result;
 152 }
 153 


 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 
 263 u_char* interpretedVFrame::bcp() const {
 264   return fr().interpreter_frame_bcp();
 265 }
 266 


< prev index next >