Revision: 22090
Author:   [email protected]
Date:     Mon Jun 30 12:39:06 2014 UTC
Log:      Waiting for sweeper threads is last resort in SlowAllocateRaw.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/356403002
http://code.google.com/p/v8/source/detail?r=22090

Modified:
 /branches/bleeding_edge/src/spaces.cc
 /branches/bleeding_edge/src/spaces.h

=======================================
--- /branches/bleeding_edge/src/spaces.cc       Thu Jun 26 11:49:39 2014 UTC
+++ /branches/bleeding_edge/src/spaces.cc       Mon Jun 30 12:39:06 2014 UTC
@@ -2575,6 +2575,22 @@
     allocation_info_.set_limit(NULL);
   }
 }
+
+
+HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation(
+    int size_in_bytes) {
+  MarkCompactCollector* collector = heap()->mark_compact_collector();
+
+  // If sweeper threads are still running, wait for them.
+  if (collector->IsConcurrentSweepingInProgress()) {
+    collector->WaitUntilSweepingCompleted();
+
+    // After waiting for the sweeper threads, there may be new free-list
+    // entries.
+    return free_list_.Allocate(size_in_bytes);
+  }
+  return NULL;
+}


 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
@@ -2593,19 +2609,12 @@
// Free list allocation failed and there is no next page. Fail if we have
   // hit the old generation size limit that should cause a garbage
   // collection.
-  if (!heap()->always_allocate() &&
-      heap()->OldGenerationAllocationLimitReached()) {
-    // If sweeper threads are active, wait for them at that point.
-     if (collector->IsConcurrentSweepingInProgress()) {
-       collector->WaitUntilSweepingCompleted();
-
-       // After waiting for the sweeper threads, there may be new free-list
-       // entries.
-       HeapObject* object = free_list_.Allocate(size_in_bytes);
-       if (object != NULL) return object;
-     }
-
-    return NULL;
+  if (!heap()->always_allocate()
+      && heap()->OldGenerationAllocationLimitReached()) {
+    // If sweeper threads are active, wait for them at that point and steal
+    // elements form their free-lists.
+ HeapObject* object = WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
+    if (object != NULL) return object;
   }

   // Try to expand the space and allocate in the new next page.
@@ -2614,8 +2623,10 @@
     return free_list_.Allocate(size_in_bytes);
   }

-  // Finally, fail.
-  return NULL;
+  // If sweeper threads are active, wait for them at that point and steal
+  // elements form their free-lists. Allocation may still fail their which
+ // would indicate that there is not enough memory for the given allocation.
+  return WaitForSweeperThreadsAndRetryAllocation(size_in_bytes);
 }


=======================================
--- /branches/bleeding_edge/src/spaces.h        Fri Jun 20 10:31:17 2014 UTC
+++ /branches/bleeding_edge/src/spaces.h        Mon Jun 30 12:39:06 2014 UTC
@@ -2007,8 +2007,11 @@
   // address denoted by top in allocation_info_.
   inline HeapObject* AllocateLinearly(int size_in_bytes);

+  MUST_USE_RESULT HeapObject*
+      WaitForSweeperThreadsAndRetryAllocation(int size_in_bytes);
+
   // Slow path of AllocateRaw.  This function is space-dependent.
-  MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes);
+  MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes);

   friend class PageIterator;
   friend class MarkCompactCollector;

--
--
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