< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
rev 58110 : v2.09a with 8235795, 8235931 and 8236035 extracted; rebased to jdk-14+28; merge with 8236035.patch.cr1; merge with 8235795.patch.cr1; merge with 8236035.patch.cr2; merge with 8235795.patch.cr2; merge with 8235795.patch.cr3.
rev 58111 : See CR9-to-CR10-changes; merge with jdk-15+11.

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -649,18 +649,26 @@
 jvmtiError
 JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThread *java_thread, jobject *monitor_ptr) {
 #ifdef ASSERT
   uint32_t debug_bits = 0;
 #endif
+  // Note: The is_thread_fully_suspended() part of the assert() is
+  // from an older implementation that recognized suspension as
+  // being safe. However, that was racy in the face of rogue resumes.
+  // Should be replaced with "calling_thread == java_thread".
   assert((SafepointSynchronize::is_at_safepoint() ||
           java_thread->is_thread_fully_suspended(false, &debug_bits)),
          "at safepoint or target thread is suspended");
   oop obj = NULL;
-  ObjectMonitor *mon = java_thread->current_waiting_monitor();
+  // For all of the get_current_contended_monitor() call sites, we
+  // are either at a safepoint or the calling thread is operating
+  // on itself so this ObjectMonitorHandle is not strictly necessary.
+  ObjectMonitorHandle omh;
+  ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh);
   if (mon == NULL) {
     // thread is not doing an Object.wait() call
-    mon = java_thread->current_pending_monitor();
+    mon = java_thread->current_pending_monitor(&omh);
     if (mon != NULL) {
       // The thread is trying to enter() an ObjectMonitor.
       obj = (oop)mon->object();
       assert(obj != NULL, "ObjectMonitor should have a valid object!");
     }

@@ -732,20 +740,28 @@
   }
 
   HandleMark hm;
   oop wait_obj = NULL;
   {
+    // For all of the get_locked_objects_in_frame() call sites, we
+    // are either at a safepoint or the calling thread is operating
+    // on itself so this ObjectMonitorHandle is not strictly necessary.
+    ObjectMonitorHandle omh;
     // save object of current wait() call (if any) for later comparison
-    ObjectMonitor *mon = java_thread->current_waiting_monitor();
+    ObjectMonitor *mon = java_thread->current_waiting_monitor(&omh);
     if (mon != NULL) {
       wait_obj = (oop)mon->object();
     }
   }
   oop pending_obj = NULL;
   {
+    // For all of the get_locked_objects_in_frame() call sites, we
+    // are either at a safepoint or the calling thread is operating
+    // on itself so this ObjectMonitorHandle is not strictly necessary.
+    ObjectMonitorHandle omh;
     // save object of current enter() call (if any) for later comparison
-    ObjectMonitor *mon = java_thread->current_pending_monitor();
+    ObjectMonitor *mon = java_thread->current_pending_monitor(&omh);
     if (mon != NULL) {
       pending_obj = (oop)mon->object();
     }
   }
 
< prev index next >