8213708: Different #ifdef guards cause incorrect use of Monitor::check_block_state()
Wrapped check_block_state() method in DEBUG_ONLY macro and make the use of the latter more consistent Reviewed-by: dcubed, dholmes
This commit is contained in:
parent
028f2e14b3
commit
98d92b0b6b
@ -875,7 +875,7 @@ void Monitor::lock(Thread * Self) {
|
||||
}
|
||||
#endif // CHECK_UNHANDLED_OOPS
|
||||
|
||||
debug_only(check_prelock_state(Self, StrictSafepointChecks));
|
||||
DEBUG_ONLY(check_prelock_state(Self, StrictSafepointChecks);)
|
||||
assert(_owner != Self, "invariant");
|
||||
assert(_OnDeck != Self->_MutexEvent, "invariant");
|
||||
|
||||
@ -902,7 +902,7 @@ void Monitor::lock(Thread * Self) {
|
||||
// Try a brief spin to avoid passing thru thread state transition ...
|
||||
if (TrySpin(Self)) goto Exeunt;
|
||||
|
||||
check_block_state(Self);
|
||||
DEBUG_ONLY(check_block_state(Self);)
|
||||
if (Self->is_Java_thread()) {
|
||||
// Horrible dictu - we suffer through a state transition
|
||||
assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
|
||||
@ -943,7 +943,7 @@ void Monitor::lock_without_safepoint_check() {
|
||||
|
||||
bool Monitor::try_lock() {
|
||||
Thread * const Self = Thread::current();
|
||||
debug_only(check_prelock_state(Self, false));
|
||||
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.
|
||||
@ -1320,7 +1320,7 @@ void Monitor::set_owner_implementation(Thread *new_owner) {
|
||||
// the thread is releasing this lock
|
||||
|
||||
Thread* old_owner = _owner;
|
||||
debug_only(_last_owner = old_owner);
|
||||
DEBUG_ONLY(_last_owner = old_owner;)
|
||||
|
||||
assert(old_owner != NULL, "removing the owner thread of an unowned mutex");
|
||||
assert(old_owner == Thread::current(), "removing the owner thread of an unowned mutex");
|
||||
@ -1360,7 +1360,7 @@ void Monitor::check_prelock_state(Thread *thread, bool safepoint_check) {
|
||||
if (thread->is_VM_thread() && !allow_vm_block()) {
|
||||
fatal("VM thread using lock %s (not allowed to block on)", name());
|
||||
}
|
||||
debug_only(if (rank() != Mutex::special) \
|
||||
DEBUG_ONLY(if (rank() != Mutex::special) \
|
||||
thread->check_for_valid_safepoint_state(false);)
|
||||
}
|
||||
assert(!os::ThreadCrashProtection::is_crash_protected(thread),
|
||||
|
@ -135,12 +135,12 @@ class Monitor : public CHeapObj<mtInternal> {
|
||||
// Debugging fields for naming, deadlock detection, etc. (some only used in debug mode)
|
||||
#ifndef PRODUCT
|
||||
bool _allow_vm_block;
|
||||
debug_only(int _rank;) // rank (to avoid/detect potential deadlocks)
|
||||
debug_only(Monitor * _next;) // Used by a Thread to link up owned locks
|
||||
debug_only(Thread* _last_owner;) // the last thread to own the lock
|
||||
debug_only(static bool contains(Monitor * locks, Monitor * lock);)
|
||||
debug_only(static Monitor * get_least_ranked_lock(Monitor * locks);)
|
||||
debug_only(Monitor * get_least_ranked_lock_besides_this(Monitor * locks);)
|
||||
DEBUG_ONLY(int _rank;) // rank (to avoid/detect potential deadlocks)
|
||||
DEBUG_ONLY(Monitor * _next;) // Used by a Thread to link up owned locks
|
||||
DEBUG_ONLY(Thread* _last_owner;) // the last thread to own the lock
|
||||
DEBUG_ONLY(static bool contains(Monitor * locks, Monitor * lock);)
|
||||
DEBUG_ONLY(static Monitor * get_least_ranked_lock(Monitor * locks);)
|
||||
DEBUG_ONLY(Monitor * get_least_ranked_lock_besides_this(Monitor * locks);)
|
||||
#endif
|
||||
|
||||
void set_owner_implementation(Thread* owner) PRODUCT_RETURN;
|
||||
@ -237,17 +237,17 @@ class Monitor : public CHeapObj<mtInternal> {
|
||||
#ifndef PRODUCT
|
||||
void print_on(outputStream* st) const;
|
||||
void print() const { print_on(tty); }
|
||||
debug_only(int rank() const { return _rank; })
|
||||
DEBUG_ONLY(int rank() const { return _rank; })
|
||||
bool allow_vm_block() { return _allow_vm_block; }
|
||||
|
||||
debug_only(Monitor *next() const { return _next; })
|
||||
debug_only(void set_next(Monitor *next) { _next = next; })
|
||||
DEBUG_ONLY(Monitor *next() const { return _next; })
|
||||
DEBUG_ONLY(void set_next(Monitor *next) { _next = next; })
|
||||
#endif
|
||||
|
||||
void set_owner(Thread* owner) {
|
||||
#ifndef PRODUCT
|
||||
set_owner_implementation(owner);
|
||||
debug_only(void verify_Monitor(Thread* thr));
|
||||
DEBUG_ONLY(void verify_Monitor(Thread* thr);)
|
||||
#else
|
||||
_owner = owner;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user