Remove promotion backup case and report OOM instead.
authorhpayer <hpayer@chromium.org>
Thu, 5 Mar 2015 18:38:30 +0000 (10:38 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 5 Mar 2015 18:38:38 +0000 (18:38 +0000)
There are no test cases for this piece of code and it is really hard to test. If this rare case triggers, we are anyway in an OOM situation and would crash probably soon afterwards.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#27026}

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

index 16b5deccf6ebf97253d04db7e49c8a40f2285ac8..7c9130d41a9c92286da176f8eebbeea2e5120ad6 100644 (file)
@@ -2207,11 +2207,7 @@ class ScavengingVisitor : public StaticVisitorBase {
                                                   object_size)) {
       return;
     }
-
-    // If promotion failed, we try to copy the object to the other semi-space
-    if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
-
-    UNREACHABLE();
+    V8::FatalProcessOutOfMemory("Scavenge promotion failed");
   }
 
 
index 77d084266264fbd78f56bc16115818a92b223ff4..1c5299fb6021b67fbcfd16e41bf81c6010660faa 100644 (file)
@@ -1861,26 +1861,27 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage(
       current_cell >>= 1;
 
       // TODO(hpayer): Refactor EvacuateObject and call this function instead.
-      if (heap()->ShouldBePromoted(object->address(), size) &&
-          TryPromoteObject(object, size)) {
-        continue;
-      }
-
-      AllocationResult allocation = new_space->AllocateRaw(size);
-      if (allocation.IsRetry()) {
-        if (!new_space->AddFreshPage()) {
-          // Shouldn't happen. We are sweeping linearly, and to-space
-          // has the same number of pages as from-space, so there is
-          // always room.
-          UNREACHABLE();
+      if (heap()->ShouldBePromoted(object->address(), size)) {
+        if (!TryPromoteObject(object, size)) {
+          V8::FatalProcessOutOfMemory("Full GC promotion failed");
         }
-        allocation = new_space->AllocateRaw(size);
-        DCHECK(!allocation.IsRetry());
-      }
-      Object* target = allocation.ToObjectChecked();
+      } else {
+        AllocationResult allocation = new_space->AllocateRaw(size);
+        if (allocation.IsRetry()) {
+          if (!new_space->AddFreshPage()) {
+            // Shouldn't happen. We are sweeping linearly, and to-space
+            // has the same number of pages as from-space, so there is
+            // always room.
+            UNREACHABLE();
+          }
+          allocation = new_space->AllocateRaw(size);
+          DCHECK(!allocation.IsRetry());
+        }
+        Object* target = allocation.ToObjectChecked();
 
-      MigrateObject(HeapObject::cast(target), object, size, NEW_SPACE);
-      heap()->IncrementSemiSpaceCopiedObjectSize(size);
+        MigrateObject(HeapObject::cast(target), object, size, NEW_SPACE);
+        heap()->IncrementSemiSpaceCopiedObjectSize(size);
+      }
     }
     *cells = 0;
   }