< prev index next >

src/hotspot/share/runtime/mutex.cpp

Print this page

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

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

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