equal
deleted
inserted
replaced
63 } |
63 } |
64 |
64 |
65 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { |
65 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { |
66 // Must do an acquire so as to force ordering of subsequent |
66 // Must do an acquire so as to force ordering of subsequent |
67 // loads from anything _memory_mgr_obj points to or implies. |
67 // loads from anything _memory_mgr_obj points to or implies. |
68 instanceOop mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj); |
68 instanceOop mgr_obj = Atomic::load_acquire(&_memory_mgr_obj); |
69 if (mgr_obj == NULL) { |
69 if (mgr_obj == NULL) { |
70 // It's ok for more than one thread to execute the code up to the locked region. |
70 // It's ok for more than one thread to execute the code up to the locked region. |
71 // Extra manager instances will just be gc'ed. |
71 // Extra manager instances will just be gc'ed. |
72 Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0); |
72 Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0); |
73 |
73 |
116 // _memory_mgr_obj here because some other thread may have initialized |
116 // _memory_mgr_obj here because some other thread may have initialized |
117 // it while we were executing the code before the lock. |
117 // 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, but |
119 // The lock has done an acquire, so the load can't float above it, but |
120 // we need to do a load_acquire as above. |
120 // we need to do a load_acquire as above. |
121 mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj); |
121 mgr_obj = Atomic::load_acquire(&_memory_mgr_obj); |
122 if (mgr_obj != NULL) { |
122 if (mgr_obj != NULL) { |
123 return mgr_obj; |
123 return mgr_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 management object are visible before publishing |
130 // with creating the management object are visible before publishing |
131 // its address. The unlock will publish the store to _memory_mgr_obj |
131 // its address. The unlock will publish the store to _memory_mgr_obj |
132 // because it does a release first. |
132 // because it does a release first. |
133 OrderAccess::release_store(&_memory_mgr_obj, mgr_obj); |
133 Atomic::release_store(&_memory_mgr_obj, mgr_obj); |
134 } |
134 } |
135 } |
135 } |
136 |
136 |
137 return mgr_obj; |
137 return mgr_obj; |
138 } |
138 } |