# HG changeset patch # User pliden # Date 1527494351 -7200 # Node ID 5aaf3a471172cb0d6b22fd1df0d0a6d7dbd966b6 # Parent 197ee9d8e228dad321e410fce619c55d026ded52 8203817: Monitor::try_lock() should not call check_prelock_state() Reviewed-by: dholmes, eosterlund, rehn diff -r 197ee9d8e228 -r 5aaf3a471172 src/hotspot/share/runtime/mutex.cpp --- a/src/hotspot/share/runtime/mutex.cpp Mon May 28 09:05:43 2018 +0200 +++ b/src/hotspot/share/runtime/mutex.cpp Mon May 28 09:59:11 2018 +0200 @@ -903,7 +903,7 @@ } #endif // CHECK_UNHANDLED_OOPS - debug_only(check_prelock_state(Self)); + debug_only(check_prelock_state(Self, StrictSafepointChecks)); assert(_owner != Self, "invariant"); assert(_OnDeck != Self->_MutexEvent, "invariant"); @@ -971,7 +971,7 @@ bool Monitor::try_lock() { Thread * const Self = Thread::current(); - debug_only(check_prelock_state(Self)); + debug_only(check_prelock_state(Self, false)); // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler"); // Special case, where all Java threads are stopped. @@ -1381,10 +1381,10 @@ // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock() -void Monitor::check_prelock_state(Thread *thread) { - assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm) - || rank() == Mutex::special, "wrong thread state for using locks"); - if (StrictSafepointChecks) { +void Monitor::check_prelock_state(Thread *thread, bool safepoint_check) { + if (safepoint_check) { + assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm) + || rank() == Mutex::special, "wrong thread state for using locks"); if (thread->is_VM_thread() && !allow_vm_block()) { fatal("VM thread using lock %s (not allowed to block on)", name()); } diff -r 197ee9d8e228 -r 5aaf3a471172 src/hotspot/share/runtime/mutex.hpp --- a/src/hotspot/share/runtime/mutex.hpp Mon May 28 09:05:43 2018 +0200 +++ b/src/hotspot/share/runtime/mutex.hpp Mon May 28 09:59:11 2018 +0200 @@ -144,7 +144,7 @@ #endif void set_owner_implementation(Thread* owner) PRODUCT_RETURN; - void check_prelock_state (Thread* thread) PRODUCT_RETURN; + void check_prelock_state (Thread* thread, bool safepoint_check) PRODUCT_RETURN; void check_block_state (Thread* thread) PRODUCT_RETURN; // platform-dependent support code can go here (in os_.cpp)