Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ef902fc
Retire gc labs concurrently
earthling-amzn Nov 7, 2024
1a37f08
Retire mutator gc labs with handshake
earthling-amzn Nov 8, 2024
d6ef283
Restore gc labs to safepoint workers
earthling-amzn Nov 8, 2024
d098df7
Fix safepoint worker handling
earthling-amzn Nov 11, 2024
7045763
Anticipate future work with better names for things
earthling-amzn Nov 12, 2024
5d3eac6
Add comments to new method
earthling-amzn Nov 12, 2024
17c25ea
Fix builds
earthling-amzn Nov 13, 2024
e7e1b8f
WIP: Control thread needs to know gc state too
earthling-amzn Nov 12, 2024
5bbdfe5
WIP: Figuring out which threads really need local gc-state and which …
earthling-amzn Nov 13, 2024
39de5c6
Propagate gc state to worker threads for full GC
earthling-amzn Nov 13, 2024
0ba2fb9
Only safepoint for init-update-refs when verify or pacing is enabled
earthling-amzn Nov 14, 2024
21f278c
Use thread local gc state here
earthling-amzn Nov 14, 2024
1af18b9
Okay, VMThread can have a thread local copy of gc state too
earthling-amzn Nov 15, 2024
645bb3b
Do not verify after gc before gc is completed
earthling-amzn Dec 5, 2024
6dbdf1c
Merge remote-tracking branch 'jdk/master' into remove-init-update-refs
earthling-amzn Dec 5, 2024
a580cb9
Allow access to pointers in trash regions during weak roots
earthling-amzn Dec 5, 2024
dbd7571
Revert "Do not verify after gc before gc is completed"
earthling-amzn Dec 6, 2024
bc49475
Revert "Allow access to pointers in trash regions during weak roots"
earthling-amzn Dec 6, 2024
77fedcd
Allow weak roots in progress from thread local or global variable
earthling-amzn Dec 6, 2024
218b1cc
Hide thread local usage behind existing APIs
earthling-amzn Dec 10, 2024
68ec004
Merge tag 'jdk-25+1' into two-steps-backward
earthling-amzn Dec 10, 2024
76452f5
Revert unnecessary changes
earthling-amzn Dec 10, 2024
24e487a
Encapsulate gc state
earthling-amzn Dec 10, 2024
d457c45
Remove unnecessary gc state propagations
earthling-amzn Dec 11, 2024
6db0a6b
WIP: Use Threads::threads_do for propagating gc state
earthling-amzn Dec 11, 2024
efa97ea
WIP: Use Threads::threads_do for propagating gc state (consolidated)
earthling-amzn Dec 11, 2024
4c8e705
Fix phase encoding to handle weak roots
earthling-amzn Dec 11, 2024
2422c3e
Merge remote-tracking branch 'jdk/master' into remove-init-update-ref…
earthling-amzn Dec 11, 2024
3b8d7f8
Fix comment, revert unnecessary change
earthling-amzn Dec 11, 2024
9aaef70
Fix comments
earthling-amzn Dec 11, 2024
71d691a
Merge remote-tracking branch 'jdk/master' into remove-init-update-ref…
earthling-amzn Jan 8, 2025
83ac7b4
Improve comments
earthling-amzn Jan 9, 2025
89c20a1
Improve comments and method names
earthling-amzn Jan 10, 2025
f319048
Control thread doesn't need a gc lab, also make gclabs for safepoint …
earthling-amzn Jan 13, 2025
26e382c
Encapsulate and document a method for making concurrent gc_state changes
earthling-amzn Jan 13, 2025
cf315b3
Merge tag 'jdk-25+5' into remove-init-update-refs-safepoint
earthling-amzn Jan 13, 2025
ab808a1
Call out the non-java threads we are most concerned with in the comment
earthling-amzn Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load

oop fwd = resolve_forwarded_not_null_mutator(obj);
if (obj == fwd) {
assert(_heap->is_evacuation_in_progress(),
"evac should be in progress");
assert(_heap->is_evacuation_in_progress(), "evac should be in progress");
Thread* const t = Thread::current();
ShenandoahEvacOOMScope scope(t);
fwd = _heap->evacuate_object(obj, t);
Expand All @@ -86,8 +85,8 @@ inline oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
if (!ShenandoahLoadRefBarrier) {
return obj;
}
if (_heap->has_forwarded_objects() &&
_heap->in_collection_set(obj)) { // Subsumes null-check
if (_heap->has_forwarded_objects() && _heap->in_collection_set(obj)) {
// Subsumes null-check
assert(obj != nullptr, "cset check must have subsumed null-check");
oop fwd = resolve_forwarded_not_null(obj);
if (obj == fwd && _heap->is_evacuation_in_progress()) {
Expand Down Expand Up @@ -381,7 +380,7 @@ void ShenandoahBarrierSet::arraycopy_work(T* src, size_t count) {
// this barrier will be called with ENQUEUE=true and HAS_FWD=false, even though the young generation
// may have forwarded objects. In this case, the `arraycopy_work` is first called with HAS_FWD=true and
// ENQUEUE=false.
assert(HAS_FWD == _heap->has_forwarded_objects() || (_heap->gc_state() & ShenandoahHeap::OLD_MARKING) != 0,
assert(HAS_FWD == _heap->has_forwarded_objects() || _heap->is_concurrent_old_mark_in_progress(),
"Forwarded object status is sane");
// This function cannot be called to handle marking and evacuation at the same time (they operate on
// different sides of the copy).
Expand Down Expand Up @@ -418,7 +417,7 @@ void ShenandoahBarrierSet::arraycopy_barrier(T* src, T* dst, size_t count) {
return;
}

int gc_state = _heap->gc_state();
char gc_state = ShenandoahThreadLocalData::gc_state(Thread::current());
if ((gc_state & ShenandoahHeap::EVACUATION) != 0) {
arraycopy_evacuation(src, count);
} else if ((gc_state & ShenandoahHeap::UPDATEREFS) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ void ShenandoahBarrierSet::clone_barrier(oop obj) {
assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");
shenandoah_assert_correct(nullptr, obj);

int gc_state = _heap->gc_state();
if ((gc_state & ShenandoahHeap::EVACUATION) != 0) {
if (_heap->is_evacuation_in_progress()) {
clone_evacuation(obj);
} else {
clone_update(obj);
Expand Down
43 changes: 17 additions & 26 deletions src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,14 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
return false;
}

// Evacuation is complete, retire gc labs
heap->concurrent_prepare_for_update_refs();

// Perform update-refs phase.
vmop_entry_init_updaterefs();
if (ShenandoahVerify || ShenandoahPacing) {
vmop_entry_init_updaterefs();
}

entry_updaterefs();
if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_updaterefs)) {
return false;
Expand Down Expand Up @@ -748,10 +754,6 @@ void ShenandoahConcurrentGC::op_final_mark() {
heap->verifier()->verify_after_concmark();
}
}

if (VerifyAfterGC) {
Universe::verify();
}
}
}
}
Expand Down Expand Up @@ -920,8 +922,8 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask {
}

// 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.
// clean up the weak oops in CLD and determine nmethod's unloading state, so that we
// can clean up immediate garbage sooner.
if (ShenandoahHeap::heap()->unload_classes()) {
// Applies ShenandoahIsCLDAlive closure to CLDs, native barrier will either null the
// CLD's holder or evacuate it.
Expand All @@ -947,21 +949,10 @@ void ShenandoahConcurrentGC::op_weak_roots() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
assert(heap->is_concurrent_weak_root_in_progress(), "Only during this phase");
// Concurrent weak root processing
{
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_work);
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots_work);
ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots_work);
heap->workers()->run_task(&task);
}

// Perform handshake to flush out dead oops
{
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_rendezvous);
heap->rendezvous_threads("Shenandoah Concurrent Weak Roots");
}
// We can only toggle concurrent_weak_root_in_progress flag
// at a safepoint, so that mutators see a consistent
// value. The flag will be cleared at the next safepoint.
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_work);
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots_work);
ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots_work);
heap->workers()->run_task(&task);
}

void ShenandoahConcurrentGC::op_class_unloading() {
Expand Down Expand Up @@ -1058,10 +1049,6 @@ void ShenandoahConcurrentGC::op_evacuate() {

void ShenandoahConcurrentGC::op_init_updaterefs() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
heap->set_evacuation_in_progress(false);
heap->set_concurrent_weak_root_in_progress(false);
heap->prepare_update_heap_references(true /*concurrent*/);
heap->set_update_refs_in_progress(true);
if (ShenandoahVerify) {
heap->verifier()->verify_before_updaterefs();
}
Expand Down Expand Up @@ -1178,6 +1165,10 @@ void ShenandoahConcurrentGC::op_final_roots() {
ShenandoahGenerationalHeap::heap()->update_region_ages(_generation->complete_marking_context());
}
}

if (VerifyAfterGC) {
Universe::verify();
}
}

void ShenandoahConcurrentGC::op_cleanup_complete() {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,8 @@ HeapWord* ShenandoahFreeSet::allocate_aligned_plab(size_t size, ShenandoahAllocR
HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) {
assert (has_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->index());
if (_heap->is_concurrent_weak_root_in_progress() && r->is_trash()) {
// We cannot use this region for allocation when weak roots are in progress because the collector may need
// to reference unmarked oops during concurrent classunloading.
return nullptr;
}
HeapWord* result = nullptr;
Expand Down
Loading