src/hotspot/share/runtime/mutex.cpp
changeset 57840 4863a802a7c1
parent 57751 7284b00e6db3
child 58291 a013100f7a35
equal deleted inserted replaced
57831:d41c18a68257 57840:4863a802a7c1
    31 #include "runtime/thread.inline.hpp"
    31 #include "runtime/thread.inline.hpp"
    32 #include "utilities/events.hpp"
    32 #include "utilities/events.hpp"
    33 #include "utilities/macros.hpp"
    33 #include "utilities/macros.hpp"
    34 
    34 
    35 #ifdef ASSERT
    35 #ifdef ASSERT
    36 void Monitor::check_safepoint_state(Thread* thread, bool do_safepoint_check) {
    36 void Mutex::check_safepoint_state(Thread* thread, bool do_safepoint_check) {
    37   // If the JavaThread checks for safepoint, verify that the lock wasn't created with safepoint_check_never.
    37   // If the JavaThread checks for safepoint, verify that the lock wasn't created with safepoint_check_never.
    38   SafepointCheckRequired not_allowed = do_safepoint_check ?  Monitor::_safepoint_check_never :
    38   SafepointCheckRequired not_allowed = do_safepoint_check ?  Mutex::_safepoint_check_never :
    39                                                              Monitor::_safepoint_check_always;
    39                                                              Mutex::_safepoint_check_always;
    40   assert(!thread->is_active_Java_thread() || _safepoint_check_required != not_allowed,
    40   assert(!thread->is_active_Java_thread() || _safepoint_check_required != not_allowed,
    41          "This lock should %s have a safepoint check for Java threads: %s",
    41          "This lock should %s have a safepoint check for Java threads: %s",
    42          _safepoint_check_required ? "always" : "never", name());
    42          _safepoint_check_required ? "always" : "never", name());
    43 
    43 
    44   // If defined with safepoint_check_never, a NonJavaThread should never ask to safepoint check either.
    44   // If defined with safepoint_check_never, a NonJavaThread should never ask to safepoint check either.
    45   assert(thread->is_Java_thread() || !do_safepoint_check || _safepoint_check_required != Monitor::_safepoint_check_never,
    45   assert(thread->is_Java_thread() || !do_safepoint_check || _safepoint_check_required != Mutex::_safepoint_check_never,
    46          "NonJavaThread should not check for safepoint");
    46          "NonJavaThread should not check for safepoint");
    47 }
    47 }
    48 #endif // ASSERT
    48 #endif // ASSERT
    49 
    49 
    50 void Monitor::lock(Thread * self) {
    50 void Mutex::lock(Thread * self) {
    51   check_safepoint_state(self, true);
    51   check_safepoint_state(self, true);
    52 
    52 
    53   DEBUG_ONLY(check_prelock_state(self, true));
    53   DEBUG_ONLY(check_prelock_state(self, true));
    54   assert(_owner != self, "invariant");
    54   assert(_owner != self, "invariant");
    55 
    55 
    56   Monitor* in_flight_monitor = NULL;
    56   Mutex* in_flight_mutex = NULL;
    57   DEBUG_ONLY(int retry_cnt = 0;)
    57   DEBUG_ONLY(int retry_cnt = 0;)
    58   bool is_active_Java_thread = self->is_active_Java_thread();
    58   bool is_active_Java_thread = self->is_active_Java_thread();
    59   while (!_lock.try_lock()) {
    59   while (!_lock.try_lock()) {
    60     // The lock is contended
    60     // The lock is contended
    61 
    61 
    62   #ifdef ASSERT
    62   #ifdef ASSERT
    63     check_block_state(self);
    63     check_block_state(self);
    64     if (retry_cnt++ > 3) {
    64     if (retry_cnt++ > 3) {
    65       log_trace(vmmonitor)("JavaThread " INTPTR_FORMAT " on %d attempt trying to acquire vmmonitor %s", p2i(self), retry_cnt, _name);
    65       log_trace(vmmutex)("JavaThread " INTPTR_FORMAT " on %d attempt trying to acquire vmmutex %s", p2i(self), retry_cnt, _name);
    66     }
    66     }
    67   #endif // ASSERT
    67   #endif // ASSERT
    68 
    68 
    69     // Is it a JavaThread participating in the safepoint protocol.
    69     // Is it a JavaThread participating in the safepoint protocol.
    70     if (is_active_Java_thread) {
    70     if (is_active_Java_thread) {
    71       assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
    71       assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
    72       { ThreadBlockInVMWithDeadlockCheck tbivmdc((JavaThread *) self, &in_flight_monitor);
    72       { ThreadBlockInVMWithDeadlockCheck tbivmdc((JavaThread *) self, &in_flight_mutex);
    73         in_flight_monitor = this;  // save for ~ThreadBlockInVMWithDeadlockCheck
    73         in_flight_mutex = this;  // save for ~ThreadBlockInVMWithDeadlockCheck
    74         _lock.lock();
    74         _lock.lock();
    75       }
    75       }
    76       if (in_flight_monitor != NULL) {
    76       if (in_flight_mutex != NULL) {
    77         // Not unlocked by ~ThreadBlockInVMWithDeadlockCheck
    77         // Not unlocked by ~ThreadBlockInVMWithDeadlockCheck
    78         break;
    78         break;
    79       }
    79       }
    80     } else {
    80     } else {
    81       _lock.lock();
    81       _lock.lock();
    85 
    85 
    86   assert_owner(NULL);
    86   assert_owner(NULL);
    87   set_owner(self);
    87   set_owner(self);
    88 }
    88 }
    89 
    89 
    90 void Monitor::lock() {
    90 void Mutex::lock() {
    91   this->lock(Thread::current());
    91   this->lock(Thread::current());
    92 }
    92 }
    93 
    93 
    94 // Lock without safepoint check - a degenerate variant of lock() for use by
    94 // Lock without safepoint check - a degenerate variant of lock() for use by
    95 // JavaThreads when it is known to be safe to not check for a safepoint when
    95 // JavaThreads when it is known to be safe to not check for a safepoint when
    96 // acquiring this lock. If the thread blocks acquiring the lock it is not
    96 // acquiring this lock. If the thread blocks acquiring the lock it is not
    97 // safepoint-safe and so will prevent a safepoint from being reached. If used
    97 // safepoint-safe and so will prevent a safepoint from being reached. If used
    98 // in the wrong way this can lead to a deadlock with the safepoint code.
    98 // in the wrong way this can lead to a deadlock with the safepoint code.
    99 
    99 
   100 void Monitor::lock_without_safepoint_check(Thread * self) {
   100 void Mutex::lock_without_safepoint_check(Thread * self) {
   101   check_safepoint_state(self, false);
   101   check_safepoint_state(self, false);
   102   assert(_owner != self, "invariant");
   102   assert(_owner != self, "invariant");
   103   _lock.lock();
   103   _lock.lock();
   104   assert_owner(NULL);
   104   assert_owner(NULL);
   105   set_owner(self);
   105   set_owner(self);
   106 }
   106 }
   107 
   107 
   108 void Monitor::lock_without_safepoint_check() {
   108 void Mutex::lock_without_safepoint_check() {
   109   lock_without_safepoint_check(Thread::current());
   109   lock_without_safepoint_check(Thread::current());
   110 }
   110 }
   111 
   111 
   112 
   112 
   113 // Returns true if thread succeeds in grabbing the lock, otherwise false.
   113 // Returns true if thread succeeds in grabbing the lock, otherwise false.
   114 
   114 
   115 bool Monitor::try_lock() {
   115 bool Mutex::try_lock() {
   116   Thread * const self = Thread::current();
   116   Thread * const self = Thread::current();
   117   DEBUG_ONLY(check_prelock_state(self, false);)
   117   DEBUG_ONLY(check_prelock_state(self, false);)
   118 
   118 
   119   if (_lock.try_lock()) {
   119   if (_lock.try_lock()) {
   120     assert_owner(NULL);
   120     assert_owner(NULL);
   122     return true;
   122     return true;
   123   }
   123   }
   124   return false;
   124   return false;
   125 }
   125 }
   126 
   126 
   127 void Monitor::release_for_safepoint() {
   127 void Mutex::release_for_safepoint() {
   128   assert_owner(NULL);
   128   assert_owner(NULL);
   129   _lock.unlock();
   129   _lock.unlock();
   130 }
   130 }
   131 
   131 
   132 void Monitor::unlock() {
   132 void Mutex::unlock() {
   133   assert_owner(Thread::current());
   133   assert_owner(Thread::current());
   134   set_owner(NULL);
   134   set_owner(NULL);
   135   _lock.unlock();
   135   _lock.unlock();
   136 }
   136 }
   137 
   137 
   145   _lock.notify_all();
   145   _lock.notify_all();
   146 }
   146 }
   147 
   147 
   148 #ifdef ASSERT
   148 #ifdef ASSERT
   149 void Monitor::assert_wait_lock_state(Thread* self) {
   149 void Monitor::assert_wait_lock_state(Thread* self) {
   150   Monitor* least = get_least_ranked_lock_besides_this(self->owned_locks());
   150   Mutex* least = get_least_ranked_lock_besides_this(self->owned_locks());
   151   assert(least != this, "Specification of get_least_... call above");
   151   assert(least != this, "Specification of get_least_... call above");
   152   if (least != NULL && least->rank() <= special) {
   152   if (least != NULL && least->rank() <= special) {
   153     ::tty->print("Attempting to wait on monitor %s/%d while holding"
   153     ::tty->print("Attempting to wait on monitor %s/%d while holding"
   154                " lock %s/%d -- possible deadlock",
   154                " lock %s/%d -- possible deadlock",
   155                name(), rank(), least->name(), least->rank());
   155                name(), rank(), least->name(), least->rank());
   192   int wait_status;
   192   int wait_status;
   193   // conceptually set the owner to NULL in anticipation of
   193   // conceptually set the owner to NULL in anticipation of
   194   // abdicating the lock in wait
   194   // abdicating the lock in wait
   195   set_owner(NULL);
   195   set_owner(NULL);
   196   JavaThread *jt = (JavaThread *)self;
   196   JavaThread *jt = (JavaThread *)self;
   197   Monitor* in_flight_monitor = NULL;
   197   Mutex* in_flight_mutex = NULL;
   198 
   198 
   199   {
   199   {
   200     ThreadBlockInVMWithDeadlockCheck tbivmdc(jt, &in_flight_monitor);
   200     ThreadBlockInVMWithDeadlockCheck tbivmdc(jt, &in_flight_mutex);
   201     OSThreadWaitState osts(self->osthread(), false /* not Object.wait() */);
   201     OSThreadWaitState osts(self->osthread(), false /* not Object.wait() */);
   202     if (as_suspend_equivalent) {
   202     if (as_suspend_equivalent) {
   203       jt->set_suspend_equivalent();
   203       jt->set_suspend_equivalent();
   204       // cleared by handle_special_suspend_equivalent_condition() or
   204       // cleared by handle_special_suspend_equivalent_condition() or
   205       // java_suspend_self()
   205       // java_suspend_self()
   206     }
   206     }
   207 
   207 
   208     wait_status = _lock.wait(timeout);
   208     wait_status = _lock.wait(timeout);
   209     in_flight_monitor = this;  // save for ~ThreadBlockInVMWithDeadlockCheck
   209     in_flight_mutex = this;  // save for ~ThreadBlockInVMWithDeadlockCheck
   210 
   210 
   211     // were we externally suspended while we were waiting?
   211     // were we externally suspended while we were waiting?
   212     if (as_suspend_equivalent && jt->handle_special_suspend_equivalent_condition()) {
   212     if (as_suspend_equivalent && jt->handle_special_suspend_equivalent_condition()) {
   213       // Our event wait has finished and we own the lock, but
   213       // Our event wait has finished and we own the lock, but
   214       // while we were waiting another thread suspended us. We don't
   214       // while we were waiting another thread suspended us. We don't
   218       jt->java_suspend_self();
   218       jt->java_suspend_self();
   219       _lock.lock();
   219       _lock.lock();
   220     }
   220     }
   221   }
   221   }
   222 
   222 
   223   if (in_flight_monitor != NULL) {
   223   if (in_flight_mutex != NULL) {
   224     // Not unlocked by ~ThreadBlockInVMWithDeadlockCheck
   224     // Not unlocked by ~ThreadBlockInVMWithDeadlockCheck
   225     assert_owner(NULL);
   225     assert_owner(NULL);
   226     // Conceptually reestablish ownership of the lock.
   226     // Conceptually reestablish ownership of the lock.
   227     set_owner(self);
   227     set_owner(self);
   228   } else {
   228   } else {
   230   }
   230   }
   231 
   231 
   232   return wait_status != 0;          // return true IFF timeout
   232   return wait_status != 0;          // return true IFF timeout
   233 }
   233 }
   234 
   234 
   235 Monitor::~Monitor() {
   235 Mutex::~Mutex() {
   236   assert_owner(NULL);
   236   assert_owner(NULL);
   237 }
   237 }
   238 
   238 
   239 // Only Threads_lock, Heap_lock and SR_lock may be safepoint_check_sometimes.
   239 // Only Threads_lock, Heap_lock and SR_lock may be safepoint_check_sometimes.
   240 bool is_sometimes_ok(const char* name) {
   240 bool is_sometimes_ok(const char* name) {
   241   return (strcmp(name, "Threads_lock") == 0 || strcmp(name, "Heap_lock") == 0 || strcmp(name, "SR_lock") == 0);
   241   return (strcmp(name, "Threads_lock") == 0 || strcmp(name, "Heap_lock") == 0 || strcmp(name, "SR_lock") == 0);
   242 }
   242 }
   243 
   243 
   244 Monitor::Monitor(int Rank, const char * name, bool allow_vm_block,
   244 Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
   245                  SafepointCheckRequired safepoint_check_required) : _owner(NULL) {
   245              SafepointCheckRequired safepoint_check_required) : _owner(NULL) {
   246   assert(os::mutex_init_done(), "Too early!");
   246   assert(os::mutex_init_done(), "Too early!");
   247   if (name == NULL) {
   247   if (name == NULL) {
   248     strcpy(_name, "UNKNOWN");
   248     strcpy(_name, "UNKNOWN");
   249   } else {
   249   } else {
   250     strncpy(_name, name, MONITOR_NAME_LEN - 1);
   250     strncpy(_name, name, MUTEX_NAME_LEN - 1);
   251     _name[MONITOR_NAME_LEN - 1] = '\0';
   251     _name[MUTEX_NAME_LEN - 1] = '\0';
   252   }
   252   }
   253 #ifdef ASSERT
   253 #ifdef ASSERT
   254   _allow_vm_block  = allow_vm_block;
   254   _allow_vm_block  = allow_vm_block;
   255   _rank            = Rank;
   255   _rank            = Rank;
   256   _safepoint_check_required = safepoint_check_required;
   256   _safepoint_check_required = safepoint_check_required;
   257 
   257 
   258   assert(_safepoint_check_required != Monitor::_safepoint_check_sometimes || is_sometimes_ok(name),
   258   assert(_safepoint_check_required != Mutex::_safepoint_check_sometimes || is_sometimes_ok(name),
   259          "Lock has _safepoint_check_sometimes %s", name);
   259          "Lock has _safepoint_check_sometimes %s", name);
   260 #endif
   260 #endif
   261 }
   261 }
   262 
   262 
   263 Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
   263 Monitor::Monitor(int Rank, const char * name, bool allow_vm_block,
   264              SafepointCheckRequired safepoint_check_required) :
   264              SafepointCheckRequired safepoint_check_required) :
   265   Monitor(Rank, name, allow_vm_block, safepoint_check_required) {}
   265   Mutex(Rank, name, allow_vm_block, safepoint_check_required) {}
   266 
   266 
   267 bool Monitor::owned_by_self() const {
   267 bool Mutex::owned_by_self() const {
   268   return _owner == Thread::current();
   268   return _owner == Thread::current();
   269 }
   269 }
   270 
   270 
   271 void Monitor::print_on_error(outputStream* st) const {
   271 void Mutex::print_on_error(outputStream* st) const {
   272   st->print("[" PTR_FORMAT, p2i(this));
   272   st->print("[" PTR_FORMAT, p2i(this));
   273   st->print("] %s", _name);
   273   st->print("] %s", _name);
   274   st->print(" - owner thread: " PTR_FORMAT, p2i(_owner));
   274   st->print(" - owner thread: " PTR_FORMAT, p2i(_owner));
   275 }
   275 }
   276 
   276 
   277 // ----------------------------------------------------------------------------------
   277 // ----------------------------------------------------------------------------------
   278 // Non-product code
   278 // Non-product code
   279 
   279 
   280 #ifndef PRODUCT
   280 #ifndef PRODUCT
   281 void Monitor::print_on(outputStream* st) const {
   281 void Mutex::print_on(outputStream* st) const {
   282   st->print_cr("Mutex: [" PTR_FORMAT "] %s - owner: " PTR_FORMAT,
   282   st->print_cr("Mutex: [" PTR_FORMAT "] %s - owner: " PTR_FORMAT,
   283                p2i(this), _name, p2i(_owner));
   283                p2i(this), _name, p2i(_owner));
   284 }
   284 }
   285 #endif
   285 #endif
   286 
   286 
   287 #ifndef PRODUCT
   287 #ifndef PRODUCT
   288 #ifdef ASSERT
   288 #ifdef ASSERT
   289 
   289 
   290 void Monitor::assert_owner(Thread * expected) {
   290 void Mutex::assert_owner(Thread * expected) {
   291   const char* msg = "invalid owner";
   291   const char* msg = "invalid owner";
   292   if (expected == NULL) {
   292   if (expected == NULL) {
   293     msg = "should be un-owned";
   293     msg = "should be un-owned";
   294   }
   294   }
   295   else if (expected == Thread::current()) {
   295   else if (expected == Thread::current()) {
   298   assert(_owner == expected,
   298   assert(_owner == expected,
   299          "%s: owner=" INTPTR_FORMAT ", should be=" INTPTR_FORMAT,
   299          "%s: owner=" INTPTR_FORMAT ", should be=" INTPTR_FORMAT,
   300          msg, p2i(_owner), p2i(expected));
   300          msg, p2i(_owner), p2i(expected));
   301 }
   301 }
   302 
   302 
   303 Monitor * Monitor::get_least_ranked_lock(Monitor * locks) {
   303 Mutex* Mutex::get_least_ranked_lock(Mutex* locks) {
   304   Monitor *res, *tmp;
   304   Mutex *res, *tmp;
   305   for (res = tmp = locks; tmp != NULL; tmp = tmp->next()) {
   305   for (res = tmp = locks; tmp != NULL; tmp = tmp->next()) {
   306     if (tmp->rank() < res->rank()) {
   306     if (tmp->rank() < res->rank()) {
   307       res = tmp;
   307       res = tmp;
   308     }
   308     }
   309   }
   309   }
   318     }
   318     }
   319   }
   319   }
   320   return res;
   320   return res;
   321 }
   321 }
   322 
   322 
   323 Monitor* Monitor::get_least_ranked_lock_besides_this(Monitor* locks) {
   323 Mutex* Mutex::get_least_ranked_lock_besides_this(Mutex* locks) {
   324   Monitor *res, *tmp;
   324   Mutex *res, *tmp;
   325   for (res = NULL, tmp = locks; tmp != NULL; tmp = tmp->next()) {
   325   for (res = NULL, tmp = locks; tmp != NULL; tmp = tmp->next()) {
   326     if (tmp != this && (res == NULL || tmp->rank() < res->rank())) {
   326     if (tmp != this && (res == NULL || tmp->rank() < res->rank())) {
   327       res = tmp;
   327       res = tmp;
   328     }
   328     }
   329   }
   329   }
   339   }
   339   }
   340   return res;
   340   return res;
   341 }
   341 }
   342 
   342 
   343 
   343 
   344 bool Monitor::contains(Monitor* locks, Monitor * lock) {
   344 bool Mutex::contains(Mutex* locks, Mutex* lock) {
   345   for (; locks != NULL; locks = locks->next()) {
   345   for (; locks != NULL; locks = locks->next()) {
   346     if (locks == lock) {
   346     if (locks == lock) {
   347       return true;
   347       return true;
   348     }
   348     }
   349   }
   349   }
   354 // Called immediately after lock acquisition or release as a diagnostic
   354 // Called immediately after lock acquisition or release as a diagnostic
   355 // to track the lock-set of the thread and test for rank violations that
   355 // to track the lock-set of the thread and test for rank violations that
   356 // might indicate exposure to deadlock.
   356 // might indicate exposure to deadlock.
   357 // Rather like an EventListener for _owner (:>).
   357 // Rather like an EventListener for _owner (:>).
   358 
   358 
   359 void Monitor::set_owner_implementation(Thread *new_owner) {
   359 void Mutex::set_owner_implementation(Thread *new_owner) {
   360   // This function is solely responsible for maintaining
   360   // This function is solely responsible for maintaining
   361   // and checking the invariant that threads and locks
   361   // and checking the invariant that threads and locks
   362   // are in a 1/N relation, with some some locks unowned.
   362   // are in a 1/N relation, with some some locks unowned.
   363   // It uses the Mutex::_owner, Mutex::_next, and
   363   // It uses the Mutex::_owner, Mutex::_next, and
   364   // Thread::_owned_locks fields, and no other function
   364   // Thread::_owned_locks fields, and no other function
   375     _owner = new_owner; // set the owner
   375     _owner = new_owner; // set the owner
   376 
   376 
   377     // link "this" into the owned locks list
   377     // link "this" into the owned locks list
   378 
   378 
   379 #ifdef ASSERT  // Thread::_owned_locks is under the same ifdef
   379 #ifdef ASSERT  // Thread::_owned_locks is under the same ifdef
   380     Monitor* locks = get_least_ranked_lock(new_owner->owned_locks());
   380     Mutex* locks = get_least_ranked_lock(new_owner->owned_locks());
   381     // Mutex::set_owner_implementation is a friend of Thread
   381     // Mutex::set_owner_implementation is a friend of Thread
   382 
   382 
   383     assert(this->rank() >= 0, "bad lock rank");
   383     assert(this->rank() >= 0, "bad lock rank");
   384 
   384 
   385     // Deadlock avoidance rules require us to acquire Mutexes only in
   385     // Deadlock avoidance rules require us to acquire Mutexes only in
   413     assert(old_owner == Thread::current(), "removing the owner thread of an unowned mutex");
   413     assert(old_owner == Thread::current(), "removing the owner thread of an unowned mutex");
   414 
   414 
   415     _owner = NULL; // set the owner
   415     _owner = NULL; // set the owner
   416 
   416 
   417 #ifdef ASSERT
   417 #ifdef ASSERT
   418     Monitor *locks = old_owner->owned_locks();
   418     Mutex* locks = old_owner->owned_locks();
   419 
   419 
   420     // remove "this" from the owned locks list
   420     // remove "this" from the owned locks list
   421 
   421 
   422     Monitor *prev = NULL;
   422     Mutex* prev = NULL;
   423     bool found = false;
   423     bool found = false;
   424     for (; locks != NULL; prev = locks, locks = locks->next()) {
   424     for (; locks != NULL; prev = locks, locks = locks->next()) {
   425       if (locks == this) {
   425       if (locks == this) {
   426         found = true;
   426         found = true;
   427         break;
   427         break;
   438   }
   438   }
   439 }
   439 }
   440 
   440 
   441 
   441 
   442 // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock()
   442 // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock()
   443 void Monitor::check_prelock_state(Thread *thread, bool safepoint_check) {
   443 void Mutex::check_prelock_state(Thread *thread, bool safepoint_check) {
   444   if (safepoint_check) {
   444   if (safepoint_check) {
   445     assert((!thread->is_active_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm)
   445     assert((!thread->is_active_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm)
   446            || rank() == Mutex::special, "wrong thread state for using locks");
   446            || rank() == Mutex::special, "wrong thread state for using locks");
   447     if (thread->is_VM_thread() && !allow_vm_block()) {
   447     if (thread->is_VM_thread() && !allow_vm_block()) {
   448       fatal("VM thread using lock %s (not allowed to block on)", name());
   448       fatal("VM thread using lock %s (not allowed to block on)", name());
   452   }
   452   }
   453   assert(!os::ThreadCrashProtection::is_crash_protected(thread),
   453   assert(!os::ThreadCrashProtection::is_crash_protected(thread),
   454          "locking not allowed when crash protection is set");
   454          "locking not allowed when crash protection is set");
   455 }
   455 }
   456 
   456 
   457 void Monitor::check_block_state(Thread *thread) {
   457 void Mutex::check_block_state(Thread *thread) {
   458   if (!_allow_vm_block && thread->is_VM_thread()) {
   458   if (!_allow_vm_block && thread->is_VM_thread()) {
   459     warning("VM thread blocked on lock");
   459     warning("VM thread blocked on lock");
   460     print();
   460     print();
   461     BREAKPOINT;
   461     BREAKPOINT;
   462   }
   462   }
   463   assert(_owner != thread, "deadlock: blocking on monitor owned by current thread");
   463   assert(_owner != thread, "deadlock: blocking on mutex owned by current thread");
   464 }
   464 }
   465 
   465 
   466 #endif // PRODUCT
   466 #endif // PRODUCT