Skip to content
Permalink
Browse files
8255837: Shenandoah: Remove ShenandoahConcurrentRoots class
Reviewed-by: rkennke
  • Loading branch information
zhengyu123 committed Jan 29, 2021
1 parent 53f1b93 commit 22bfa5b0ac3cca196821162de07aabcb2f6071a5
@@ -23,7 +23,6 @@
*/

#include "precompiled.hpp"
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
#include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp"
#include "gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.hpp"
#include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp"
@@ -35,7 +34,7 @@
#include "runtime/java.hpp"

void ShenandoahIUMode::initialize_flags() const {
if (ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
if (ClassUnloading) {
FLAG_SET_DEFAULT(ShenandoahSuspendibleWorkers, true);
FLAG_SET_DEFAULT(VerifyBeforeExit, false);
}
@@ -23,7 +23,6 @@
*/

#include "precompiled.hpp"
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
#include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp"
#include "gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.hpp"
#include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp"
@@ -35,7 +34,7 @@
#include "runtime/java.hpp"

void ShenandoahSATBMode::initialize_flags() const {
if (ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
if (ClassUnloading) {
FLAG_SET_DEFAULT(ShenandoahSuspendibleWorkers, true);
FLAG_SET_DEFAULT(VerifyBeforeExit, false);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
* Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "gc/shenandoah/shenandoahClosures.inline.hpp"
#include "gc/shenandoah/shenandoahCodeRoots.hpp"
#include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahNMethod.inline.hpp"
@@ -289,8 +288,7 @@ class ShenandoahUnlinkTask : public AbstractGangTask {
};

void ShenandoahCodeRoots::unlink(WorkGang* workers, bool unloading_occurred) {
assert(ShenandoahConcurrentRoots::should_do_concurrent_class_unloading(),
"Only when running concurrent class unloading");
assert(ShenandoahHeap::heap()->unload_classes(), "Only when running concurrent class unloading");

for (;;) {
ICRefillVerifier verifier;
@@ -345,8 +343,7 @@ class ShenandoahNMethodPurgeTask : public AbstractGangTask {
};

void ShenandoahCodeRoots::purge(WorkGang* workers) {
assert(ShenandoahConcurrentRoots::should_do_concurrent_class_unloading(),
"Only when running concurrent class unloading");
assert(ShenandoahHeap::heap()->unload_classes(), "Only when running concurrent class unloading");

ShenandoahNMethodPurgeTask task;
workers->run_task(&task);
@@ -101,8 +101,8 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
}

// Perform concurrent class unloading
if (heap->is_concurrent_weak_root_in_progress() &&
ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (heap->unload_classes() &&
heap->is_concurrent_weak_root_in_progress()) {
entry_class_unloading();
}

@@ -497,7 +497,7 @@ void ShenandoahConcurrentGC::op_init_mark() {
// Arm nmethods for concurrent marking. When a nmethod is about to be executed,
// we need to make sure that all its metadata are marked. alternative is to remark
// thread roots at final mark pause, but it can be potential latency killer.
if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (heap->unload_classes()) {
ShenandoahCodeRoots::arm_nmethods();
}

@@ -695,7 +695,6 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public AbstractGangTask {
ShenandoahConcurrentNMethodIterator _nmethod_itr;
ShenandoahConcurrentStringDedupRoots _dedup_roots;
ShenandoahPhaseTimings::Phase _phase;
bool _concurrent_class_unloading;

public:
ShenandoahConcurrentWeakRootsEvacUpdateTask(ShenandoahPhaseTimings::Phase phase) :
@@ -704,9 +703,8 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public AbstractGangTask {
_cld_roots(phase, ShenandoahHeap::heap()->workers()->active_workers()),
_nmethod_itr(ShenandoahCodeRoots::table()),
_dedup_roots(phase),
_phase(phase),
_concurrent_class_unloading(ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (_concurrent_class_unloading) {
_phase(phase) {
if (ShenandoahHeap::heap()->unload_classes()) {
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_nmethod_itr.nmethods_do_begin();
}
@@ -717,7 +715,7 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public AbstractGangTask {
~ShenandoahConcurrentWeakRootsEvacUpdateTask() {
_dedup_roots.epilogue();

if (_concurrent_class_unloading) {
if (ShenandoahHeap::heap()->unload_classes()) {
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_nmethod_itr.nmethods_do_end();
}
@@ -743,7 +741,7 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public AbstractGangTask {
// If we are going to perform concurrent class unloading later on, we need to
// cleanup the weak oops in CLD and determinate nmethod's unloading state, so that we
// can cleanup immediate garbage sooner.
if (_concurrent_class_unloading) {
if (ShenandoahHeap::heap()->unload_classes()) {
// Applies ShenandoahIsCLDAlive closure to CLDs, native barrier will either NULL the
// CLD's holder or evacuate it.
{
@@ -781,15 +779,15 @@ void ShenandoahConcurrentGC::op_weak_roots() {
heap->rendezvous_threads();
}

if (!ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (!ShenandoahHeap::heap()->unload_classes()) {
heap->set_concurrent_weak_root_in_progress(false);
}
}

void ShenandoahConcurrentGC::op_class_unloading() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
assert (heap->is_concurrent_weak_root_in_progress() &&
ShenandoahConcurrentRoots::should_do_concurrent_class_unloading(),
heap->unload_classes(),
"Checked by caller");
heap->do_class_unloading();
heap->set_concurrent_weak_root_in_progress(false);
@@ -823,24 +821,22 @@ class ShenandoahConcurrentRootsEvacUpdateTask : public AbstractGangTask {
ShenandoahVMRoots<true /*concurrent*/> _vm_roots;
ShenandoahClassLoaderDataRoots<true /*concurrent*/, false /*single threaded*/> _cld_roots;
ShenandoahConcurrentNMethodIterator _nmethod_itr;
bool _process_codecache;

public:
ShenandoahConcurrentRootsEvacUpdateTask(ShenandoahPhaseTimings::Phase phase) :
AbstractGangTask("Shenandoah Evacuate/Update Concurrent Strong Roots"),
_phase(phase),
_vm_roots(phase),
_cld_roots(phase, ShenandoahHeap::heap()->workers()->active_workers()),
_nmethod_itr(ShenandoahCodeRoots::table()),
_process_codecache(!ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (_process_codecache) {
_nmethod_itr(ShenandoahCodeRoots::table()) {
if (!ShenandoahHeap::heap()->unload_classes()) {
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_nmethod_itr.nmethods_do_begin();
}
}

~ShenandoahConcurrentRootsEvacUpdateTask() {
if (_process_codecache) {
if (!ShenandoahHeap::heap()->unload_classes()) {
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_nmethod_itr.nmethods_do_end();
}
@@ -865,7 +861,7 @@ class ShenandoahConcurrentRootsEvacUpdateTask : public AbstractGangTask {
}

// Cannot setup ShenandoahEvacOOMScope here, due to potential deadlock with nmethod_entry_barrier.
if (_process_codecache) {
if (!ShenandoahHeap::heap()->unload_classes()) {
ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
ShenandoahEvacUpdateCodeCacheClosure cl;
_nmethod_itr.nmethods_do(&cl);
@@ -104,17 +104,16 @@ class ShenandoahConcurrentMarkingTask : public AbstractGangTask {
}
};

class ShenandoahSATBAndRemarkCodeRootsThreadsClosure : public ThreadClosure {
class ShenandoahSATBAndRemarkThreadsClosure : public ThreadClosure {
private:
SATBMarkQueueSet& _satb_qset;
OopClosure* const _cl;
MarkingCodeBlobClosure* _code_cl;
uintx _claim_token;

public:
ShenandoahSATBAndRemarkCodeRootsThreadsClosure(SATBMarkQueueSet& satb_qset, OopClosure* cl, MarkingCodeBlobClosure* code_cl) :
ShenandoahSATBAndRemarkThreadsClosure(SATBMarkQueueSet& satb_qset, OopClosure* cl) :
_satb_qset(satb_qset),
_cl(cl), _code_cl(code_cl),
_cl(cl),
_claim_token(Threads::thread_claim_token()) {}

void do_thread(Thread* thread) {
@@ -124,15 +123,7 @@ class ShenandoahSATBAndRemarkCodeRootsThreadsClosure : public ThreadClosure {
if (thread->is_Java_thread()) {
if (_cl != NULL) {
ResourceMark rm;
thread->oops_do(_cl, _code_cl);
} else if (_code_cl != NULL) {
// In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
// however the liveness of oops reachable from nmethods have very complex lifecycles:
// * Alive if on the stack of an executing method
// * Weakly reachable otherwise
// Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
// live by the SATB invariant but other oops recorded in nmethods may behave differently.
thread->as_Java_thread()->nmethods_do(_code_cl);
thread->oops_do(_cl, NULL);
}
}
}
@@ -165,12 +156,9 @@ class ShenandoahFinalMarkingTask : public AbstractGangTask {
while (satb_mq_set.apply_closure_to_completed_buffer(&cl)) {}
assert(!heap->has_forwarded_objects(), "Not expected");

bool do_nmethods = heap->unload_classes() && !ShenandoahConcurrentRoots::can_do_concurrent_class_unloading();
ShenandoahMarkRefsClosure mark_cl(q, rp);
MarkingCodeBlobClosure blobsCl(&mark_cl, !CodeBlobToOopClosure::FixRelocations);
ShenandoahSATBAndRemarkCodeRootsThreadsClosure tc(satb_mq_set,
ShenandoahIUBarrier ? &mark_cl : NULL,
do_nmethods ? &blobsCl : NULL);
ShenandoahSATBAndRemarkThreadsClosure tc(satb_mq_set,
ShenandoahIUBarrier ? &mark_cl : NULL);
Threads::threads_do(&tc);
}

This file was deleted.

This file was deleted.

@@ -180,7 +180,7 @@ void ShenandoahDegenGC::op_degenerated() {
assert(!heap->cancelled_gc(), "STW reference update can not OOM");
}

if (ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
if (ClassUnloading) {
// Disarm nmethods that armed in concurrent cycle.
// In above case, update roots should disarm them
ShenandoahCodeRoots::disarm_nmethods();
@@ -39,7 +39,6 @@
#include "gc/shenandoah/shenandoahCollectionSet.hpp"
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
#include "gc/shenandoah/shenandoahConcurrentMark.hpp"
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
#include "gc/shenandoah/shenandoahControlThread.hpp"
#include "gc/shenandoah/shenandoahFreeSet.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
@@ -1711,7 +1710,6 @@ void ShenandoahHeap::set_evacuation_in_progress(bool in_progress) {
}

void ShenandoahHeap::set_concurrent_strong_root_in_progress(bool in_progress) {
assert(ShenandoahConcurrentRoots::can_do_concurrent_roots(), "Why set the flag?");
if (in_progress) {
_concurrent_strong_root_in_progress.set();
} else {
@@ -1720,7 +1718,6 @@ void ShenandoahHeap::set_concurrent_strong_root_in_progress(bool in_progress) {
}

void ShenandoahHeap::set_concurrent_weak_root_in_progress(bool in_progress) {
assert(ShenandoahConcurrentRoots::can_do_concurrent_roots(), "Why set the flag?");
if (in_progress) {
_concurrent_weak_root_in_progress.set();
} else {
@@ -1971,15 +1968,15 @@ void ShenandoahHeap::prepare_concurrent_roots() {
assert(!is_stw_gc_in_progress(), "Only concurrent GC");
set_concurrent_strong_root_in_progress(!collection_set()->is_empty());
set_concurrent_weak_root_in_progress(true);
if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (unload_classes()) {
_unloader.prepare();
}
}

void ShenandoahHeap::finish_concurrent_roots() {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
assert(!is_stw_gc_in_progress(), "Only concurrent GC");
if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
if (unload_classes()) {
_unloader.finish();
}
}
@@ -29,7 +29,6 @@
#include "gc/shared/tlab_globals.hpp"
#include "gc/shenandoah/shenandoahForwarding.inline.hpp"
#include "gc/shenandoah/shenandoahConcurrentGC.hpp"
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
#include "gc/shenandoah/shenandoahCollectionSet.hpp"
#include "gc/shenandoah/shenandoahFreeSet.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
@@ -125,7 +124,7 @@ void ShenandoahMarkCompact::do_it(GCCause::Cause gc_cause) {

// Degenerated GC may carry concurrent root flags when upgrading to
// full GC. We need to reset it before mutators resume.
if (ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
if (ClassUnloading) {
heap->set_concurrent_strong_root_in_progress(false);
heap->set_concurrent_weak_root_in_progress(false);
}
Loading

0 comments on commit 22bfa5b

Please sign in to comment.