8203817: Monitor::try_lock() should not call check_prelock_state()

Reviewed-by: dholmes, eosterlund, rehn
This commit is contained in:
Per Lidén 2018-05-28 09:59:11 +02:00
parent e1c94920e5
commit d830d47d91
2 changed files with 7 additions and 7 deletions

View File

@ -903,7 +903,7 @@ void Monitor::lock(Thread * Self) {
} }
#endif // CHECK_UNHANDLED_OOPS #endif // CHECK_UNHANDLED_OOPS
debug_only(check_prelock_state(Self)); debug_only(check_prelock_state(Self, StrictSafepointChecks));
assert(_owner != Self, "invariant"); assert(_owner != Self, "invariant");
assert(_OnDeck != Self->_MutexEvent, "invariant"); assert(_OnDeck != Self->_MutexEvent, "invariant");
@ -971,7 +971,7 @@ void Monitor::lock_without_safepoint_check() {
bool Monitor::try_lock() { bool Monitor::try_lock() {
Thread * const Self = Thread::current(); 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"); // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler");
// Special case, where all Java threads are stopped. // Special case, where all Java threads are stopped.
@ -1381,10 +1381,10 @@ void Monitor::set_owner_implementation(Thread *new_owner) {
// Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock() // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock()
void Monitor::check_prelock_state(Thread *thread) { void Monitor::check_prelock_state(Thread *thread, bool safepoint_check) {
assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm) if (safepoint_check) {
|| rank() == Mutex::special, "wrong thread state for using locks"); assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm)
if (StrictSafepointChecks) { || rank() == Mutex::special, "wrong thread state for using locks");
if (thread->is_VM_thread() && !allow_vm_block()) { if (thread->is_VM_thread() && !allow_vm_block()) {
fatal("VM thread using lock %s (not allowed to block on)", name()); fatal("VM thread using lock %s (not allowed to block on)", name());
} }

View File

@ -144,7 +144,7 @@ class Monitor : public CHeapObj<mtInternal> {
#endif #endif
void set_owner_implementation(Thread* owner) PRODUCT_RETURN; 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; void check_block_state (Thread* thread) PRODUCT_RETURN;
// platform-dependent support code can go here (in os_<os_family>.cpp) // platform-dependent support code can go here (in os_<os_family>.cpp)