Skip to content

Commit d036dca

Browse files
committed
8254103: Shenandoah: Move updating thread roots to concurrent phase
Reviewed-by: rkennke
1 parent 7e82ba1 commit d036dca

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau
449449
heap->entry_updaterefs();
450450
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_updaterefs)) return;
451451

452+
// Concurrent update thread roots
453+
heap->entry_update_thread_roots();
454+
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_updaterefs)) return;
455+
452456
heap->vmop_entry_final_updaterefs();
453457

454458
// Update references freed up collection set, kick the cleanup to reclaim the space.

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,31 @@ void ShenandoahHeap::op_conc_evac() {
18061806
workers()->run_task(&task);
18071807
}
18081808

1809+
class ShenandoahUpdateThreadClosure : public HandshakeClosure {
1810+
private:
1811+
ShenandoahUpdateRefsClosure _cl;
1812+
public:
1813+
ShenandoahUpdateThreadClosure();
1814+
void do_thread(Thread* thread);
1815+
};
1816+
1817+
ShenandoahUpdateThreadClosure::ShenandoahUpdateThreadClosure() :
1818+
HandshakeClosure("Shenandoah Update Thread Roots") {
1819+
}
1820+
1821+
void ShenandoahUpdateThreadClosure::do_thread(Thread* thread) {
1822+
if (thread->is_Java_thread()) {
1823+
JavaThread* jt = thread->as_Java_thread();
1824+
ResourceMark rm;
1825+
jt->oops_do(&_cl, NULL);
1826+
}
1827+
}
1828+
1829+
void ShenandoahHeap::op_update_thread_roots() {
1830+
ShenandoahUpdateThreadClosure cl;
1831+
Handshake::execute(&cl);
1832+
}
1833+
18091834
void ShenandoahHeap::op_stw_evac() {
18101835
ShenandoahEvacuationTask task(this, _collection_set, false);
18111836
workers()->run_task(&task);
@@ -2735,8 +2760,6 @@ void ShenandoahHeap::op_final_updaterefs() {
27352760

27362761
if (is_degenerated_gc_in_progress()) {
27372762
concurrent_mark()->update_roots(ShenandoahPhaseTimings::degen_gc_update_roots);
2738-
} else {
2739-
concurrent_mark()->update_thread_roots(ShenandoahPhaseTimings::final_update_refs_roots);
27402763
}
27412764

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

3044+
void ShenandoahHeap::entry_update_thread_roots() {
3045+
TraceCollectorStats tcs(monitoring_support()->concurrent_collection_counters());
3046+
3047+
static const char* msg = "Concurrent update thread roots";
3048+
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_update_thread_roots);
3049+
EventMark em("%s", msg);
3050+
3051+
// No workers used in this phase, no setup required
3052+
try_inject_alloc_failure();
3053+
op_update_thread_roots();
3054+
}
3055+
3056+
30213057
void ShenandoahHeap::entry_updaterefs() {
30223058
static const char* msg = "Concurrent update references";
30233059
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_update_refs);

src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class ShenandoahHeap : public CollectedHeap {
396396
void entry_cleanup_early();
397397
void entry_rendezvous_roots();
398398
void entry_evac();
399+
void entry_update_thread_roots();
399400
void entry_updaterefs();
400401
void entry_cleanup_complete();
401402
void entry_uncommit(double shrink_before, size_t shrink_until);
@@ -421,6 +422,7 @@ class ShenandoahHeap : public CollectedHeap {
421422
void op_rendezvous_roots();
422423
void op_conc_evac();
423424
void op_stw_evac();
425+
void op_update_thread_roots();
424426
void op_updaterefs();
425427
void op_cleanup_complete();
426428
void op_uncommit(double shrink_before, size_t shrink_until);

src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class outputStream;
106106
f(init_update_refs, "Pause Init Update Refs (N)") \
107107
f(init_update_refs_manage_gclabs, " Manage GCLABs") \
108108
\
109+
f(conc_update_thread_roots, "Concurrent Update Thread Roots") \
109110
f(conc_update_refs, "Concurrent Update Refs") \
110111
\
111112
f(final_update_refs_gross, "Pause Final Update Refs (G)") \

0 commit comments

Comments
 (0)