From ea07e719ca255d0da1966118c464ee23f4dc44da Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 8 Apr 2025 08:12:59 +0000 Subject: [PATCH] 8352256: ObjectSynchronizer::quick_notify misses JFR event notification path Reviewed-by: dholmes, coleenp, mgronlun --- src/hotspot/share/runtime/objectMonitor.cpp | 12 ++++++++++++ src/hotspot/share/runtime/objectMonitor.hpp | 2 ++ src/hotspot/share/runtime/synchronizer.cpp | 10 +++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index e280de6baf1..03228d0cb12 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -2058,6 +2058,12 @@ void ObjectMonitor::notify(TRAPS) { return; } + quick_notify(current); +} + +void ObjectMonitor::quick_notify(JavaThread* current) { + assert(has_owner(current), "Precondition"); + EventJavaMonitorNotify event; DTRACE_MONITOR_PROBE(notify, this, object(), current); int tally = notify_internal(current) ? 1 : 0; @@ -2080,6 +2086,12 @@ void ObjectMonitor::notifyAll(TRAPS) { return; } + quick_notifyAll(current); +} + +void ObjectMonitor::quick_notifyAll(JavaThread* current) { + assert(has_owner(current), "Precondition"); + EventJavaMonitorNotify event; DTRACE_MONITOR_PROBE(notifyAll, this, object(), current); int tally = 0; diff --git a/src/hotspot/share/runtime/objectMonitor.hpp b/src/hotspot/share/runtime/objectMonitor.hpp index d24201fafe4..729316811c2 100644 --- a/src/hotspot/share/runtime/objectMonitor.hpp +++ b/src/hotspot/share/runtime/objectMonitor.hpp @@ -385,6 +385,8 @@ class ObjectMonitor : public CHeapObj { void wait(jlong millis, bool interruptible, TRAPS); void notify(TRAPS); void notifyAll(TRAPS); + void quick_notify(JavaThread* current); + void quick_notifyAll(JavaThread* current); void print() const; #ifdef ASSERT diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index 73dd9d5330e..d608ffbdc02 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -368,16 +368,12 @@ bool ObjectSynchronizer::quick_notify(oopDesc* obj, JavaThread* current, bool al if (mon->first_waiter() != nullptr) { // We have one or more waiters. Since this is an inflated monitor - // that we own, we can transfer one or more threads from the waitset - // to the entry_list here and now, avoiding the slow-path. + // that we own, we quickly notify them here and now, avoiding the slow-path. if (all) { - DTRACE_MONITOR_PROBE(notifyAll, mon, obj, current); + mon->quick_notifyAll(current); } else { - DTRACE_MONITOR_PROBE(notify, mon, obj, current); + mon->quick_notify(current); } - do { - mon->notify_internal(current); - } while (mon->first_waiter() != nullptr && all); } return true; }