--- old/src/hotspot/share/gc/z/zMark.cpp 2019-02-19 14:38:57.682539210 +0100 +++ new/src/hotspot/share/gc/z/zMark.cpp 2019-02-19 14:38:57.497533251 +0100 @@ -129,8 +129,6 @@ } virtual void do_thread(Thread* thread) { - ZRootsIteratorClosure::do_thread(thread); - // Update thread local address bad mask ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask); --- old/src/hotspot/share/gc/z/zRelocate.cpp 2019-02-19 14:38:58.001549486 +0100 +++ new/src/hotspot/share/gc/z/zRelocate.cpp 2019-02-19 14:38:57.806543204 +0100 @@ -40,8 +40,6 @@ class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure { public: virtual void do_thread(Thread* thread) { - ZRootsIteratorClosure::do_thread(thread); - // Update thread local address bad mask ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask); --- old/src/hotspot/share/gc/z/zRootsIterator.cpp 2019-02-19 14:38:58.301559150 +0100 +++ new/src/hotspot/share/gc/z/zRootsIterator.cpp 2019-02-19 14:38:58.111553029 +0100 @@ -135,29 +135,38 @@ } } -class ZCodeBlobClosure : public CodeBlobToOopClosure { +class ZRootsIteratorCodeBlobClosure : public CodeBlobToOopClosure { private: BarrierSetNMethod* _bs; public: - ZCodeBlobClosure(OopClosure* cl) : + ZRootsIteratorCodeBlobClosure(OopClosure* cl) : CodeBlobToOopClosure(cl, true /* fix_relocations */), _bs(BarrierSet::barrier_set()->barrier_set_nmethod()) {} virtual void do_code_blob(CodeBlob* cb) { nmethod* const nm = cb->as_nmethod_or_null(); - if (nm == NULL || nm->test_set_oops_do_mark()) { - return; + if (nm != NULL && !nm->test_set_oops_do_mark()) { + CodeBlobToOopClosure::do_code_blob(cb); + _bs->disarm(nm); } - CodeBlobToOopClosure::do_code_blob(cb); - _bs->disarm(nm); } }; -void ZRootsIteratorClosure::do_thread(Thread* thread) { - ZCodeBlobClosure code_cl(this); - thread->oops_do(this, ClassUnloading ? &code_cl : NULL); -} +class ZRootsIteratorThreadClosure : public ThreadClosure { +private: + ZRootsIteratorClosure* _cl; + +public: + ZRootsIteratorThreadClosure(ZRootsIteratorClosure* cl) : + _cl(cl) {} + + virtual void do_thread(Thread* thread) { + ZRootsIteratorCodeBlobClosure code_cl(_cl); + thread->oops_do(_cl, ClassUnloading ? &code_cl : NULL); + _cl->do_thread(thread); + } +}; ZRootsIterator::ZRootsIterator() : _universe(this), @@ -227,7 +236,8 @@ void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) { ZStatTimer timer(ZSubPhasePauseRootsThreads); ResourceMark rm; - Threads::possibly_parallel_threads_do(true, cl); + ZRootsIteratorThreadClosure thread_cl(cl); + Threads::possibly_parallel_threads_do(true, &thread_cl); } void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) { --- old/src/hotspot/share/gc/z/zRootsIterator.hpp 2019-02-19 14:38:58.625569587 +0100 +++ new/src/hotspot/share/gc/z/zRootsIterator.hpp 2019-02-19 14:38:58.422563047 +0100 @@ -31,9 +31,9 @@ #include "runtime/thread.hpp" #include "utilities/globalDefinitions.hpp" -class ZRootsIteratorClosure : public OopClosure, public ThreadClosure { +class ZRootsIteratorClosure : public OopClosure { public: - virtual void do_thread(Thread* thread); + virtual void do_thread(Thread* thread) {} }; typedef OopStorage::ParState ZOopStorageIterator;