Reviewers: jochen,

Description:
Sweep map space concurrently.

BUG=

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+25, -15 lines):
  M src/heap/mark-compact.h
  M src/heap/mark-compact.cc


Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 74e1b3f80f2e4331caa2bc0fa0326b7b2bde3434..7722b587d20c270d8afbf6af37a642f8e920c52f 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -227,6 +227,7 @@ static void VerifyEvacuation(Heap* heap) {
 void MarkCompactCollector::SetUp() {
   free_list_old_space_.Reset(new FreeList(heap_->old_space()));
   free_list_code_space_.Reset(new FreeList(heap_->code_space()));
+  free_list_map_space_.Reset(new FreeList(heap_->map_space()));
   EnsureMarkingDequeIsReserved();
   EnsureMarkingDequeIsCommitted(kMinMarkingDequeSize);
 }
@@ -494,12 +495,16 @@ class MarkCompactCollector::SweeperTask : public v8::Task {
 void MarkCompactCollector::StartSweeperThreads() {
   DCHECK(free_list_old_space_.get()->IsEmpty());
   DCHECK(free_list_code_space_.get()->IsEmpty());
+  DCHECK(free_list_map_space_.get()->IsEmpty());
   V8::GetCurrentPlatform()->CallOnBackgroundThread(
       new SweeperTask(heap(), heap()->old_space()),
       v8::Platform::kShortRunningTask);
   V8::GetCurrentPlatform()->CallOnBackgroundThread(
       new SweeperTask(heap(), heap()->code_space()),
       v8::Platform::kShortRunningTask);
+  V8::GetCurrentPlatform()->CallOnBackgroundThread(
+      new SweeperTask(heap(), heap()->map_space()),
+      v8::Platform::kShortRunningTask);
 }


@@ -511,18 +516,22 @@ void MarkCompactCollector::EnsureSweepingCompleted() {
   if (!heap()->concurrent_sweeping_enabled() || !IsSweepingCompleted()) {
     SweepInParallel(heap()->paged_space(OLD_SPACE), 0);
     SweepInParallel(heap()->paged_space(CODE_SPACE), 0);
+    SweepInParallel(heap()->paged_space(MAP_SPACE), 0);
   }
   // Wait twice for both jobs.
   if (heap()->concurrent_sweeping_enabled()) {
     pending_sweeper_jobs_semaphore_.Wait();
     pending_sweeper_jobs_semaphore_.Wait();
+    pending_sweeper_jobs_semaphore_.Wait();
   }
   ParallelSweepSpacesComplete();
   sweeping_in_progress_ = false;
   RefillFreeList(heap()->paged_space(OLD_SPACE));
   RefillFreeList(heap()->paged_space(CODE_SPACE));
+  RefillFreeList(heap()->paged_space(MAP_SPACE));
   heap()->paged_space(OLD_SPACE)->ResetUnsweptFreeBytes();
   heap()->paged_space(CODE_SPACE)->ResetUnsweptFreeBytes();
+  heap()->paged_space(MAP_SPACE)->ResetUnsweptFreeBytes();

 #ifdef VERIFY_HEAP
   if (FLAG_verify_heap && !evacuation()) {
@@ -549,6 +558,8 @@ void MarkCompactCollector::RefillFreeList(PagedSpace* space) {
     free_list = free_list_old_space_.get();
   } else if (space == heap()->code_space()) {
     free_list = free_list_code_space_.get();
+  } else if (space == heap()->map_space()) {
+    free_list = free_list_map_space_.get();
   } else {
     // Any PagedSpace might invoke RefillFreeLists, so we need to make sure
     // to only refill them for the old space.
@@ -4186,13 +4197,18 @@ int MarkCompactCollector::SweepInParallel(Page* page, PagedSpace* space) {
   if (page->TryParallelSweeping()) {
     FreeList* free_list;
     FreeList private_free_list(space);
-    if (space->identity() == CODE_SPACE) {
+    if (space->identity() == OLD_SPACE) {
+      free_list = free_list_old_space_.get();
+      max_freed =
+          Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, IGNORE_SKIP_LIST,
+                IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL);
+    } else if (space->identity() == CODE_SPACE) {
       free_list = free_list_code_space_.get();
       max_freed =
           Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, REBUILD_SKIP_LIST,
                 IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL);
     } else {
-      free_list = free_list_old_space_.get();
+      free_list = free_list_map_space_.get();
       max_freed =
           Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, IGNORE_SKIP_LIST,
                 IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL);
@@ -4262,7 +4278,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
                     IGNORE_FREE_SPACE>(space, NULL, p, NULL);
             }
           } else {
-            DCHECK(space->identity() == OLD_SPACE);
             Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
                   IGNORE_FREE_SPACE>(space, NULL, p, NULL);
           }
@@ -4291,8 +4306,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
                   IGNORE_FREE_SPACE>(space, NULL, p, NULL);
           }
         } else {
-          DCHECK(space->identity() == OLD_SPACE ||
-                 space->identity() == MAP_SPACE);
           Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
                 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
         }
@@ -4342,7 +4355,11 @@ void MarkCompactCollector::SweepSpaces() {
                                   GCTracer::Scope::MC_SWEEP_CODE);
       SweepSpace(heap()->code_space(), CONCURRENT_SWEEPING);
     }
-
+    {
+      GCTracer::Scope sweep_scope(heap()->tracer(),
+                                  GCTracer::Scope::MC_SWEEP_MAP);
+      SweepSpace(heap()->map_space(), CONCURRENT_SWEEPING);
+    }
     sweeping_in_progress_ = true;
     if (heap()->concurrent_sweeping_enabled()) {
       StartSweeperThreads();
@@ -4353,15 +4370,6 @@ void MarkCompactCollector::SweepSpaces() {

   heap()->FreeDeadArrayBuffers(false);

-  // ClearNonLiveReferences depends on precise sweeping of map space to
-  // detect whether unmarked map became dead in this collection or in one
-  // of the previous ones.
-  {
-    GCTracer::Scope sweep_scope(heap()->tracer(),
-                                GCTracer::Scope::MC_SWEEP_MAP);
-    SweepSpace(heap()->map_space(), SEQUENTIAL_SWEEPING);
-  }
-
   // Deallocate unmarked objects and clear marked bits for marked objects.
   heap_->lo_space()->FreeUnmarkedObjects();

@@ -4401,6 +4409,7 @@ void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) {
 void MarkCompactCollector::ParallelSweepSpacesComplete() {
   ParallelSweepSpaceComplete(heap()->old_space());
   ParallelSweepSpaceComplete(heap()->code_space());
+  ParallelSweepSpaceComplete(heap()->map_space());
 }


Index: src/heap/mark-compact.h
diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h
index f7dfedd93f876e8a0e5620bb3da4d13895479bde..5a12ebea3309aa8b4c5d84bbfd649d35028c7ce4 100644
--- a/src/heap/mark-compact.h
+++ b/src/heap/mark-compact.h
@@ -971,6 +971,7 @@ class MarkCompactCollector {

   SmartPointer<FreeList> free_list_old_space_;
   SmartPointer<FreeList> free_list_code_space_;
+  SmartPointer<FreeList> free_list_map_space_;

   friend class Heap;
 };


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