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