Reviewers: Michael Starzinger,

Message:
Fix issue 2194


https://codereview.chromium.org/11413009/diff/1/src/spaces.cc
File src/spaces.cc (right):

https://codereview.chromium.org/11413009/diff/1/src/spaces.cc#newcode2394
src/spaces.cc:2394: // until we find a size_in_bytes contiguous piece of
memory
there are so many heuristics all over the gc...

Description:
Remove eager sweeping for lazy swept spaces. Try to find in SlowAllocateRaw a
bounded number of times a big enough memory slot.


BUG=


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

SVN Base: https://v8.googlecode.com/svn/trunk

Affected files:
  M src/mark-compact.cc
  M src/spaces.cc


Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 1af3074f36c48f27c0689d2753ab865f8015447b..3672cd004460f058a78c868c4be4deb46ec7fbe3 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -3524,7 +3524,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {

   intptr_t freed_bytes = 0;
   int pages_swept = 0;
-  intptr_t newspace_size = space->heap()->new_space()->Size();
   bool lazy_sweeping_active = false;
   bool unused_page_present = false;

@@ -3587,15 +3586,8 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
         }
         freed_bytes += SweepConservatively(space, p);
         pages_swept++;
-        if (freed_bytes > 2 * newspace_size) {
-          space->SetPagesToSweep(p->next_page());
-          lazy_sweeping_active = true;
-        } else {
-          if (FLAG_gc_verbose) {
-            PrintF("Only %" V8PRIdPTR " bytes freed.  Still sweeping.\n",
-                   freed_bytes);
-          }
-        }
+        space->SetPagesToSweep(p->next_page());
+        lazy_sweeping_active = true;
         break;
       }
       case PRECISE: {
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 583b2ca5124982cda6302c4b6b62213b34c2752a..d03707ec8adcc0ce1d91e1a8e144f24faa09f47c 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -2390,10 +2390,14 @@ void PagedSpace::EvictEvacuationCandidatesFromFreeLists() {
 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
   // Allocation in this space has failed.

- // If there are unswept pages advance lazy sweeper then sweep one page before
-  // allocating a new page.
-  if (first_unswept_page_->is_valid()) {
-    AdvanceSweeper(size_in_bytes);
+ // If there are unswept pages advance lazy sweeper a bounded number of times
+  // until we find a size_in_bytes contiguous piece of memory
+  const int kMaxSweepingTries = 5;
+  const int kAllocationSweepingFactor = 10;
+  int i = 0;
+
+ for (i = 0; i < kMaxSweepingTries && first_unswept_page_->is_valid(); i++) {
+    AdvanceSweeper(size_in_bytes * kAllocationSweepingFactor);

     // Retry the free list allocation.
     HeapObject* object = free_list_.Allocate(size_in_bytes);


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to