< prev index next >

src/hotspot/share/runtime/mutex.cpp

Print this page

254     wait_status = _lock.wait(timeout);
255   }
256 
257   if (ifmr.not_released()) {
258     // Not unlocked by ~ThreadBlockInVMPreprocess
259     assert_owner(nullptr);
260     // Conceptually reestablish ownership of the lock.
261     set_owner(self);
262   } else {
263     lock(self);
264   }
265 
266   return wait_status != 0;          // return true IFF timeout
267 }
268 
269 Mutex::~Mutex() {
270   assert_owner(nullptr);
271   os::free(const_cast<char*>(_name));
272 }
273 
274 Mutex::Mutex(Rank rank, const char * name, bool allow_vm_block) : _owner(nullptr) {
275   assert(os::mutex_init_done(), "Too early!");
276   assert(name != nullptr, "Mutex requires a name");
277   _name = os::strdup(name, mtInternal);

278 #ifdef ASSERT
279   _allow_vm_block  = allow_vm_block;
280   _rank            = rank;
281   _skip_rank_check = false;
282 
283   assert(_rank >= static_cast<Rank>(0) && _rank <= safepoint, "Bad lock rank %s: %s", rank_name(), name);
284 
285   // The allow_vm_block also includes allowing other non-Java threads to block or
286   // allowing Java threads to block in native.
287   assert(_rank > nosafepoint || _allow_vm_block,
288          "Locks that don't check for safepoint should always allow the vm to block: %s", name);
289 #endif
290 }
291 
292 bool Mutex::owned_by_self() const {
293   return owner() == Thread::current();
294 }
295 
296 void Mutex::print_on_error(outputStream* st) const {
297   st->print("[" PTR_FORMAT, p2i(this));

254     wait_status = _lock.wait(timeout);
255   }
256 
257   if (ifmr.not_released()) {
258     // Not unlocked by ~ThreadBlockInVMPreprocess
259     assert_owner(nullptr);
260     // Conceptually reestablish ownership of the lock.
261     set_owner(self);
262   } else {
263     lock(self);
264   }
265 
266   return wait_status != 0;          // return true IFF timeout
267 }
268 
269 Mutex::~Mutex() {
270   assert_owner(nullptr);
271   os::free(const_cast<char*>(_name));
272 }
273 
274 Mutex::Mutex(Rank rank, const char * name, bool allow_vm_block) : _owner(nullptr), _id(-1) {
275   assert(os::mutex_init_done(), "Too early!");
276   assert(name != nullptr, "Mutex requires a name");
277   _name = os::strdup(name, mtInternal);
278   _id = MutexLocker::name2id(name);
279 #ifdef ASSERT
280   _allow_vm_block  = allow_vm_block;
281   _rank            = rank;
282   _skip_rank_check = false;
283 
284   assert(_rank >= static_cast<Rank>(0) && _rank <= safepoint, "Bad lock rank %s: %s", rank_name(), name);
285 
286   // The allow_vm_block also includes allowing other non-Java threads to block or
287   // allowing Java threads to block in native.
288   assert(_rank > nosafepoint || _allow_vm_block,
289          "Locks that don't check for safepoint should always allow the vm to block: %s", name);
290 #endif
291 }
292 
293 bool Mutex::owned_by_self() const {
294   return owner() == Thread::current();
295 }
296 
297 void Mutex::print_on_error(outputStream* st) const {
298   st->print("[" PTR_FORMAT, p2i(this));
< prev index next >