< prev index next >

src/hotspot/share/runtime/mutex.cpp

Print this page

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

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));

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