Promote objects if semi-space copy fails while scavenging.
authorhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Jun 2014 14:30:22 +0000 (14:30 +0000)
committerhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 24 Jun 2014 14:30:22 +0000 (14:30 +0000)
BUG=388188
LOG=N
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/351853006

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21980 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/heap.cc
src/mark-compact.cc

index f8e6d49..4dea510 100644 (file)
@@ -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) {
index b31d6ae..b7575b3 100644 (file)
@@ -2015,7 +2015,6 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
         continue;
       }
 
-      // Promotion failed. Just migrate object to another semispace.
       AllocationResult allocation = new_space->AllocateRaw(size);
       if (allocation.IsRetry()) {
         if (!new_space->AddFreshPage()) {