8264742: member variable _monitor of MonitorLocker is redundant

Reviewed-by: coleenp, dholmes, phh
This commit is contained in:
Xin Liu 2021-04-07 17:51:25 +00:00 committed by Paul Hohensee
parent 7a99a9874b
commit 774e5ae009

View file

@ -198,7 +198,6 @@ void assert_locked_or_safepoint_or_handshake(const Mutex* lock, const JavaThread
class MutexLocker: public StackObj {
protected:
Mutex* _mutex;
private:
public:
MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
_mutex(mutex) {
@ -242,36 +241,41 @@ class MutexLocker: public StackObj {
class MonitorLocker: public MutexLocker {
Mutex::SafepointCheckFlag _flag;
Monitor* _monitor;
protected:
Monitor* as_monitor() const {
return static_cast<Monitor*>(_mutex);
}
public:
MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
MutexLocker(monitor, flag), _flag(flag), _monitor(monitor) {
MutexLocker(monitor, flag), _flag(flag) {
// Superclass constructor did locking
assert(_monitor != NULL, "NULL monitor not allowed");
assert(monitor != NULL, "NULL monitor not allowed");
}
MonitorLocker(Thread* thread, Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) :
MutexLocker(thread, monitor, flag), _flag(flag), _monitor(monitor) {
MutexLocker(thread, monitor, flag), _flag(flag) {
// Superclass constructor did locking
assert(_monitor != NULL, "NULL monitor not allowed");
assert(monitor != NULL, "NULL monitor not allowed");
}
bool wait(int64_t timeout = 0,
bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
if (_flag == Mutex::_safepoint_check_flag) {
return _monitor->wait(timeout, as_suspend_equivalent);
return as_monitor()->wait(timeout, as_suspend_equivalent);
} else {
return _monitor->wait_without_safepoint_check(timeout);
return as_monitor()->wait_without_safepoint_check(timeout);
}
return false;
}
void notify_all() {
_monitor->notify_all();
as_monitor()->notify_all();
}
void notify() {
_monitor->notify();
as_monitor()->notify();
}
};