Index: src/heap/mark-compact.cc |
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
index 7e6fc61f7c86de7f464f1dfa4dad5d0de6bcd486..7f98b33ec508509c858f20078a5548009ed9d941 100644 |
--- a/src/heap/mark-compact.cc |
+++ b/src/heap/mark-compact.cc |
@@ -6,7 +6,6 @@ |
#include "src/base/atomicops.h" |
#include "src/base/bits.h" |
-#include "src/base/sys-info.h" |
#include "src/code-stubs.h" |
#include "src/compilation-cache.h" |
#include "src/cpu-profiler.h" |
@@ -3368,39 +3367,26 @@ |
} |
-int MarkCompactCollector::NumberOfParallelCompactionTasks() { |
- if (!FLAG_parallel_compaction) return 1; |
- // We cap the number of parallel compaction tasks by |
- // - (#cores - 1) |
- // - a value depending on the list of evacuation candidates |
- // - a hard limit |
- const int kPagesPerCompactionTask = 4; |
- const int kMaxCompactionTasks = 8; |
- return Min(kMaxCompactionTasks, |
- Min(1 + evacuation_candidates_.length() / kPagesPerCompactionTask, |
- Max(1, base::SysInfo::NumberOfProcessors() - 1))); |
-} |
- |
- |
void MarkCompactCollector::EvacuatePagesInParallel() { |
if (evacuation_candidates_.length() == 0) return; |
- const int num_tasks = NumberOfParallelCompactionTasks(); |
+ int num_tasks = 1; |
+ if (FLAG_parallel_compaction) { |
+ num_tasks = NumberOfParallelCompactionTasks(); |
+ } |
// Set up compaction spaces. |
CompactionSpaceCollection** compaction_spaces_for_tasks = |
new CompactionSpaceCollection*[num_tasks]; |
- FreeList** free_lists = new FreeList*[2 * num_tasks]; |
for (int i = 0; i < num_tasks; i++) { |
compaction_spaces_for_tasks[i] = new CompactionSpaceCollection(heap()); |
- free_lists[i] = compaction_spaces_for_tasks[i]->Get(OLD_SPACE)->free_list(); |
- free_lists[i + num_tasks] = |
- compaction_spaces_for_tasks[i]->Get(CODE_SPACE)->free_list(); |
- } |
- heap()->old_space()->DivideFreeLists(free_lists, num_tasks, 1 * MB); |
- heap()->code_space()->DivideFreeLists(&free_lists[num_tasks], num_tasks, |
- 1 * MB); |
- delete[] free_lists; |
+ } |
+ |
+ compaction_spaces_for_tasks[0]->Get(OLD_SPACE)->MoveOverFreeMemory( |
+ heap()->old_space()); |
+ compaction_spaces_for_tasks[0] |
+ ->Get(CODE_SPACE) |
+ ->MoveOverFreeMemory(heap()->code_space()); |
compaction_in_progress_ = true; |
// Kick off parallel tasks. |
@@ -3411,8 +3397,10 @@ |
v8::Platform::kShortRunningTask); |
} |
- // Perform compaction on the main thread. |
+ // Contribute in main thread. Counter and signal are in principal not needed. |
+ concurrent_compaction_tasks_active_++; |
EvacuatePages(compaction_spaces_for_tasks[0], &migration_slots_buffer_); |
+ pending_compaction_tasks_semaphore_.Signal(); |
WaitUntilCompactionCompleted(); |