Skip to content
Permalink
Browse files
8254103: Shenandoah: Move updating thread roots to concurrent phase
Reviewed-by: rkennke
  • Loading branch information
zhengyu123 committed Oct 8, 2020
1 parent 7e82ba1 commit d036dca0851a30f5752532e228dd9a167b86133f
Showing 4 changed files with 45 additions and 2 deletions.
@@ -449,6 +449,10 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau
heap->entry_updaterefs();
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_updaterefs)) return;

// Concurrent update thread roots
heap->entry_update_thread_roots();
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_updaterefs)) return;

heap->vmop_entry_final_updaterefs();

// Update references freed up collection set, kick the cleanup to reclaim the space.
@@ -1806,6 +1806,31 @@ void ShenandoahHeap::op_conc_evac() {
workers()->run_task(&task);
}

class ShenandoahUpdateThreadClosure : public HandshakeClosure {
private:
ShenandoahUpdateRefsClosure _cl;
public:
ShenandoahUpdateThreadClosure();
void do_thread(Thread* thread);
};

ShenandoahUpdateThreadClosure::ShenandoahUpdateThreadClosure() :
HandshakeClosure("Shenandoah Update Thread Roots") {
}

void ShenandoahUpdateThreadClosure::do_thread(Thread* thread) {
if (thread->is_Java_thread()) {
JavaThread* jt = thread->as_Java_thread();
ResourceMark rm;
jt->oops_do(&_cl, NULL);
}
}

void ShenandoahHeap::op_update_thread_roots() {
ShenandoahUpdateThreadClosure cl;
Handshake::execute(&cl);
}

void ShenandoahHeap::op_stw_evac() {
ShenandoahEvacuationTask task(this, _collection_set, false);
workers()->run_task(&task);
@@ -2735,8 +2760,6 @@ void ShenandoahHeap::op_final_updaterefs() {

if (is_degenerated_gc_in_progress()) {
concurrent_mark()->update_roots(ShenandoahPhaseTimings::degen_gc_update_roots);
} else {
concurrent_mark()->update_thread_roots(ShenandoahPhaseTimings::final_update_refs_roots);
}

// Has to be done before cset is clear
@@ -3018,6 +3041,19 @@ void ShenandoahHeap::entry_evac() {
op_conc_evac();
}

void ShenandoahHeap::entry_update_thread_roots() {
TraceCollectorStats tcs(monitoring_support()->concurrent_collection_counters());

static const char* msg = "Concurrent update thread roots";
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_update_thread_roots);
EventMark em("%s", msg);

// No workers used in this phase, no setup required
try_inject_alloc_failure();
op_update_thread_roots();
}


void ShenandoahHeap::entry_updaterefs() {
static const char* msg = "Concurrent update references";
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_update_refs);
@@ -396,6 +396,7 @@ class ShenandoahHeap : public CollectedHeap {
void entry_cleanup_early();
void entry_rendezvous_roots();
void entry_evac();
void entry_update_thread_roots();
void entry_updaterefs();
void entry_cleanup_complete();
void entry_uncommit(double shrink_before, size_t shrink_until);
@@ -421,6 +422,7 @@ class ShenandoahHeap : public CollectedHeap {
void op_rendezvous_roots();
void op_conc_evac();
void op_stw_evac();
void op_update_thread_roots();
void op_updaterefs();
void op_cleanup_complete();
void op_uncommit(double shrink_before, size_t shrink_until);
@@ -106,6 +106,7 @@ class outputStream;
f(init_update_refs, "Pause Init Update Refs (N)") \
f(init_update_refs_manage_gclabs, " Manage GCLABs") \
\
f(conc_update_thread_roots, "Concurrent Update Thread Roots") \
f(conc_update_refs, "Concurrent Update Refs") \
\
f(final_update_refs_gross, "Pause Final Update Refs (G)") \

1 comment on commit d036dca

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on d036dca Oct 8, 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.