Reviewers: jarin, Michael Starzinger,

https://codereview.chromium.org/351853006/diff/20001/src/mark-compact.cc
File src/mark-compact.cc (left):

https://codereview.chromium.org/351853006/diff/20001/src/mark-compact.cc#oldcode2018
src/mark-compact.cc:2018: // Promotion failed. Just migrate object to
another semispace.
Removed the outdated comment.

Note, here the invariant still holds since we linearly sweep the new
space (see comment below).

Description:
Promote objects if semi-space copy fails while scavenging.

BUG=

Please review this at https://codereview.chromium.org/351853006/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+13, -1 lines):
  M src/heap.cc
  M src/mark-compact.cc


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) {
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index b31d6ae93e6256ce02ae59fbc3e2149dc407dbda..b7575b3ab2a8faa3ca6de69b60c839e418f745b0 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -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()) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to