Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 13 additions & 5 deletions src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,22 +567,26 @@ void ShenandoahHeapRegion::recycle_internal() {
ShenandoahHeap* heap = ShenandoahHeap::heap();

_mixed_candidate_garbage_words = 0;
set_top(bottom());
clear_live_data();
reset_alloc_metadata();
heap->marking_context()->reset_top_at_mark_start(this);
set_update_watermark(bottom());
if (ZapUnusedHeapArea) {
SpaceMangler::mangle_region(MemRegion(bottom(), top()));
}
set_top(bottom());
set_affiliation(FREE);

// Lastly, set region state to empty
make_empty();
set_affiliation(FREE);
}

void ShenandoahHeapRegion::try_recycle_under_lock() {
shenandoah_assert_heaplocked();
if (is_trash() && _recycling.try_set()) {
if (!is_trash()) {
return;
}
if (_recycling.try_set()) {
if (is_trash()) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahGeneration* generation = heap->generation_for(affiliation());
Expand All @@ -602,12 +606,16 @@ void ShenandoahHeapRegion::try_recycle_under_lock() {
os::naked_yield();
}
}
assert(!is_trash(), "Must not");
}
}

void ShenandoahHeapRegion::try_recycle() {
shenandoah_assert_not_heaplocked();
if (is_trash() && _recycling.try_set()) {
if (!is_trash()) {
return;
}
if (_recycling.try_set()) {
// Double check region state after win the race to set recycling flag
if (is_trash()) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
Expand Down Expand Up @@ -827,7 +835,7 @@ void ShenandoahHeapRegion::set_state(RegionState to) {
evt.set_to(to);
evt.commit();
}
Atomic::store(&_state, to);
Atomic::release_store(&_state, to);
}

void ShenandoahHeapRegion::record_pin() {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ShenandoahHeapRegion {
bool is_alloc_allowed() const { auto cur_state = state(); return is_empty_state(cur_state) || cur_state == _regular || cur_state == _pinned; }
bool is_stw_move_allowed() const { auto cur_state = state(); return cur_state == _regular || cur_state == _cset || (ShenandoahHumongousMoves && cur_state == _humongous_start); }

RegionState state() const { return Atomic::load(&_state); }
RegionState state() const { return Atomic::load_acquire(&_state); }
int state_ordinal() const { return region_state_to_ordinal(state()); }

void record_pin();
Expand Down