< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page
rev 47400 : [mq]: cmpxchg_ptr
rev 47401 : [mq]: cmpxchg_if_null
rev 47404 : [mq]: load_ptr_acquire
rev 47406 : [mq]: assembler_cmpxchg

@@ -109,13 +109,11 @@
 
 #define NINFLATIONLOCKS 256
 static volatile intptr_t gInflationLocks[NINFLATIONLOCKS];
 
 // global list of blocks of monitors
-// gBlockList is really PaddedEnd<ObjectMonitor> *, but we don't
-// want to expose the PaddedEnd template more than necessary.
-ObjectMonitor * volatile ObjectSynchronizer::gBlockList = NULL;
+PaddedEnd<ObjectMonitor> * volatile ObjectSynchronizer::gBlockList = NULL;
 // global monitor free list
 ObjectMonitor * volatile ObjectSynchronizer::gFreeList  = NULL;
 // global monitor in-use list, for moribund threads,
 // monitors they inflated need to be scanned for deflation
 ObjectMonitor * volatile ObjectSynchronizer::gOmInUseList  = NULL;

@@ -239,11 +237,11 @@
     // recursive stack-locking in the displaced header in the BasicLock,
     // and last are the inflated Java Monitor (ObjectMonitor) checks.
     lock->set_displaced_header(markOopDesc::unused_mark());
 
     if (owner == NULL &&
-        Atomic::cmpxchg_ptr(Self, &(m->_owner), NULL) == NULL) {
+        Atomic::cmpxchg_if_null((void*)Self, &(m->_owner))) {
       assert(m->_recursions == 0, "invariant");
       assert(m->_owner == Self, "invariant");
       return true;
     }
   }

@@ -800,11 +798,11 @@
   hash = mark->hash();
   if (hash == 0) {
     hash = get_next_hash(Self, obj);
     temp = mark->copy_set_hash(hash); // merge hash code into header
     assert(temp->is_neutral(), "invariant");
-    test = (markOop) Atomic::cmpxchg_ptr(temp, monitor, mark);
+    test = Atomic::cmpxchg(temp, monitor->header_addr(), mark);
     if (test != mark) {
       // The only update to the header in the monitor (outside GC)
       // is install the hash code. If someone add new usage of
       // displaced header, please update this code
       hash = test->hash();

@@ -937,12 +935,11 @@
 }
 
 // Visitors ...
 
 void ObjectSynchronizer::monitors_iterate(MonitorClosure* closure) {
-  PaddedEnd<ObjectMonitor> * block =
-    (PaddedEnd<ObjectMonitor> *)OrderAccess::load_ptr_acquire(&gBlockList);
+  PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
   while (block != NULL) {
     assert(block->object() == CHAINMARKER, "must be a block header");
     for (int i = _BLOCKSIZE - 1; i > 0; i--) {
       ObjectMonitor* mid = (ObjectMonitor *)(block + i);
       oop object = (oop)mid->object();

@@ -989,12 +986,11 @@
   }
 }
 
 void ObjectSynchronizer::global_oops_do(OopClosure* f) {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
-  PaddedEnd<ObjectMonitor> * block =
-    (PaddedEnd<ObjectMonitor> *)OrderAccess::load_ptr_acquire(&gBlockList);
+  PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
   for (; block != NULL; block = (PaddedEnd<ObjectMonitor> *)next(block)) {
     assert(block->object() == CHAINMARKER, "must be a block header");
     for (int i = 1; i < _BLOCKSIZE; i++) {
       ObjectMonitor* mid = (ObjectMonitor *)&block[i];
       if (mid->object() != NULL) {

@@ -1230,11 +1226,11 @@
     // The very first objectMonitor in a block is reserved and dedicated.
     // It serves as blocklist "next" linkage.
     temp[0].FreeNext = gBlockList;
     // There are lock-free uses of gBlockList so make sure that
     // the previous stores happen before we update gBlockList.
-    OrderAccess::release_store_ptr(&gBlockList, temp);
+    OrderAccess::release_store(&gBlockList, temp);
 
     // Add the new string of objectMonitors to the global free list
     temp[_BLOCKSIZE - 1].FreeNext = gFreeList;
     gFreeList = temp + 1;
     Thread::muxRelease(&gListLock);

@@ -1732,12 +1728,11 @@
       counters->nScavenged += deflated_count;
       counters->nInuse += gOmInUseCount;
     }
 
   } else {
-    PaddedEnd<ObjectMonitor> * block =
-      (PaddedEnd<ObjectMonitor> *)OrderAccess::load_ptr_acquire(&gBlockList);
+    PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
     for (; block != NULL; block = (PaddedEnd<ObjectMonitor> *)next(block)) {
       // Iterate over all extant monitors - Scavenge all idle monitors.
       assert(block->object() == CHAINMARKER, "must be a block header");
       counters->nInCirculation += _BLOCKSIZE;
       for (int i = 1; i < _BLOCKSIZE; i++) {

@@ -1967,12 +1962,11 @@
 // Check if monitor belongs to the monitor cache
 // The list is grow-only so it's *relatively* safe to traverse
 // the list of extant blocks without taking a lock.
 
 int ObjectSynchronizer::verify_objmon_isinpool(ObjectMonitor *monitor) {
-  PaddedEnd<ObjectMonitor> * block =
-    (PaddedEnd<ObjectMonitor> *)OrderAccess::load_ptr_acquire(&gBlockList);
+  PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
   while (block != NULL) {
     assert(block->object() == CHAINMARKER, "must be a block header");
     if (monitor > (ObjectMonitor *)&block[0] &&
         monitor < (ObjectMonitor *)&block[_BLOCKSIZE]) {
       address mon = (address)monitor;
< prev index next >