8253434: Shenandoah: Cleanup ShenandoahRootScanner

Reviewed-by: rkennke
This commit is contained in:
Zhengyu Gu 2020-09-22 14:03:25 +00:00
parent 8c02bdbf13
commit 3d5fea1f07
3 changed files with 7 additions and 42 deletions

View File

@ -107,21 +107,8 @@ public:
private:
void do_work(ShenandoahHeap* heap, OopClosure* oops, uint worker_id) {
// The rationale for selecting the roots to scan is as follows:
// a. With unload_classes = true, we only want to scan the actual strong roots from the
// code cache. This will allow us to identify the dead classes, unload them, *and*
// invalidate the relevant code cache blobs. This could be only done together with
// class unloading.
// b. With unload_classes = false, we have to nominally retain all the references from code
// cache, because there could be the case of embedded class/oop in the generated code,
// which we will never visit during mark. Without code cache invalidation, as in (a),
// we risk executing that code cache blob, and crashing.
if (heap->unload_classes()) {
_rp->strong_roots_do(worker_id, oops);
} else {
_rp->roots_do(worker_id, oops);
}
}
};
class ShenandoahUpdateRootsTask : public AbstractGangTask {

View File

@ -168,30 +168,13 @@ ShenandoahRootScanner::~ShenandoahRootScanner() {
}
void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops) {
CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
roots_do(worker_id, oops, &clds_cl, &blobs_cl);
roots_do(worker_id, oops, &blobs_cl);
}
void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops) {
CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
MarkingCodeBlobClosure blobs_cl(oops, !CodeBlobToOopClosure::FixRelocations);
strong_roots_do(worker_id, oops, &clds_cl, &blobs_cl);
}
void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops, CodeBlobClosure* code, ThreadClosure *tc) {
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
void ShenandoahRootScanner::roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure *tc) {
assert(!ShenandoahSafepoint::is_at_shenandoah_safepoint() ||
!ShenandoahHeap::heap()->unload_classes(),
"Expect class unloading when Shenandoah cycle is running");
assert(clds != NULL, "Only possible with CLD closure");
ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
ResourceMark rm;
_thread_roots.threads_do(&tc_cl, worker_id);
}
void ShenandoahRootScanner::strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc) {
assert(ShenandoahHeap::heap()->unload_classes(), "Should be used during class unloading");
ShenandoahParallelOopsDoThreadClosure tc_cl(oops, code, tc);
ResourceMark rm;
_thread_roots.threads_do(&tc_cl, worker_id);

View File

@ -197,15 +197,10 @@ public:
ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase);
~ShenandoahRootScanner();
// Apply oops, clds and blobs to all strongly reachable roots in the system,
// during class unloading cycle
void strong_roots_do(uint worker_id, OopClosure* cl);
void strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
// Apply oops, clds and blobs to all strongly reachable roots and weakly reachable
// roots when class unloading is disabled during this cycle
void roots_do(uint worker_id, OopClosure* cl);
void roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
private:
void roots_do(uint worker_id, OopClosure* oops, CodeBlobClosure* code, ThreadClosure* tc = NULL);
};
template <bool CONCURRENT>