< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page
rev 51882 : imported patch 8211176-eager-object-monitor-init

*** 108,118 **** static int Knob_Penalty = 200; // spin failure penalty static int Knob_Poverty = 1000; static int Knob_FixedSpin = 0; static int Knob_PreSpin = 10; // 20-100 likely better ! static volatile int InitDone = 0; // ----------------------------------------------------------------------------- // Theory of operations -- Monitors lists, thread residency, etc: // // * A thread acquires ownership of a monitor by successfully --- 108,118 ---- static int Knob_Penalty = 200; // spin failure penalty static int Knob_Poverty = 1000; static int Knob_FixedSpin = 0; static int Knob_PreSpin = 10; // 20-100 likely better ! DEBUG_ONLY(static volatile bool InitDone = false;) // ----------------------------------------------------------------------------- // Theory of operations -- Monitors lists, thread residency, etc: // // * A thread acquires ownership of a monitor by successfully
*** 426,436 **** assert(_owner == Self, "invariant"); assert(_Responsible != Self, "invariant"); return; } ! DeferredInitialize(); // We try one round of spinning *before* enqueueing Self. // // If the _owner is ready but OFFPROC we could use a YieldTo() // operation to donate the remainder of this thread's quantum --- 426,436 ---- assert(_owner == Self, "invariant"); assert(_Responsible != Self, "invariant"); return; } ! assert(InitDone, "Unexpectedly not initialized"); // We try one round of spinning *before* enqueueing Self. // // If the _owner is ready but OFFPROC we could use a YieldTo() // operation to donate the remainder of this thread's quantum
*** 1100,1110 **** intptr_t ObjectMonitor::complete_exit(TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; ! DeferredInitialize(); if (THREAD != _owner) { if (THREAD->is_lock_owned ((address)_owner)) { assert(_recursions == 0, "internal state error"); _owner = THREAD; // Convert from basiclock addr to Thread addr --- 1100,1110 ---- intptr_t ObjectMonitor::complete_exit(TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; ! assert(InitDone, "Unexpectedly not initialized"); if (THREAD != _owner) { if (THREAD->is_lock_owned ((address)_owner)) { assert(_recursions == 0, "internal state error"); _owner = THREAD; // Convert from basiclock addr to Thread addr
*** 1184,1194 **** void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; ! DeferredInitialize(); // Throw IMSX or IEX. CHECK_OWNER(); EventJavaMonitorWait event; --- 1184,1194 ---- void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; ! assert(InitDone, "Unexpectedly not initialized"); // Throw IMSX or IEX. CHECK_OWNER(); EventJavaMonitorWait event;
*** 1885,1895 **** // One-shot global initialization for the sync subsystem. // We could also defer initialization and initialize on-demand // the first time we call inflate(). Initialization would // be protected - like so many things - by the MonitorCache_lock. ! void ObjectMonitor::Initialize() { static int InitializationCompleted = 0; assert(InitializationCompleted == 0, "invariant"); InitializationCompleted = 1; if (UsePerfData) { EXCEPTION_MARK; --- 1885,1895 ---- // One-shot global initialization for the sync subsystem. // We could also defer initialization and initialize on-demand // the first time we call inflate(). Initialization would // be protected - like so many things - by the MonitorCache_lock. ! void ObjectMonitor::init_2() { static int InitializationCompleted = 0; assert(InitializationCompleted == 0, "invariant"); InitializationCompleted = 1; if (UsePerfData) { EXCEPTION_MARK;
*** 1913,1938 **** #undef NEWPERFCOUNTER #undef NEWPERFVARIABLE } } ! void ObjectMonitor::DeferredInitialize() { ! if (InitDone > 0) return; ! if (Atomic::cmpxchg (-1, &InitDone, 0) != 0) { ! while (InitDone != 1) /* empty */; ! return; ! } ! // One-shot global initialization ... // The initialization is idempotent, so we don't need locks. // In the future consider doing this via os::init_2(). if (!os::is_MP()) { Knob_SpinLimit = 0; Knob_PreSpin = 0; Knob_FixedSpin = -1; } ! OrderAccess::fence(); ! InitDone = 1; } --- 1913,1931 ---- #undef NEWPERFCOUNTER #undef NEWPERFVARIABLE } } ! void ObjectMonitor::init() { // One-shot global initialization ... // The initialization is idempotent, so we don't need locks. // In the future consider doing this via os::init_2(). if (!os::is_MP()) { Knob_SpinLimit = 0; Knob_PreSpin = 0; Knob_FixedSpin = -1; } ! DEBUG_ONLY(InitDone = true;) }
< prev index next >