Commit deb0c9c1 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Update marked bytes when making the heap consistent for snapshots

Live bytes are computed during sweeping for regular garbage collection.
The live bytes computation was missing from the logic that makes the
heap consistent after performing marking just for taking a snapshot.
The result is that ProcessHeap counters are not usable when just
performing a garbage collection for snapshots as the counters would
always be zeroed out.

Bug: chromium:865438
Change-Id: Id0d7e7a75895a6e6bb0ae62959f3e7a36b3d26fa
Reviewed-on: https://chromium-review.googlesource.com/1155121Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579339}
parent e068840a
......@@ -1496,6 +1496,7 @@ void NormalPage::SweepAndCompact(CompactionContext& context) {
void NormalPage::MakeConsistentForMutator() {
object_start_bit_map()->Clear();
size_t marked_object_size = 0;
Address start_of_gap = Payload();
NormalPageArena* normal_arena = ArenaForNormalPage();
for (Address header_address = Payload(); header_address < PayloadEnd();) {
......@@ -1519,6 +1520,7 @@ void NormalPage::MakeConsistentForMutator() {
normal_arena->AddToFreeList(start_of_gap, header_address - start_of_gap);
if (header->IsMarked()) {
header->Unmark();
marked_object_size += size;
}
object_start_bit_map()->SetBit(header_address);
header_address += size;
......@@ -1528,6 +1530,11 @@ void NormalPage::MakeConsistentForMutator() {
if (start_of_gap != PayloadEnd())
normal_arena->AddToFreeList(start_of_gap, PayloadEnd() - start_of_gap);
if (marked_object_size) {
ArenaForNormalPage()->GetThreadState()->Heap().IncreaseMarkedObjectSize(
marked_object_size);
}
VerifyObjectStartBitmapIsConsistentWithPayload();
}
......@@ -1709,8 +1716,10 @@ bool LargeObjectPage::Sweep() {
void LargeObjectPage::MakeConsistentForMutator() {
HeapObjectHeader* header = ObjectHeader();
if (header->IsMarked())
if (header->IsMarked()) {
header->Unmark();
Arena()->GetThreadState()->Heap().IncreaseMarkedObjectSize(size());
}
}
#if defined(ADDRESS_SANITIZER)
......
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