--- old/src/hotspot/share/gc/z/zRootsIterator.cpp 2019-11-22 15:12:10.820584540 +0100 +++ new/src/hotspot/share/gc/z/zRootsIterator.cpp 2019-11-22 15:12:10.326568330 +0100 @@ -140,39 +140,46 @@ class ZRootsIteratorCodeBlobClosure : public CodeBlobToOopClosure { private: - BarrierSetNMethod* _bs; + BarrierSetNMethod* const _bs; + const bool _disarm_nmethods; public: - ZRootsIteratorCodeBlobClosure(OopClosure* cl) : + ZRootsIteratorCodeBlobClosure(OopClosure* cl, bool disarm_nmethods) : CodeBlobToOopClosure(cl, true /* fix_relocations */), - _bs(BarrierSet::barrier_set()->barrier_set_nmethod()) {} + _bs(BarrierSet::barrier_set()->barrier_set_nmethod()), + _disarm_nmethods(disarm_nmethods) {} virtual void do_code_blob(CodeBlob* cb) { nmethod* const nm = cb->as_nmethod_or_null(); if (nm != NULL && nm->oops_do_try_claim()) { CodeBlobToOopClosure::do_code_blob(cb); - _bs->disarm(nm); + if (_disarm_nmethods) { + _bs->disarm(nm); + } } } }; class ZRootsIteratorThreadClosure : public ThreadClosure { private: - ZRootsIteratorClosure* _cl; + ZRootsIteratorClosure* const _cl; + const bool _disarm_nmethods; public: - ZRootsIteratorThreadClosure(ZRootsIteratorClosure* cl) : - _cl(cl) {} + ZRootsIteratorThreadClosure(ZRootsIteratorClosure* cl, bool disarm_nmethods) : + _cl(cl), + _disarm_nmethods(disarm_nmethods) {} virtual void do_thread(Thread* thread) { - ZRootsIteratorCodeBlobClosure code_cl(_cl); + ZRootsIteratorCodeBlobClosure code_cl(_cl, _disarm_nmethods); thread->oops_do(_cl, ClassUnloading ? &code_cl : NULL); _cl->do_thread(thread); } }; -ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export) : +ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export, bool disarm_nmethods) : _visit_jvmti_weak_export(visit_jvmti_weak_export), + _disarm_nmethods(disarm_nmethods), _universe(this), _object_synchronizer(this), _management(this), @@ -240,7 +247,7 @@ void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsThreads); ResourceMark rm; - ZRootsIteratorThreadClosure thread_cl(cl); + ZRootsIteratorThreadClosure thread_cl(cl, _disarm_nmethods); Threads::possibly_parallel_threads_do(true, &thread_cl); }