< prev index next >

src/share/vm/runtime/objectMonitor.cpp

Print this page

        

*** 22,31 **** --- 22,33 ---- * */ #include "precompiled.hpp" #include "classfile/vmSymbols.hpp" + #include "jfr/jfrEvents.hpp" + #include "jfr/support/jfrThreadId.hpp" #include "memory/resourceArea.hpp" #include "oops/markOop.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp"
*** 35,46 **** #include "runtime/orderAccess.inline.hpp" #include "runtime/osThread.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/thread.inline.hpp" #include "services/threadService.hpp" - #include "trace/tracing.hpp" - #include "trace/traceMacros.hpp" #include "utilities/dtrace.hpp" #include "utilities/macros.hpp" #include "utilities/preserveException.hpp" #ifdef TARGET_OS_FAMILY_linux # include "os_linux.inline.hpp" --- 37,46 ----
*** 52,61 **** --- 52,64 ---- # include "os_windows.inline.hpp" #endif #ifdef TARGET_OS_FAMILY_bsd # include "os_bsd.inline.hpp" #endif + #if INCLUDE_JFR + #include "jfr/support/jfrFlush.hpp" + #endif #if defined(__GNUC__) && !defined(IA64) && !defined(PPC64) // Need to inhibit inlining for older versions of GCC to avoid build-time failures #define ATTR __attribute__((noinline)) #else
*** 374,384 **** --- 377,392 ---- // 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);) EventJavaMonitorEnter event; + if (event.should_commit()) { + event.set_monitorClass(((oop)this->object())->klass()); + event.set_address((uintptr_t)(this->object_addr())); + } { // Change java thread status to indicate blocked on monitor enter. JavaThreadBlockedOnMonitorEnterState jtbmes(jt, this); Self->set_current_pending_monitor(this);
*** 463,475 **** // event handler consumed an unpark() issued by the thread that // just exited the monitor. } if (event.should_commit()) { ! event.set_klass(((oop)this->object())->klass()); ! event.set_previousOwner((TYPE_JAVALANGTHREAD)_previous_owner_tid); ! event.set_address((TYPE_ADDRESS)(uintptr_t)(this->object_addr())); event.commit(); } if (ObjectMonitor::_sync_ContendedLockAttempts != NULL) { ObjectMonitor::_sync_ContendedLockAttempts->inc() ; --- 471,481 ---- // event handler consumed an unpark() issued by the thread that // just exited the monitor. } if (event.should_commit()) { ! event.set_previousOwner((uintptr_t)_previous_owner_tid); event.commit(); } if (ObjectMonitor::_sync_ContendedLockAttempts != NULL) { ObjectMonitor::_sync_ContendedLockAttempts->inc() ;
*** 988,1002 **** // a MEMBAR or other serializing instruction before fetching EntryList|cxq. if ((SyncFlags & 4) == 0) { _Responsible = NULL ; } ! #if INCLUDE_TRACE // get the owner's thread id for the MonitorEnter event // if it is enabled and the thread isn't suspended ! if (not_suspended && Tracing::is_event_enabled(TraceJavaMonitorEnterEvent)) { ! _previous_owner_tid = SharedRuntime::get_java_tid(Self); } #endif for (;;) { assert (THREAD == _owner, "invariant") ; --- 994,1008 ---- // a MEMBAR or other serializing instruction before fetching EntryList|cxq. if ((SyncFlags & 4) == 0) { _Responsible = NULL ; } ! #if INCLUDE_JFR // get the owner's thread id for the MonitorEnter event // if it is enabled and the thread isn't suspended ! if (not_suspended && EventJavaMonitorEnter::is_enabled()) { ! _previous_owner_tid = JFR_THREAD_ID(Self); } #endif for (;;) { assert (THREAD == _owner, "invariant") ;
*** 1441,1459 **** for (v = *adr ; Atomic::cmpxchg (v + dx, adr, v) != v; v = *adr) ; return v ; } // helper method for posting a monitor wait event ! void ObjectMonitor::post_monitor_wait_event(EventJavaMonitorWait* event, jlong notifier_tid, jlong timeout, bool timedout) { ! event->set_klass(((oop)this->object())->klass()); ! event->set_timeout((TYPE_ULONG)timeout); ! event->set_address((TYPE_ADDRESS)(uintptr_t)(this->object_addr())); ! event->set_notifier((TYPE_OSTHREAD)notifier_tid); ! event->set_timedOut((TYPE_BOOLEAN)timedout); event->commit(); } // ----------------------------------------------------------------------------- // Wait/Notify/NotifyAll --- 1447,1467 ---- for (v = *adr ; Atomic::cmpxchg (v + dx, adr, v) != v; v = *adr) ; return v ; } // helper method for posting a monitor wait event ! static void post_monitor_wait_event(EventJavaMonitorWait* event, ! ObjectMonitor* monitor, jlong notifier_tid, jlong timeout, bool timedout) { ! assert(monitor != NULL, "invariant"); ! event->set_monitorClass(((oop)monitor->object())->klass()); ! event->set_timeout(timeout); ! event->set_address((uintptr_t)monitor->object_addr()); ! event->set_notifier((u8)notifier_tid); ! event->set_timedOut(timedout); event->commit(); } // ----------------------------------------------------------------------------- // Wait/Notify/NotifyAll
*** 1487,1497 **** // JVMTI_EVENT_MONITOR_WAITED event handler cannot accidentally // consume an unpark() meant for the ParkEvent associated with // this ObjectMonitor. } if (event.should_commit()) { ! post_monitor_wait_event(&event, 0, millis, false); } TEVENT (Wait - Throw IEX) ; THROW(vmSymbols::java_lang_InterruptedException()); return ; } --- 1495,1505 ---- // JVMTI_EVENT_MONITOR_WAITED event handler cannot accidentally // consume an unpark() meant for the ParkEvent associated with // this ObjectMonitor. } if (event.should_commit()) { ! post_monitor_wait_event(&event, this, 0, millis, false); } TEVENT (Wait - Throw IEX) ; THROW(vmSymbols::java_lang_InterruptedException()); return ; }
*** 1631,1641 **** node._event->unpark(); } } if (event.should_commit()) { ! post_monitor_wait_event(&event, node._notifier_tid, millis, ret == OS_TIMEOUT); } OrderAccess::fence() ; assert (Self->_Stalled != 0, "invariant") ; --- 1639,1649 ---- node._event->unpark(); } } if (event.should_commit()) { ! post_monitor_wait_event(&event, this, node._notifier_tid, millis, ret == OS_TIMEOUT); } OrderAccess::fence() ; assert (Self->_Stalled != 0, "invariant") ;
*** 1714,1724 **** if (Policy != 4) { iterator->TState = ObjectWaiter::TS_ENTER ; } iterator->_notified = 1 ; Thread * Self = THREAD; ! iterator->_notifier_tid = Self->osthread()->thread_id(); ObjectWaiter * List = _EntryList ; if (List != NULL) { assert (List->_prev == NULL, "invariant") ; assert (List->TState == ObjectWaiter::TS_ENTER, "invariant") ; --- 1722,1732 ---- if (Policy != 4) { iterator->TState = ObjectWaiter::TS_ENTER ; } iterator->_notified = 1 ; Thread * Self = THREAD; ! iterator->_notifier_tid = JFR_THREAD_ID(Self); ObjectWaiter * List = _EntryList ; if (List != NULL) { assert (List->_prev == NULL, "invariant") ; assert (List->TState == ObjectWaiter::TS_ENTER, "invariant") ;
*** 1840,1850 **** guarantee (iterator->TState == ObjectWaiter::TS_WAIT, "invariant") ; guarantee (iterator->_notified == 0, "invariant") ; iterator->_notified = 1 ; Thread * Self = THREAD; ! iterator->_notifier_tid = Self->osthread()->thread_id(); if (Policy != 4) { iterator->TState = ObjectWaiter::TS_ENTER ; } ObjectWaiter * List = _EntryList ; --- 1848,1858 ---- guarantee (iterator->TState == ObjectWaiter::TS_WAIT, "invariant") ; guarantee (iterator->_notified == 0, "invariant") ; iterator->_notified = 1 ; Thread * Self = THREAD; ! iterator->_notifier_tid = JFR_THREAD_ID(Self); if (Policy != 4) { iterator->TState = ObjectWaiter::TS_ENTER ; } ObjectWaiter * List = _EntryList ;
< prev index next >