< prev index next >

src/hotspot/share/services/threadService.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.

@@ -206,20 +206,23 @@
 // FIXME: JVMTI should call this function
 Handle ThreadService::get_current_contended_monitor(JavaThread* thread) {
   assert(thread != NULL, "should be non-NULL");
   debug_only(Thread::check_for_dangling_thread_pointer(thread);)
 
+  // This function can be called on a target JavaThread that is not
+  // the caller and we are not at a safepoint. This ObjectMonitorHandle
+  // keeps the ObjectMonitor from being async deflated so the object
+  // reference we fetch remains non-NULL.
   ObjectMonitorHandle omh;
   ObjectMonitor *wait_obj = thread->current_waiting_monitor(&omh);
 
   oop obj = NULL;
   if (wait_obj != NULL) {
     // thread is doing an Object.wait() call
     obj = (oop) wait_obj->object();
     assert(obj != NULL, "Object.wait() should have an object");
   } else {
-    ObjectMonitorHandle omh;
     ObjectMonitor *enter_obj = thread->current_pending_monitor(&omh);
     if (enter_obj != NULL) {
       // thread is trying to enter() an ObjectMonitor.
       obj = (oop) enter_obj->object();
       assert(obj != NULL, "ObjectMonitor should have an associated object!");

@@ -362,10 +365,12 @@
 DeadlockCycle* ThreadService::find_deadlocks_at_safepoint(ThreadsList * t_list, bool concurrent_locks) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 
   // This code was modified from the original Threads::find_deadlocks code.
   int globalDfn = 0, thisDfn;
+  // This code is called at a safepoint so this ObjectMonitorHandle
+  // is not strictly necessary.
   ObjectMonitorHandle omh;
   ObjectMonitor* waitingToLockMonitor = NULL;
   JvmtiRawMonitor* waitingToLockRawMonitor = NULL;
   oop waitingToLockBlocker = NULL;
   bool blocked_on_monitor = false;

@@ -983,10 +988,12 @@
   JvmtiRawMonitor* waitingToLockRawMonitor;
   oop waitingToLockBlocker;
   int len = _threads->length();
   for (int i = 0; i < len; i++) {
     currentThread = _threads->at(i);
+    // This code is called at a safepoint so this ObjectMonitorHandle
+    // is not strictly necessary.
     ObjectMonitorHandle omh;
     ObjectMonitor* waitingToLockMonitor = currentThread->current_pending_monitor(&omh);
     waitingToLockRawMonitor = currentThread->current_pending_raw_monitor();
     waitingToLockBlocker = currentThread->current_park_blocker();
     st->cr();
< prev index next >