Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index f8e6d499a473dcfd4d12d48c6aca32782fa02ca0..4dea51050d3f1a37e21b81ae7ea9ec53ceb4d341 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -2026,6 +2026,19 @@ class ScavengingVisitor : public StaticVisitorBase { |
AllocationResult allocation = |
heap->new_space()->AllocateRaw(allocation_size); |
heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); |
+ |
+ // Allocation in the other semi-space may fail due to fragmentation. |
+ // In that case we allocate in the old generation. |
+ if (allocation.IsRetry()) { |
+ if (object_contents == DATA_OBJECT) { |
+ ASSERT(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); |
+ allocation = heap->old_data_space()->AllocateRaw(allocation_size); |
+ } else { |
+ ASSERT(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); |
+ allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); |
+ } |
+ } |
+ |
HeapObject* target = HeapObject::cast(allocation.ToObjectChecked()); |
if (alignment != kObjectAlignment) { |