src/hotspot/share/services/memoryPool.cpp
changeset 59247 56bf71d64d51
parent 50429 83aec1d357d4
child 59290 97d13893ec3c
equal deleted inserted replaced
59246:fcad92f425c5 59247:56bf71d64d51
    75 // It creates a MemoryPool instance when the first time
    75 // It creates a MemoryPool instance when the first time
    76 // this function is called.
    76 // this function is called.
    77 instanceOop MemoryPool::get_memory_pool_instance(TRAPS) {
    77 instanceOop MemoryPool::get_memory_pool_instance(TRAPS) {
    78   // Must do an acquire so as to force ordering of subsequent
    78   // Must do an acquire so as to force ordering of subsequent
    79   // loads from anything _memory_pool_obj points to or implies.
    79   // loads from anything _memory_pool_obj points to or implies.
    80   instanceOop pool_obj = OrderAccess::load_acquire(&_memory_pool_obj);
    80   instanceOop pool_obj = Atomic::load_acquire(&_memory_pool_obj);
    81   if (pool_obj == NULL) {
    81   if (pool_obj == NULL) {
    82     // It's ok for more than one thread to execute the code up to the locked region.
    82     // It's ok for more than one thread to execute the code up to the locked region.
    83     // Extra pool instances will just be gc'ed.
    83     // Extra pool instances will just be gc'ed.
    84     InstanceKlass* ik = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL);
    84     InstanceKlass* ik = Management::sun_management_ManagementFactoryHelper_klass(CHECK_NULL);
    85 
    85 
   116       // _memory_pool_obj here because some other thread may have
   116       // _memory_pool_obj here because some other thread may have
   117       // initialized it while we were executing the code before the lock.
   117       // initialized it while we were executing the code before the lock.
   118       //
   118       //
   119       // The lock has done an acquire, so the load can't float above it,
   119       // The lock has done an acquire, so the load can't float above it,
   120       // but we need to do a load_acquire as above.
   120       // but we need to do a load_acquire as above.
   121       pool_obj = OrderAccess::load_acquire(&_memory_pool_obj);
   121       pool_obj = Atomic::load_acquire(&_memory_pool_obj);
   122       if (pool_obj != NULL) {
   122       if (pool_obj != NULL) {
   123          return pool_obj;
   123          return pool_obj;
   124       }
   124       }
   125 
   125 
   126       // Get the address of the object we created via call_special.
   126       // Get the address of the object we created via call_special.
   128 
   128 
   129       // Use store barrier to make sure the memory accesses associated
   129       // Use store barrier to make sure the memory accesses associated
   130       // with creating the pool are visible before publishing its address.
   130       // with creating the pool are visible before publishing its address.
   131       // The unlock will publish the store to _memory_pool_obj because
   131       // The unlock will publish the store to _memory_pool_obj because
   132       // it does a release first.
   132       // it does a release first.
   133       OrderAccess::release_store(&_memory_pool_obj, pool_obj);
   133       Atomic::release_store(&_memory_pool_obj, pool_obj);
   134     }
   134     }
   135   }
   135   }
   136 
   136 
   137   return pool_obj;
   137   return pool_obj;
   138 }
   138 }