8203817: Monitor::try_lock() should not call check_prelock_state()
Reviewed-by: dholmes, eosterlund, rehn
--- 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());
}
--- 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_<os_family>.cpp)