< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

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

@@ -108,11 +108,11 @@
 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;
+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,11 +426,11 @@
     assert(_owner == Self, "invariant");
     assert(_Responsible != Self, "invariant");
     return;
   }
 
-  DeferredInitialize();
+  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,11 +1100,11 @@
 intptr_t ObjectMonitor::complete_exit(TRAPS) {
   Thread * const Self = THREAD;
   assert(Self->is_Java_thread(), "Must be Java thread!");
   JavaThread *jt = (JavaThread *)THREAD;
 
-  DeferredInitialize();
+  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,11 +1184,11 @@
 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();
+  assert(InitDone, "Unexpectedly not initialized");
 
   // Throw IMSX or IEX.
   CHECK_OWNER();
 
   EventJavaMonitorWait event;

@@ -1885,11 +1885,11 @@
 // 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() {
+void ObjectMonitor::init_2() {
   static int InitializationCompleted = 0;
   assert(InitializationCompleted == 0, "invariant");
   InitializationCompleted = 1;
   if (UsePerfData) {
     EXCEPTION_MARK;

@@ -1913,26 +1913,19 @@
 #undef NEWPERFCOUNTER
 #undef NEWPERFVARIABLE
   }
 }
 
-void ObjectMonitor::DeferredInitialize() {
-  if (InitDone > 0) return;
-  if (Atomic::cmpxchg (-1, &InitDone, 0) != 0) {
-    while (InitDone != 1) /* empty */;
-    return;
-  }
-
+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;
   }
 
-  OrderAccess::fence();
-  InitDone = 1;
+  DEBUG_ONLY(InitDone = true;)
 }
 
< prev index next >