diff --git a/src/hotspot/share/gc/z/zNMethodTable.cpp b/src/hotspot/share/gc/z/zNMethodTable.cpp index 5971954..c7d6261 100644 --- a/src/hotspot/share/gc/z/zNMethodTable.cpp +++ b/src/hotspot/share/gc/z/zNMethodTable.cpp @@ -611,15 +611,20 @@ public: return; } + ZLocker locker(ZNMethodTable::lock_for_nmethod(nm)); + if (nm->is_unloading()) { // Unlinking of the dependencies must happen before the // handshake separating unlink and purge. nm->flush_dependencies(false /* delete_immediately */); + + // We don't need to take the lock when unlinking nmethods from + // the Method, because it is only concurrently unlinked by + // the entry barrier, which acquires the per nmethod lock. + nm->unlink_from_method(false /* acquire_lock */); return; } - ZLocker locker(ZNMethodTable::lock_for_nmethod(nm)); - // Heal oops and disarm ZNMethodOopClosure cl; ZNMethodTable::entry_oops_do(entry, &cl);