Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index f8588b87e6eda4763e3f757a8deda15fa47fbd42..a6db39c58cde422c7536d22c2dab95a232a75f9e 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -768,6 +768,18 @@ bool Heap::CollectGarbage(AllocationSpace space, |
allocation_timeout_ = Max(6, FLAG_gc_interval); |
#endif |
+ // There may be an allocation memento behind every object in new space. |
+ // If we evacuate a not full new space or if we are on the last page of |
+ // the new space, then there may be uninitialized memory behind the top |
+ // pointer of the new space page. We store a filler object there to |
+ // identify the unused space. |
+ Address from_top = new_space_.top(); |
+ Address from_limit = new_space_.limit(); |
+ if (from_top < from_limit) { |
+ int remaining_in_page = static_cast<int>(from_limit - from_top); |
+ CreateFillerObjectAt(from_top, remaining_in_page); |
+ } |
+ |
if (collector == SCAVENGER && !incremental_marking()->IsStopped()) { |
if (FLAG_trace_incremental_marking) { |
PrintF("[IncrementalMarking] Scavenge during marking.\n"); |