comparison 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
comparison
equal deleted inserted replaced
1:da8c7f5b5f84 2:69dbef21875b
63 return _is_unloading; 63 return _is_unloading;
64 } 64 }
65 }; 65 };
66 66
67 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour { 67 class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {
68 private:
69 bool is_unloading(nmethod* nm) const {
70 ZIsUnloadingOopClosure cl;
71 nm->oops_do(&cl, true /* allow_zombie */);
72 return cl.is_unloading();
73 }
74
75 public: 68 public:
76 virtual bool is_unloading(CompiledMethod* method) const { 69 virtual bool is_unloading(CompiledMethod* method) const {
77 nmethod* const nm = method->as_nmethod(); 70 nmethod* const nm = method->as_nmethod();
78 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm); 71 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
79 if (lock == NULL) { 72 ZLocker<ZReentrantLock> locker(lock);
80 return is_unloading(nm); 73 ZIsUnloadingOopClosure cl;
81 } else { 74 nm->oops_do(&cl, true /* allow_zombie */);
82 ZLocker<ZReentrantLock> locker(lock); 75 return cl.is_unloading();
83 return is_unloading(nm);
84 }
85 } 76 }
86 }; 77 };
87 78
88 class ZCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour { 79 class ZCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour {
89 public: 80 public:
90 virtual bool lock(CompiledMethod* method) { 81 virtual bool lock(CompiledMethod* method) {
91 nmethod* const nm = method->as_nmethod(); 82 nmethod* const nm = method->as_nmethod();
92 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm); 83 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
93 if (lock != NULL) { 84 lock->lock();
94 lock->lock();
95 }
96 return true; 85 return true;
97 } 86 }
98 87
99 virtual void unlock(CompiledMethod* method) { 88 virtual void unlock(CompiledMethod* method) {
100 nmethod* const nm = method->as_nmethod(); 89 nmethod* const nm = method->as_nmethod();
101 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm); 90 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
102 if (lock != NULL) { 91 lock->unlock();
103 lock->unlock();
104 }
105 } 92 }
106 93
107 virtual bool is_safe(CompiledMethod* method) { 94 virtual bool is_safe(CompiledMethod* method) {
108 if (SafepointSynchronize::is_at_safepoint()) { 95 if (SafepointSynchronize::is_at_safepoint()) {
109 return true; 96 return true;
110 } 97 }
111 98
112 nmethod* const nm = method->as_nmethod(); 99 nmethod* const nm = method->as_nmethod();
113 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm); 100 ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
114 return lock == NULL || lock->is_owned(); 101 return lock->is_owned();
115 } 102 }
116 }; 103 };
117 104
118 ZUnload::ZUnload(ZWorkers* workers) : 105 ZUnload::ZUnload(ZWorkers* workers) :
119 _workers(workers) { 106 _workers(workers) {