< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page
rev 48406 : 8194406: Use Atomic::replace_if_null
Reviewed-by: coleenp, dholmes


 221     // Case: light contention possibly amenable to TLE
 222     // Case: TLE inimical operations such as nested/recursive synchronization
 223 
 224     if (owner == Self) {
 225       m->_recursions++;
 226       return true;
 227     }
 228 
 229     // This Java Monitor is inflated so obj's header will never be
 230     // displaced to this thread's BasicLock. Make the displaced header
 231     // non-NULL so this BasicLock is not seen as recursive nor as
 232     // being locked. We do this unconditionally so that this thread's
 233     // BasicLock cannot be mis-interpreted by any stack walkers. For
 234     // performance reasons, stack walkers generally first check for
 235     // Biased Locking in the object's header, the second check is for
 236     // stack-locking in the object's header, the third check is for
 237     // recursive stack-locking in the displaced header in the BasicLock,
 238     // and last are the inflated Java Monitor (ObjectMonitor) checks.
 239     lock->set_displaced_header(markOopDesc::unused_mark());
 240 
 241     if (owner == NULL &&
 242         Atomic::cmpxchg(Self, &(m->_owner), (void*)NULL) == NULL) {
 243       assert(m->_recursions == 0, "invariant");
 244       assert(m->_owner == Self, "invariant");
 245       return true;
 246     }
 247   }
 248 
 249   // Note that we could inflate in quick_enter.
 250   // This is likely a useful optimization
 251   // Critically, in quick_enter() we must not:
 252   // -- perform bias revocation, or
 253   // -- block indefinitely, or
 254   // -- reach a safepoint
 255 
 256   return false;        // revert to slow-path
 257 }
 258 
 259 // -----------------------------------------------------------------------------
 260 //  Fast Monitor Enter/Exit
 261 // This the fast monitor enter. The interpreter and compiler use
 262 // some assembly copies of this code. Make sure update those code




 221     // Case: light contention possibly amenable to TLE
 222     // Case: TLE inimical operations such as nested/recursive synchronization
 223 
 224     if (owner == Self) {
 225       m->_recursions++;
 226       return true;
 227     }
 228 
 229     // This Java Monitor is inflated so obj's header will never be
 230     // displaced to this thread's BasicLock. Make the displaced header
 231     // non-NULL so this BasicLock is not seen as recursive nor as
 232     // being locked. We do this unconditionally so that this thread's
 233     // BasicLock cannot be mis-interpreted by any stack walkers. For
 234     // performance reasons, stack walkers generally first check for
 235     // Biased Locking in the object's header, the second check is for
 236     // stack-locking in the object's header, the third check is for
 237     // recursive stack-locking in the displaced header in the BasicLock,
 238     // and last are the inflated Java Monitor (ObjectMonitor) checks.
 239     lock->set_displaced_header(markOopDesc::unused_mark());
 240 
 241     if (owner == NULL && Atomic::replace_if_null(Self, &(m->_owner))) {

 242       assert(m->_recursions == 0, "invariant");
 243       assert(m->_owner == Self, "invariant");
 244       return true;
 245     }
 246   }
 247 
 248   // Note that we could inflate in quick_enter.
 249   // This is likely a useful optimization
 250   // Critically, in quick_enter() we must not:
 251   // -- perform bias revocation, or
 252   // -- block indefinitely, or
 253   // -- reach a safepoint
 254 
 255   return false;        // revert to slow-path
 256 }
 257 
 258 // -----------------------------------------------------------------------------
 259 //  Fast Monitor Enter/Exit
 260 // This the fast monitor enter. The interpreter and compiler use
 261 // some assembly copies of this code. Make sure update those code


< prev index next >