< prev index next >

src/hotspot/share/runtime/mutex.cpp

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

@@ -465,11 +465,11 @@
   // LockWord encoding = (cxq,LOCKBYTE)
   ESelf->reset();
   OrderAccess::fence();
 
   // Optional optimization ... try barging on the inner lock
-  if ((NativeMonitorFlags & 32) && Atomic::cmpxchg(ESelf, &_OnDeck, (ParkEvent*)NULL) == NULL) {
+  if ((NativeMonitorFlags & 32) && Atomic::replace_if_null(ESelf, &_OnDeck)) {
     goto OnDeck_LOOP;
   }
 
   if (AcquireOrPush(ESelf)) goto Exeunt;
 

@@ -572,11 +572,11 @@
   // but only one concurrent consumer (detacher of RATs).
   // Consider protecting this critical section with schedctl on Solaris.
   // Unlike a normal lock, however, the exiting thread "locks" OnDeck,
   // picks a successor and marks that thread as OnDeck.  That successor
   // thread will then clear OnDeck once it eventually acquires the outer lock.
-  if (Atomic::cmpxchg((ParkEvent*)_LBIT, &_OnDeck, (ParkEvent*)NULL) != NULL) {
+  if (!Atomic::replace_if_null((ParkEvent*)_LBIT, &_OnDeck)) {
     return;
   }
 
   ParkEvent * List = _EntryList;
   if (List != NULL) {
< prev index next >