Skip to content
Permalink
Browse files
8254562: ZGC: Remove ZMarkRootsTask
Reviewed-by: pliden
  • Loading branch information
stefank committed Oct 13, 2020
1 parent 90de289 commit 9d230ea87dac793a10b256aa773d7fa2262057f0
Showing 10 changed files with 16 additions and 79 deletions.
@@ -176,7 +176,6 @@ ZHeapIterator::ZHeapIterator(uint nworkers, bool visit_weaks) :
_bitmaps_lock(),
_queues(nworkers),
_array_queues(nworkers),
_roots(),
_concurrent_roots(),
_weak_roots(),
_concurrent_weak_roots(),
@@ -341,7 +340,6 @@ void ZHeapIterator::drain_and_steal(const ZHeapIteratorContext& context, ObjectC

template <bool VisitWeaks>
void ZHeapIterator::object_iterate_inner(const ZHeapIteratorContext& context, ObjectClosure* cl) {
push_roots<false /* Concurrent */, false /* Weak */>(context, _roots);
push_roots<true /* Concurrent */, false /* Weak */>(context, _concurrent_roots);
if (VisitWeaks) {
push_roots<false /* Concurrent */, true /* Weak */>(context, _weak_roots);
@@ -52,7 +52,6 @@ class ZHeapIterator : public ParallelObjectIterator {
ZLock _bitmaps_lock;
ZHeapIteratorQueues _queues;
ZHeapIteratorArrayQueues _array_queues;
ZRootsIterator _roots;
ZConcurrentRootsIteratorClaimOther _concurrent_roots;
ZWeakRootsIterator _weak_roots;
ZConcurrentWeakRootsIterator _concurrent_weak_roots;
@@ -123,40 +123,6 @@ void ZMark::prepare_mark() {
}
}

class ZMarkRootsIteratorClosure : public ZRootsIteratorClosure {
public:
virtual void do_oop(oop* p) {
ZBarrier::mark_barrier_on_root_oop_field(p);
}

virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}
};

class ZMarkRootsTask : public ZTask {
private:
ZMark* const _mark;
ZRootsIterator _roots;
ZMarkRootsIteratorClosure _cl;

public:
ZMarkRootsTask(ZMark* mark) :
ZTask("ZMarkRootsTask"),
_mark(mark),
_roots(false /* visit_jvmti_weak_export */) {}

virtual void work() {
_roots.oops_do(&_cl);

// Flush and free worker stacks. Needed here since
// the set of workers executing during root scanning
// can be different from the set of workers executing
// during mark.
_mark->flush_and_free();
}
};

void ZMark::start() {
// Verification
if (ZVerifyMarking) {
@@ -165,10 +131,6 @@ void ZMark::start() {

// Prepare for concurrent mark
prepare_mark();

// Mark roots
ZMarkRootsTask task(this);
_workers->run_parallel(&task);
}

void ZMark::prepare_work() {
@@ -43,7 +43,7 @@ static const ZStatCounter ZCounterRelocationContention("Contention", "Relocation
ZRelocate::ZRelocate(ZWorkers* workers) :
_workers(workers) {}

class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure {
class ZRelocateRootsIteratorClosure : public OopClosure {
public:
virtual void do_oop(oop* p) {
ZBarrier::relocate_barrier_on_root_oop_field(p);
@@ -56,24 +56,26 @@ class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure {

class ZRelocateRootsTask : public ZTask {
private:
ZRootsIterator _roots;
ZRelocateRootsIteratorClosure _cl;

public:
ZRelocateRootsTask() :
ZTask("ZRelocateRootsTask"),
_roots(true /* visit_jvmti_weak_export */) {}
ZTask("ZRelocateRootsTask") {}

virtual void work() {
// Allocation path assumes that relocating GC threads are ZWorkers
assert(ZThread::is_worker(), "Relocation code needs to be run as a worker");
assert(ZThread::worker_id() == 0, "No multi-thread support");

// During relocation we need to visit the JVMTI
// export weak roots to rehash the JVMTI tag map
_roots.oops_do(&_cl);
ZRelocateRoots::oops_do(&_cl);
}
};

void ZRelocate::start() {
ZRelocateRootsTask task;
_workers->run_parallel(&task);
_workers->run_serial(&task);
}

uintptr_t ZRelocate::relocate_object_inner(ZForwarding* forwarding, uintptr_t from_index, uintptr_t from_offset) const {
@@ -54,7 +54,6 @@
#include "runtime/vmThread.hpp"
#include "utilities/debug.hpp"

static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");

static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup");
@@ -141,25 +140,12 @@ void ZJavaThreadsIterator::threads_do(ThreadClosure* cl) {
}
}

ZRootsIterator::ZRootsIterator(bool visit_jvmti_weak_export) :
_visit_jvmti_weak_export(visit_jvmti_weak_export),
_jvmti_weak_export(this) {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
}

void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
void ZRelocateRoots::oops_do(OopClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
AlwaysTrueClosure always_alive;
JvmtiExport::weak_oops_do(&always_alive, cl);
}

void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRoots);
if (_visit_jvmti_weak_export) {
_jvmti_weak_export.oops_do(cl);
}
}

ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) :
_oop_storage_set_iter(),
_java_threads_iter(),
@@ -105,18 +105,9 @@ class ZJavaThreadsIterator {
void threads_do(ThreadClosure* cl);
};

class ZRootsIterator {
private:
const bool _visit_jvmti_weak_export;

void do_jvmti_weak_export(ZRootsIteratorClosure* cl);

ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_jvmti_weak_export> _jvmti_weak_export;

class ZRelocateRoots : public AllStatic {
public:
ZRootsIterator(bool visit_jvmti_weak_export = false);

void oops_do(ZRootsIteratorClosure* cl);
static void oops_do(OopClosure* cl);
};

class ZConcurrentRootsIterator {
@@ -229,10 +229,6 @@ void ZVerify::roots(bool verify_fixed) {
}
}

void ZVerify::roots_strong() {
roots<ZRootsIterator>(true /* verify_fixed */);
}

void ZVerify::roots_weak() {
roots<ZWeakRootsIterator>(true /* verify_fixed */);
}
@@ -246,7 +242,6 @@ void ZVerify::roots_concurrent_weak() {
}

void ZVerify::roots(bool verify_concurrent_strong, bool verify_weaks) {
roots_strong();
roots_concurrent_strong(verify_concurrent_strong);
if (verify_weaks) {
roots_weak();
@@ -33,7 +33,6 @@ class ZVerify : public AllStatic {
private:
template <typename RootsIterator> static void roots(bool verify_fixed);

static void roots_strong();
static void roots_weak();
static void roots_concurrent_strong(bool verify_fixed);
static void roots_concurrent_weak();
@@ -101,6 +101,10 @@ void ZWorkers::run(ZTask* task, uint nworkers) {
_workers.run_task(task->gang_task());
}

void ZWorkers::run_serial(ZTask* task) {
run(task, 1 /* nworkers */);
}

void ZWorkers::run_parallel(ZTask* task) {
run(task, nparallel());
}
@@ -48,6 +48,7 @@ class ZWorkers {

void set_boost(bool boost);

void run_serial(ZTask* task);
void run_parallel(ZTask* task);
void run_concurrent(ZTask* task);

1 comment on commit 9d230ea

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 9d230ea Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.