8242641: Shenandoah: clear live data and update TAMS optimistically

Reviewed-by: rkennke
This commit is contained in:
Aleksey Shipilev 2020-04-14 22:18:37 +02:00
parent a7a361ff32
commit 6669c5e73e

View File

@ -1358,11 +1358,14 @@ public:
ShenandoahInitMarkUpdateRegionStateClosure() : _ctx(ShenandoahHeap::heap()->marking_context()) {}
void heap_region_do(ShenandoahHeapRegion* r) {
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index());
if (r->is_active()) {
r->clear_live_data();
_ctx->capture_top_at_mark_start(r);
// Check if region needs updating its TAMS. We have updated it already during concurrent
// reset, so it is very likely we don't need to do another write here.
if (_ctx->top_at_mark_start(r) != r->top()) {
_ctx->capture_top_at_mark_start(r);
}
} else {
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index());
assert(_ctx->top_at_mark_start(r) == r->top(),
"Region " SIZE_FORMAT " should already have correct TAMS", r->index());
}
@ -1651,11 +1654,32 @@ void ShenandoahHeap::op_roots() {
set_concurrent_root_in_progress(false);
}
class ShenandoahResetUpdateRegionStateClosure : public ShenandoahHeapRegionClosure {
private:
ShenandoahMarkingContext* const _ctx;
public:
ShenandoahResetUpdateRegionStateClosure() : _ctx(ShenandoahHeap::heap()->marking_context()) {}
void heap_region_do(ShenandoahHeapRegion* r) {
if (r->is_active()) {
// Reset live data and set TAMS optimistically. We would recheck these under the pause
// anyway to capture any updates that happened since now.
r->clear_live_data();
_ctx->capture_top_at_mark_start(r);
}
}
bool is_thread_safe() { return true; }
};
void ShenandoahHeap::op_reset() {
if (ShenandoahPacing) {
pacer()->setup_for_reset();
}
reset_mark_bitmap();
ShenandoahResetUpdateRegionStateClosure cl;
parallel_heap_region_iterate(&cl);
}
void ShenandoahHeap::op_preclean() {