8219332: ZGC: Improve ZRootsIteratorClosure abstraction

Reviewed-by: stefank
This commit is contained in:
Per Lidén 2019-02-20 13:43:02 +01:00
parent 92f19f92bb
commit 3df5e4fabb
4 changed files with 23 additions and 17 deletions

View File

@ -129,8 +129,6 @@ public:
}
virtual void do_thread(Thread* thread) {
ZRootsIteratorClosure::do_thread(thread);
// Update thread local address bad mask
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);

View File

@ -40,8 +40,6 @@ ZRelocate::ZRelocate(ZWorkers* workers) :
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);

View File

@ -135,29 +135,38 @@ void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRoots
}
}
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_system_dictionary(ZRootsIteratorClosure* cl) {
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) {

View File

@ -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<true /* concurrent */, false /* is_const */> ZOopStorageIterator;