267
268 virtual void do_nmethod(nmethod* nm) {
269 if (failed()) {
270 return;
271 }
272
273 if (!nm->is_alive()) {
274 return;
275 }
276
277 ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
278
279 if (nm->is_unloading()) {
280 // Unlinking of the dependencies must happen before the
281 // handshake separating unlink and purge.
282 nm->flush_dependencies(false /* delete_immediately */);
283
284 // We don't need to take the lock when unlinking nmethods from
285 // the Method, because it is only concurrently unlinked by
286 // the entry barrier, which acquires the per nmethod lock.
287 nm->unlink_from_method(false /* acquire_lock */);
288 return;
289 }
290
291 // Heal oops and disarm
292 ZNMethodOopClosure cl;
293 ZNMethod::nmethod_oops_do(nm, &cl);
294 ZNMethod::disarm_nmethod(nm);
295
296 // Clear compiled ICs and exception caches
297 if (!nm->unload_nmethod_caches(_unloading_occurred)) {
298 set_failed();
299 }
300 }
301
302 bool failed() const {
303 return Atomic::load(&_failed);
304 }
305 };
306
307 class ZNMethodUnlinkTask : public ZTask {
|
267
268 virtual void do_nmethod(nmethod* nm) {
269 if (failed()) {
270 return;
271 }
272
273 if (!nm->is_alive()) {
274 return;
275 }
276
277 ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
278
279 if (nm->is_unloading()) {
280 // Unlinking of the dependencies must happen before the
281 // handshake separating unlink and purge.
282 nm->flush_dependencies(false /* delete_immediately */);
283
284 // We don't need to take the lock when unlinking nmethods from
285 // the Method, because it is only concurrently unlinked by
286 // the entry barrier, which acquires the per nmethod lock.
287 nm->unlink_from_method();
288 return;
289 }
290
291 // Heal oops and disarm
292 ZNMethodOopClosure cl;
293 ZNMethod::nmethod_oops_do(nm, &cl);
294 ZNMethod::disarm_nmethod(nm);
295
296 // Clear compiled ICs and exception caches
297 if (!nm->unload_nmethod_caches(_unloading_occurred)) {
298 set_failed();
299 }
300 }
301
302 bool failed() const {
303 return Atomic::load(&_failed);
304 }
305 };
306
307 class ZNMethodUnlinkTask : public ZTask {
|