Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index 81de035b0af7a6ae67de51f738b30ecbdbcb2da5..fc9f16627e423910358d2cbdec0707f3fd44fe9f 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<int>(limit - from_top); |
+ heap()->CreateFillerObjectAt(from_top, remaining_in_page); |
+ } |
+ |
int survivors_size = 0; |
// First pass: traverse all objects in inactive semispace, remove marks, |