Commit 6e5941d5 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Fix live bytes accounting in MinorMC

Live bytes were accounted twice. Once when object is marked black and
once explicitly by the marking task. Drop the accounting by the marking
task.

This should also help reduce binary size.

Bug: v8:12612, chromium:1331317
Change-Id: I43e90413309709662b6fcd0dfdec96cac1b5f231
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3732930
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81429}
parent 1a5cfc20
......@@ -5836,35 +5836,20 @@ class YoungGenerationMarkingTask {
MinorMarkCompactCollector::MarkingWorklist* global_worklist)
: marking_worklist_local_(global_worklist),
marking_state_(collector->marking_state()),
visitor_(isolate, marking_state_, &marking_worklist_local_) {
local_live_bytes_.reserve(isolate->heap()->new_space()->Capacity() /
Page::kPageSize);
}
visitor_(isolate, marking_state_, &marking_worklist_local_) {}
void MarkObject(Object object) {
if (!Heap::InYoungGeneration(object)) return;
HeapObject heap_object = HeapObject::cast(object);
if (marking_state_->WhiteToBlack(heap_object)) {
const int size = visitor_.Visit(heap_object);
IncrementLiveBytes(heap_object, size);
visitor_.Visit(heap_object);
}
}
void EmptyMarkingWorklist() {
HeapObject object;
while (marking_worklist_local_.Pop(&object)) {
const int size = visitor_.Visit(object);
IncrementLiveBytes(object, size);
}
}
void IncrementLiveBytes(HeapObject object, intptr_t bytes) {
local_live_bytes_[Page::FromHeapObject(object)] += bytes;
}
void FlushLiveBytes() {
for (auto pair : local_live_bytes_) {
marking_state_->IncrementLiveBytes(pair.first, pair.second);
visitor_.Visit(object);
}
}
......@@ -5872,7 +5857,6 @@ class YoungGenerationMarkingTask {
MinorMarkCompactCollector::MarkingWorklist::Local marking_worklist_local_;
MinorMarkCompactCollector::MarkingState* marking_state_;
YoungGenerationMarkingVisitor visitor_;
std::unordered_map<Page*, intptr_t, Page::Hasher> local_live_bytes_;
};
class PageMarkingItem : public ParallelWorkItem {
......@@ -5986,7 +5970,6 @@ class YoungGenerationMarkingJob : public v8::JobTask {
YoungGenerationMarkingTask task(isolate_, collector_, global_worklist_);
ProcessMarkingItems(&task);
task.EmptyMarkingWorklist();
task.FlushLiveBytes();
}
if (FLAG_trace_minor_mc_parallel_marking) {
PrintIsolate(collector_->isolate(), "marking[%p]: time=%f\n",
......
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