8333716: Shenandoah: Check for disarmed method before taking the nmethod lock

Reviewed-by: shade, ysr, wkemper
This commit is contained in:
Neethu Prasad 2024-06-07 20:03:10 +00:00 committed by Paul Hohensee
parent c37d02aef3
commit 18e7d7b5e7

View File

@ -36,13 +36,19 @@
#include "runtime/threadWXSetters.inline.hpp"
bool ShenandoahBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
if (!is_armed(nm)) {
// Some other thread got here first and healed the oops
// and disarmed the nmethod. No need to continue.
return true;
}
ShenandoahReentrantLock* lock = ShenandoahNMethod::lock_for_nmethod(nm);
assert(lock != nullptr, "Must be");
ShenandoahReentrantLocker locker(lock);
if (!is_armed(nm)) {
// Some other thread got here first and healed the oops
// and disarmed the nmethod.
// Some other thread managed to complete while we were
// waiting for lock. No need to continue.
return true;
}