< prev index next >

src/hotspot/share/runtime/mutex.cpp

Print this page

264   }
265 
266   return wait_status != 0;          // return true IFF timeout
267 }
268 
269 static const int MAX_NUM_MUTEX = 1204;
270 static Mutex* _internal_mutex_arr[MAX_NUM_MUTEX];
271 Mutex** Mutex::_mutex_array = _internal_mutex_arr;
272 int Mutex::_num_mutex = 0;
273 
274 void Mutex::add_mutex(Mutex* var) {
275   assert(Mutex::_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");
276   Mutex::_mutex_array[_num_mutex++] = var;
277 }
278 
279 Mutex::~Mutex() {
280   assert_owner(nullptr);
281   os::free(const_cast<char*>(_name));
282 }
283 
284 Mutex::Mutex(Rank rank, const char * name, bool allow_vm_block) : _owner(nullptr) {
285   assert(os::mutex_init_done(), "Too early!");
286   assert(name != nullptr, "Mutex requires a name");
287   _name = os::strdup(name, mtInternal);

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

264   }
265 
266   return wait_status != 0;          // return true IFF timeout
267 }
268 
269 static const int MAX_NUM_MUTEX = 1204;
270 static Mutex* _internal_mutex_arr[MAX_NUM_MUTEX];
271 Mutex** Mutex::_mutex_array = _internal_mutex_arr;
272 int Mutex::_num_mutex = 0;
273 
274 void Mutex::add_mutex(Mutex* var) {
275   assert(Mutex::_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");
276   Mutex::_mutex_array[_num_mutex++] = var;
277 }
278 
279 Mutex::~Mutex() {
280   assert_owner(nullptr);
281   os::free(const_cast<char*>(_name));
282 }
283 
284 Mutex::Mutex(Rank rank, const char * name, bool allow_vm_block) : _owner(nullptr), _id(-1) {
285   assert(os::mutex_init_done(), "Too early!");
286   assert(name != nullptr, "Mutex requires a name");
287   _name = os::strdup(name, mtInternal);
288   _id = MutexLocker::name2id(name);
289 #ifdef ASSERT
290   _allow_vm_block  = allow_vm_block;
291   _rank            = rank;
292   _skip_rank_check = false;
293 
294   assert(_rank >= static_cast<Rank>(0) && _rank <= safepoint, "Bad lock rank %s: %s", rank_name(), name);
295 
296   // The allow_vm_block also includes allowing other non-Java threads to block or
297   // allowing Java threads to block in native.
298   assert(_rank > nosafepoint || _allow_vm_block,
299          "Locks that don't check for safepoint should always allow the vm to block: %s", name);
300 #endif
301 }
302 
303 bool Mutex::owned_by_self() const {
304   return owner() == Thread::current();
305 }
306 
307 void Mutex::print_on_error(outputStream* st) const {
308   st->print("[" PTR_FORMAT, p2i(this));
< prev index next >