< prev index next >
src/share/vm/runtime/objectMonitor.cpp
Print this page
@@ -22,12 +22,14 @@
*
*/
#include "precompiled.hpp"
#include "classfile/vmSymbols.hpp"
+#if INCLUDE_JFR
#include "jfr/jfrEvents.hpp"
#include "jfr/support/jfrThreadId.hpp"
+#endif
#include "memory/resourceArea.hpp"
#include "oops/markOop.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.hpp"
@@ -378,15 +380,17 @@
// Prevent deflation at STW-time. See deflate_idle_monitors() and is_busy().
// Ensure the object-monitor relationship remains stable while there's contention.
Atomic::inc_ptr(&_count);
JFR_ONLY(JfrConditionalFlushWithStacktrace<EventJavaMonitorEnter> flush(jt);)
+#if INCLUDE_JFR
EventJavaMonitorEnter event;
if (event.should_commit()) {
event.set_monitorClass(((oop)this->object())->klass());
event.set_address((uintptr_t)(this->object_addr()));
}
+#endif
{ // Change java thread status to indicate blocked on monitor enter.
JavaThreadBlockedOnMonitorEnterState jtbmes(jt, this);
Self->set_current_pending_monitor(this);
@@ -470,14 +474,16 @@
// it doesn't matter if the JVMTI_EVENT_MONITOR_CONTENDED_ENTERED
// event handler consumed an unpark() issued by the thread that
// just exited the monitor.
}
+#if INCLUDE_JFR
if (event.should_commit()) {
event.set_previousOwner((uintptr_t)_previous_owner_tid);
event.commit();
}
+#endif
if (ObjectMonitor::_sync_ContendedLockAttempts != NULL) {
ObjectMonitor::_sync_ContendedLockAttempts->inc() ;
}
}
@@ -1446,10 +1452,11 @@
int v ;
for (v = *adr ; Atomic::cmpxchg (v + dx, adr, v) != v; v = *adr) ;
return v ;
}
+#if INCLUDE_JFR
// helper method for posting a monitor wait event
static void post_monitor_wait_event(EventJavaMonitorWait* event,
ObjectMonitor* monitor,
jlong notifier_tid,
jlong timeout,
@@ -1460,10 +1467,11 @@
event->set_address((uintptr_t)monitor->object_addr());
event->set_notifier((u8)notifier_tid);
event->set_timedOut(timedout);
event->commit();
}
+#endif
// -----------------------------------------------------------------------------
// Wait/Notify/NotifyAll
//
// Note: a subset of changes to ObjectMonitor::wait()
@@ -1476,11 +1484,13 @@
DeferredInitialize () ;
// Throw IMSX or IEX.
CHECK_OWNER();
+#if INCLUDE_JFR
EventJavaMonitorWait event;
+#endif
// check for a pending interrupt
if (interruptible && Thread::is_interrupted(Self, true) && !HAS_PENDING_EXCEPTION) {
// post monitor waited event. Note that this is past-tense, we are done waiting.
if (JvmtiExport::should_post_monitor_waited()) {
@@ -1494,13 +1504,15 @@
// cannot be made the successor. This means that the
// JVMTI_EVENT_MONITOR_WAITED event handler cannot accidentally
// consume an unpark() meant for the ParkEvent associated with
// this ObjectMonitor.
}
+#if INCLUDE_JFR
if (event.should_commit()) {
post_monitor_wait_event(&event, this, 0, millis, false);
}
+#endif
TEVENT (Wait - Throw IEX) ;
THROW(vmSymbols::java_lang_InterruptedException());
return ;
}
@@ -1638,13 +1650,15 @@
// entering the unlocked monitor.
node._event->unpark();
}
}
+#if INCLUDE_JFR
if (event.should_commit()) {
post_monitor_wait_event(&event, this, node._notifier_tid, millis, ret == OS_TIMEOUT);
}
+#endif
OrderAccess::fence() ;
assert (Self->_Stalled != 0, "invariant") ;
Self->_Stalled = 0 ;
@@ -1722,11 +1736,13 @@
if (Policy != 4) {
iterator->TState = ObjectWaiter::TS_ENTER ;
}
iterator->_notified = 1 ;
Thread * Self = THREAD;
+#if INCLUDE_JFR
iterator->_notifier_tid = JFR_THREAD_ID(Self);
+#endif
ObjectWaiter * List = _EntryList ;
if (List != NULL) {
assert (List->_prev == NULL, "invariant") ;
assert (List->TState == ObjectWaiter::TS_ENTER, "invariant") ;
@@ -1848,11 +1864,13 @@
guarantee (iterator->TState == ObjectWaiter::TS_WAIT, "invariant") ;
guarantee (iterator->_notified == 0, "invariant") ;
iterator->_notified = 1 ;
Thread * Self = THREAD;
+#if INCLUDE_JFR
iterator->_notifier_tid = JFR_THREAD_ID(Self);
+#endif
if (Policy != 4) {
iterator->TState = ObjectWaiter::TS_ENTER ;
}
ObjectWaiter * List = _EntryList ;
< prev index next >