diff src/hotspot/share/gc/z/zUnload.cpp @ 53921:a590b6107ab3

8218974: Free GC native structures in nmethod::flush Reviewed-by: pliden
author eosterlund
date Tue, 26 Feb 2019 11:36:00 +0100
parents bf1133e7dfba
children 224515275cf9
line wrap: on
line diff
--- a/src/hotspot/share/gc/z/zUnload.cpp	Tue Feb 26 14:57:23 2019 +0530
+++ b/src/hotspot/share/gc/z/zUnload.cpp	Tue Feb 26 11:36:00 2019 +0100
@@ -65,23 +65,14 @@
 };
 
 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {
-private:
-  bool is_unloading(nmethod* nm) const {
-    ZIsUnloadingOopClosure cl;
-    nm->oops_do(&cl, true /* allow_zombie */);
-    return cl.is_unloading();
-  }
-
 public:
   virtual bool is_unloading(CompiledMethod* method) const {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock == NULL) {
-      return is_unloading(nm);
-    } else {
-      ZLocker<ZReentrantLock> locker(lock);
-      return is_unloading(nm);
-    }
+    ZLocker<ZReentrantLock> locker(lock);
+    ZIsUnloadingOopClosure cl;
+    nm->oops_do(&cl, true /* allow_zombie */);
+    return cl.is_unloading();
   }
 };
 
@@ -90,18 +81,14 @@
   virtual bool lock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock != NULL) {
-      lock->lock();
-    }
+    lock->lock();
     return true;
   }
 
   virtual void unlock(CompiledMethod* method) {
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    if (lock != NULL) {
-      lock->unlock();
-    }
+    lock->unlock();
   }
 
   virtual bool is_safe(CompiledMethod* method) {
@@ -111,7 +98,7 @@
 
     nmethod* const nm = method->as_nmethod();
     ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
-    return lock == NULL || lock->is_owned();
+    return lock->is_owned();
   }
 };