Commit 27f2d8ec authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

heap: Fix CHECK when adding slots for compaction

Bug: 957461
Change-Id: I24c54ad9a06e70acb87bfdaa424a678ebd8fbd84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1587029Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654833}
parent 0eff0570
...@@ -44,25 +44,28 @@ class HeapCompact::MovableObjectFixups final { ...@@ -44,25 +44,28 @@ class HeapCompact::MovableObjectFixups final {
} }
void Add(MovableReference* slot) { void Add(MovableReference* slot) {
MovableReference reference = *slot; MovableReference value = *slot;
CHECK(reference); CHECK(value);
// All slots and references are part of Oilpan's heap. // All slots and values are part of Oilpan's heap.
CHECK(heap_->LookupPageForAddress(reinterpret_cast<Address>(slot))); BasePage* const slot_page =
CHECK(heap_->LookupPageForAddress(reinterpret_cast<Address>(reference))); heap_->LookupPageForAddress(reinterpret_cast<Address>(slot));
CHECK(slot_page);
BasePage* const value_page =
heap_->LookupPageForAddress(reinterpret_cast<Address>(value));
CHECK(value_page);
BasePage* const reference_page = PageFromObject(reference);
// The following cases are not compacted and do not require recording: // The following cases are not compacted and do not require recording:
// - Backings in large pages. // - Backings in large pages.
// - Inline backings that are part of a non-backing arena. // - Inline backings that are part of a non-backing arena.
if (reference_page->IsLargeObjectPage() || if (value_page->IsLargeObjectPage() ||
!HeapCompact::IsCompactableArena(reference_page->Arena()->ArenaIndex())) !HeapCompact::IsCompactableArena(value_page->Arena()->ArenaIndex()))
return; return;
// Slots may have been recorded already but must point to the same // Slots may have been recorded already but must point to the same
// reference. Example: Ephemeron iterations may register slots multiple // value. Example: Ephemeron iterations may register slots multiple
// times. // times.
auto fixup_it = fixups_.find(reference); auto fixup_it = fixups_.find(value);
if (UNLIKELY(fixup_it != fixups_.end())) { if (UNLIKELY(fixup_it != fixups_.end())) {
CHECK_EQ(slot, fixup_it->second); CHECK_EQ(slot, fixup_it->second);
return; return;
...@@ -72,24 +75,27 @@ class HeapCompact::MovableObjectFixups final { ...@@ -72,24 +75,27 @@ class HeapCompact::MovableObjectFixups final {
// Slots must reside in live objects // Slots must reside in live objects
// Add regular fixup. // Add regular fixup.
fixups_.insert({reference, slot}); fixups_.insert({value, slot});
BasePage* const slot_page = PageFromObject(slot);
// Slots must reside in and references must point to live objects at this // Slots must reside in and values must point to live objects at this
// point, with the exception of slots in eagerly swept arenas where objects // point, with the exception of slots in eagerly swept arenas where objects
// have already been processed. |reference| usually points to a separate // have already been processed. |value| usually points to a separate
// backing store but can also point to inlined storage which is why the // backing store but can also point to inlined storage which is why the
// dynamic header lookup is required. // dynamic header lookup is required.
CHECK(reference_page->Arena()->ArenaIndex() != CHECK(value_page->Arena()->ArenaIndex() != BlinkGC::kEagerSweepArenaIndex);
BlinkGC::kEagerSweepArenaIndex); CHECK(static_cast<NormalPage*>(value_page)
CHECK(static_cast<NormalPage*>(reference_page) ->FindHeaderFromAddress(reinterpret_cast<Address>(value))
->FindHeaderFromAddress(reinterpret_cast<Address>(reference))
->IsMarked()); ->IsMarked());
CHECK(slot_page->Arena()->ArenaIndex() == BlinkGC::kEagerSweepArenaIndex || if (slot_page->IsLargeObjectPage()) {
CHECK(
static_cast<LargeObjectPage*>(slot_page)->ObjectHeader()->IsMarked());
} else {
CHECK(slot_page->Arena()->ArenaIndex() ==
BlinkGC::kEagerSweepArenaIndex ||
static_cast<NormalPage*>(slot_page) static_cast<NormalPage*>(slot_page)
->FindHeaderFromAddress(reinterpret_cast<Address>(slot)) ->FindHeaderFromAddress(reinterpret_cast<Address>(slot))
->IsMarked()); ->IsMarked());
}
// Check whether the slot itself resides on a page that is compacted. // Check whether the slot itself resides on a page that is compacted.
if (LIKELY(!relocatable_pages_.Contains(slot_page))) if (LIKELY(!relocatable_pages_.Contains(slot_page)))
......
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