Commit 18ced8a5 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

heap: Young gen cleanups

Various cleanups around young generation GCs.

These include:
(*) Repalce minor_mark_compact_collector_ with a unique_ptr and merge
    initialization with the mark_compact_collector_ and
    scavenger_collector_.
(*) Rename IncrementalMarking::UpdateMarkingWorklistAfterScavenge to
    IncrementalMarking::UpdateMarkingWorklistAfterYoungGenGC.
(*) Remove redundant MarkingTreatmentMode parameter from
    MakeIterable.

Bug: v8:12612
Change-Id: Ifac7006d3425808a4b9e4c8e1af054a60c073180
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3448380Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79077}
parent 284aa5e3
......@@ -2626,7 +2626,7 @@ void Heap::MinorMarkCompact() {
incremental_marking());
ConcurrentMarking::PauseScope pause_scope(concurrent_marking());
minor_mark_compact_collector()->CollectGarbage();
minor_mark_compact_collector_->CollectGarbage();
SetGCState(NOT_IN_GC);
}
......@@ -4693,7 +4693,7 @@ class OldToNewSlotVerifyingVisitor : public SlotVerifyingVisitor {
void VisitEphemeron(HeapObject host, int index, ObjectSlot key,
ObjectSlot target) override {
VisitPointer(host, target);
if (FLAG_minor_mc) return VisitPointer(host, target);
if (FLAG_minor_mc) return;
// Keys are handled separately and should never appear in this set.
CHECK(!InUntypedSet(key));
Object k = *key;
......@@ -5775,6 +5775,7 @@ void Heap::SetUp(LocalHeap* main_thread_local_heap) {
mark_compact_collector_.reset(new MarkCompactCollector(this));
scavenger_collector_.reset(new ScavengerCollector(this));
minor_mark_compact_collector_.reset(new MinorMarkCompactCollector(this));
incremental_marking_.reset(
new IncrementalMarking(this, mark_compact_collector_->weak_objects()));
......@@ -5869,7 +5870,6 @@ void Heap::SetUpSpaces(LinearAllocationArea* new_allocation_info,
}
tracer_.reset(new GCTracer(this));
minor_mark_compact_collector_ = new MinorMarkCompactCollector(this);
array_buffer_sweeper_.reset(new ArrayBufferSweeper(this));
gc_idle_time_handler_.reset(new GCIdleTimeHandler());
memory_measurement_.reset(new MemoryMeasurement(isolate()));
......@@ -5890,8 +5890,8 @@ void Heap::SetUpSpaces(LinearAllocationArea* new_allocation_info,
LOG(isolate_, IntPtrTEvent("heap-available", Available()));
mark_compact_collector()->SetUp();
if (minor_mark_compact_collector() != nullptr) {
minor_mark_compact_collector()->SetUp();
if (minor_mark_compact_collector_) {
minor_mark_compact_collector_->SetUp();
}
if (new_space()) {
......@@ -6171,10 +6171,9 @@ void Heap::TearDown() {
mark_compact_collector_.reset();
}
if (minor_mark_compact_collector_ != nullptr) {
if (minor_mark_compact_collector_) {
minor_mark_compact_collector_->TearDown();
delete minor_mark_compact_collector_;
minor_mark_compact_collector_ = nullptr;
minor_mark_compact_collector_.reset();
}
scavenger_collector_.reset();
......
......@@ -870,7 +870,7 @@ class Heap {
}
MinorMarkCompactCollector* minor_mark_compact_collector() {
return minor_mark_compact_collector_;
return minor_mark_compact_collector_.get();
}
ArrayBufferSweeper* array_buffer_sweeper() {
......@@ -2327,7 +2327,7 @@ class Heap {
std::unique_ptr<GCTracer> tracer_;
std::unique_ptr<MarkCompactCollector> mark_compact_collector_;
MinorMarkCompactCollector* minor_mark_compact_collector_ = nullptr;
std::unique_ptr<MinorMarkCompactCollector> minor_mark_compact_collector_;
std::unique_ptr<ScavengerCollector> scavenger_collector_;
std::unique_ptr<ArrayBufferSweeper> array_buffer_sweeper_;
......
......@@ -436,7 +436,7 @@ void IncrementalMarking::FinalizeIncrementally() {
}
}
void IncrementalMarking::UpdateMarkingWorklistAfterScavenge() {
void IncrementalMarking::UpdateMarkingWorklistAfterYoungGenGC() {
if (!IsMarking()) return;
Map filler_map = ReadOnlyRoots(heap_).one_pointer_filler_map();
......
......@@ -138,7 +138,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
void FinalizeIncrementally();
void UpdateMarkingWorklistAfterScavenge();
void UpdateMarkingWorklistAfterYoungGenGC();
void UpdateMarkedBytesAfterScavenge(size_t dead_bytes_in_new_space);
void Hurry();
......
......@@ -5288,7 +5288,7 @@ void MinorMarkCompactCollector::CollectGarbage() {
{
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARKING_DEQUE);
heap()->incremental_marking()->UpdateMarkingWorklistAfterScavenge();
heap()->incremental_marking()->UpdateMarkingWorklistAfterYoungGenGC();
}
{
......@@ -5314,8 +5314,7 @@ void MinorMarkCompactCollector::CollectGarbage() {
}
void MinorMarkCompactCollector::MakeIterable(
Page* p, MarkingTreatmentMode marking_mode,
FreeSpaceTreatmentMode free_space_mode) {
Page* p, FreeSpaceTreatmentMode free_space_mode) {
CHECK(!p->IsLargePage());
// We have to clear the full collectors markbits for the areas that we
// remove here.
......@@ -5357,11 +5356,6 @@ void MinorMarkCompactCollector::MakeIterable(
p->heap()->CreateFillerObjectAt(free_start, static_cast<int>(size),
ClearRecordedSlots::kNo);
}
if (marking_mode == MarkingTreatmentMode::CLEAR) {
non_atomic_marking_state()->ClearLiveness(p);
p->ClearFlag(Page::SWEEP_TO_ITERATE);
}
}
namespace {
......@@ -5935,14 +5929,12 @@ void YoungGenerationEvacuator::RawEvacuatePage(MemoryChunk* chunk,
marking_state->live_bytes(chunk));
if (!chunk->IsLargePage()) {
if (heap()->ShouldZapGarbage()) {
collector_->MakeIterable(static_cast<Page*>(chunk),
MarkingTreatmentMode::KEEP, ZAP_FREE_SPACE);
collector_->MakeIterable(static_cast<Page*>(chunk), ZAP_FREE_SPACE);
} else if (heap()->incremental_marking()->IsMarking()) {
// When incremental marking is on, we need to clear the mark bits of
// the full collector. We cannot yet discard the young generation mark
// bits as they are still relevant for pointers updating.
collector_->MakeIterable(static_cast<Page*>(chunk),
MarkingTreatmentMode::KEEP,
IGNORE_FREE_SPACE);
}
}
......@@ -5955,14 +5947,12 @@ void YoungGenerationEvacuator::RawEvacuatePage(MemoryChunk* chunk,
marking_state->live_bytes(chunk));
DCHECK(!chunk->IsLargePage());
if (heap()->ShouldZapGarbage()) {
collector_->MakeIterable(static_cast<Page*>(chunk),
MarkingTreatmentMode::KEEP, ZAP_FREE_SPACE);
collector_->MakeIterable(static_cast<Page*>(chunk), ZAP_FREE_SPACE);
} else if (heap()->incremental_marking()->IsMarking()) {
// When incremental marking is on, we need to clear the mark bits of
// the full collector. We cannot yet discard the young generation mark
// bits as they are still relevant for pointers updating.
collector_->MakeIterable(static_cast<Page*>(chunk),
MarkingTreatmentMode::KEEP, IGNORE_FREE_SPACE);
collector_->MakeIterable(static_cast<Page*>(chunk), IGNORE_FREE_SPACE);
}
break;
case kObjectsOldToOld:
......
......@@ -187,7 +187,6 @@ class LiveObjectVisitor : AllStatic {
enum class AlwaysPromoteYoung { kYes, kNo };
enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD };
enum class MarkingTreatmentMode { KEEP, CLEAR };
enum class RememberedSetUpdatingMode { ALL, OLD_TO_NEW_ONLY };
// Base class for minor and full MC collectors.
......@@ -865,8 +864,7 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
void TearDown() override;
void CollectGarbage() override;
void MakeIterable(Page* page, MarkingTreatmentMode marking_mode,
FreeSpaceTreatmentMode free_space_mode);
void MakeIterable(Page* page, FreeSpaceTreatmentMode free_space_mode);
void CleanupSweepToIteratePages();
private:
......
......@@ -414,7 +414,7 @@ void ScavengerCollector::CollectGarbage() {
heap_->UpdateYoungReferencesInExternalStringTable(
&Heap::UpdateYoungReferenceInExternalStringTableEntry);
heap_->incremental_marking()->UpdateMarkingWorklistAfterScavenge();
heap_->incremental_marking()->UpdateMarkingWorklistAfterYoungGenGC();
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
heap_->UpdateRetainersAfterScavenge();
......
......@@ -1368,9 +1368,6 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource {
};
TEST(InternalizeExternal) {
// TODO(mlippautz): Remove once we add support for forwarding ThinStrings in
// minor MC
if (FLAG_minor_mc) return;
FLAG_stress_incremental_marking = false;
CcTest::InitializeVM();
i::Isolate* isolate = CcTest::i_isolate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment