< prev index next >

src/hotspot/share/gc/z/zNMethodTable.cpp

     nmethod* const nm = entry.method();
     if (!nm->is_alive()) {
       return;
     }
 
+    ZLocker<ZReentrantLock> 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<ZReentrantLock> locker(ZNMethodTable::lock_for_nmethod(nm));
-
     // Heal oops and disarm
     ZNMethodOopClosure cl;
     ZNMethodTable::entry_oops_do(entry, &cl);
     ZNMethodTable::disarm_nmethod(nm);
 
    
< prev index next >