Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit a9f94bd

Browse files
committedAug 18, 2020
8251910: Shenandoah: Handshake threads between weak-roots and reset phases
Reviewed-by: rkennke
1 parent 9d8d509 commit a9f94bd

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed
 

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

+6
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau
424424

425425
// Update references freed up collection set, kick the cleanup to reclaim the space.
426426
heap->entry_cleanup_complete();
427+
} else {
428+
// Concurrent weak/strong root flags are unset concurrently. We depend on updateref GC safepoints
429+
// to ensure the changes are visible to all mutators before gc cycle is completed.
430+
// In case of no evacuation, updateref GC safepoints are skipped. Therefore, we will need
431+
// to perform thread handshake to ensure their consistences.
432+
heap->entry_rendezvous_roots();
427433
}
428434

429435
// Cycle is complete

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -1821,8 +1821,7 @@ void ShenandoahHeap::op_weak_roots() {
18211821
// Perform handshake to flush out dead oops
18221822
{
18231823
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_rendezvous);
1824-
ShenandoahRendezvousClosure cl;
1825-
Handshake::execute(&cl);
1824+
rendezvous_threads();
18261825
}
18271826
}
18281827
}
@@ -1842,6 +1841,15 @@ void ShenandoahHeap::op_strong_roots() {
18421841
set_concurrent_strong_root_in_progress(false);
18431842
}
18441843

1844+
void ShenandoahHeap::op_rendezvous_roots() {
1845+
rendezvous_threads();
1846+
}
1847+
1848+
void ShenandoahHeap::rendezvous_threads() {
1849+
ShenandoahRendezvousClosure cl;
1850+
Handshake::execute(&cl);
1851+
}
1852+
18451853
class ShenandoahResetUpdateRegionStateClosure : public ShenandoahHeapRegionClosure {
18461854
private:
18471855
ShenandoahMarkingContext* const _ctx;
@@ -2900,6 +2908,16 @@ void ShenandoahHeap::entry_cleanup_early() {
29002908
op_cleanup_early();
29012909
}
29022910

2911+
void ShenandoahHeap::entry_rendezvous_roots() {
2912+
static const char* msg = "Rendezvous roots";
2913+
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_rendezvous_roots);
2914+
EventMark em("%s", msg);
2915+
2916+
// This phase does not use workers, no need for setup
2917+
try_inject_alloc_failure();
2918+
op_rendezvous_roots();
2919+
}
2920+
29032921
void ShenandoahHeap::entry_cleanup_complete() {
29042922
static const char* msg = "Concurrent cleanup";
29052923
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_cleanup_complete, true /* log_heap_usage */);

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

+4
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ class ShenandoahHeap : public CollectedHeap {
386386
void entry_class_unloading();
387387
void entry_strong_roots();
388388
void entry_cleanup_early();
389+
void entry_rendezvous_roots();
389390
void entry_evac();
390391
void entry_updaterefs();
391392
void entry_cleanup_complete();
@@ -409,12 +410,15 @@ class ShenandoahHeap : public CollectedHeap {
409410
void op_class_unloading();
410411
void op_strong_roots();
411412
void op_cleanup_early();
413+
void op_rendezvous_roots();
412414
void op_conc_evac();
413415
void op_stw_evac();
414416
void op_updaterefs();
415417
void op_cleanup_complete();
416418
void op_uncommit(double shrink_before);
417419

420+
void rendezvous_threads();
421+
418422
// Messages for GC trace events, they have to be immortal for
419423
// passing around the logging/tracing systems
420424
const char* init_mark_event_message() const;

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

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class outputStream;
9999
f(conc_class_unload_purge_cldg, " CLDG") \
100100
f(conc_class_unload_purge_ec, " Exception Caches") \
101101
f(conc_strong_roots, "Concurrent Strong Roots") \
102+
f(conc_rendezvous_roots, "Rendezvous") \
102103
SHENANDOAH_PAR_PHASE_DO(conc_strong_roots_, " CSR: ", f) \
103104
f(conc_evac, "Concurrent Evacuation") \
104105
\

0 commit comments

Comments
 (0)
This repository has been archived.