equal
deleted
inserted
replaced
92 } |
92 } |
93 |
93 |
94 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { |
94 instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { |
95 // Must do an acquire so as to force ordering of subsequent |
95 // Must do an acquire so as to force ordering of subsequent |
96 // loads from anything _memory_mgr_obj points to or implies. |
96 // loads from anything _memory_mgr_obj points to or implies. |
97 instanceOop mgr_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_mgr_obj); |
97 instanceOop mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj); |
98 if (mgr_obj == NULL) { |
98 if (mgr_obj == NULL) { |
99 // It's ok for more than one thread to execute the code up to the locked region. |
99 // It's ok for more than one thread to execute the code up to the locked region. |
100 // Extra manager instances will just be gc'ed. |
100 // Extra manager instances will just be gc'ed. |
101 Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0); |
101 Klass* k = Management::sun_management_ManagementFactoryHelper_klass(CHECK_0); |
102 |
102 |
145 // _memory_mgr_obj here because some other thread may have initialized |
145 // _memory_mgr_obj here because some other thread may have initialized |
146 // it while we were executing the code before the lock. |
146 // it while we were executing the code before the lock. |
147 // |
147 // |
148 // The lock has done an acquire, so the load can't float above it, but |
148 // The lock has done an acquire, so the load can't float above it, but |
149 // we need to do a load_acquire as above. |
149 // we need to do a load_acquire as above. |
150 mgr_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_mgr_obj); |
150 mgr_obj = OrderAccess::load_acquire(&_memory_mgr_obj); |
151 if (mgr_obj != NULL) { |
151 if (mgr_obj != NULL) { |
152 return mgr_obj; |
152 return mgr_obj; |
153 } |
153 } |
154 |
154 |
155 // Get the address of the object we created via call_special. |
155 // Get the address of the object we created via call_special. |
157 |
157 |
158 // Use store barrier to make sure the memory accesses associated |
158 // Use store barrier to make sure the memory accesses associated |
159 // with creating the management object are visible before publishing |
159 // with creating the management object are visible before publishing |
160 // its address. The unlock will publish the store to _memory_mgr_obj |
160 // its address. The unlock will publish the store to _memory_mgr_obj |
161 // because it does a release first. |
161 // because it does a release first. |
162 OrderAccess::release_store_ptr(&_memory_mgr_obj, mgr_obj); |
162 OrderAccess::release_store(&_memory_mgr_obj, mgr_obj); |
163 } |
163 } |
164 } |
164 } |
165 |
165 |
166 return mgr_obj; |
166 return mgr_obj; |
167 } |
167 } |