8322853: Should use ConditionalMutexLocker in NativeHeapTrimmerThread::print_state

Reviewed-by: dholmes, shade
This commit is contained in:
Denghui Dong 2024-01-03 13:10:22 +00:00
parent 539da24863
commit 7eb25ec7b3

View File

@ -71,11 +71,6 @@ class NativeHeapTrimmerThread : public NamedThread {
return --_suspend_count;
}
bool is_stopped() const {
assert(_lock->is_locked(), "Must be");
return _stop;
}
bool at_or_nearing_safepoint() const {
return SafepointSynchronize::is_at_safepoint() ||
SafepointSynchronize::is_synchronizing();
@ -215,13 +210,12 @@ public:
}
void print_state(outputStream* st) const {
// Don't pull lock during error reporting
Mutex* const lock = VMError::is_error_reported() ? nullptr : _lock;
int64_t num_trims = 0;
bool stopped = false;
uint16_t suspenders = 0;
{
MutexLocker ml(lock, Mutex::_no_safepoint_check_flag);
// Don't pull lock during error reporting
ConditionalMutexLocker ml(_lock, !VMError::is_error_reported(), Mutex::_no_safepoint_check_flag);
num_trims = _num_trims_performed;
stopped = _stop;
suspenders = _suspend_count;