From 9e995fdd91e7088510e017b55d2ddc0611514c01 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Sat, 1 Feb 2014 10:35:36 +0000 Subject: [PATCH] Ensure the word after top is cleared in newspace if top < high. BUG= R=ulan@chromium.org Review URL: https://codereview.chromium.org/151783002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19014 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap-inl.h | 2 +- src/mark-compact.cc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index f55073ce9e..b1657ab987 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -488,7 +488,7 @@ void Heap::ScavengePointer(HeapObject** p) { void Heap::UpdateAllocationSiteFeedback(HeapObject* object) { Heap* heap = object->GetHeap(); - ASSERT(heap->InNewSpace(object)); + ASSERT(heap->InFromSpace(object)); if (!FLAG_allocation_site_pretenuring || !AllocationSite::CanTrack(object->map()->instance_type())) return; diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 81de035b0a..fc9f16627e 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -3007,6 +3007,20 @@ void MarkCompactCollector::EvacuateNewSpace() { new_space->Flip(); new_space->ResetAllocationInfo(); + // UpdateAllocationSiteFeedback expects that only objects at the end of + // newspace are not guaranteed to have the next word clear. It relies on + // FromSpacePageHigh to check whether an object is at the end of newspace. + // However, it is possible that newspace is being evacuated without it being + // full, e.g. to make the heap iterable, hence top will not equal high. In + // that case, fill up newspace with a filler to ensure the next word is + // cleared. + if (FLAG_allocation_site_pretenuring && + from_top < new_space->FromSpacePageHigh()) { + Address limit = NewSpacePage::FromLimit(from_top)->area_end(); + int remaining_in_page = static_cast(limit - from_top); + heap()->CreateFillerObjectAt(from_top, remaining_in_page); + } + int survivors_size = 0; // First pass: traverse all objects in inactive semispace, remove marks,