Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1354383002: [heap] Add more tasks for parallel compaction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Turn on parallel compaction Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 *cell = 0; 3363 *cell = 0;
3364 } 3364 }
3365 p->ResetLiveBytes(); 3365 p->ResetLiveBytes();
3366 return true; 3366 return true;
3367 } 3367 }
3368 3368
3369 3369
3370 void MarkCompactCollector::EvacuatePagesInParallel() { 3370 void MarkCompactCollector::EvacuatePagesInParallel() {
3371 if (evacuation_candidates_.length() == 0) return; 3371 if (evacuation_candidates_.length() == 0) return;
3372 3372
3373 int num_tasks = 1; 3373 const int num_tasks = NumberOfParallelCompactionTasks();
3374 if (FLAG_parallel_compaction) {
3375 num_tasks = NumberOfParallelCompactionTasks();
3376 }
3377 3374
3378 // Set up compaction spaces. 3375 // Set up compaction spaces.
3379 CompactionSpaceCollection** compaction_spaces_for_tasks = 3376 CompactionSpaceCollection** compaction_spaces_for_tasks =
3380 new CompactionSpaceCollection*[num_tasks]; 3377 new CompactionSpaceCollection*[num_tasks];
3378 FreeList** free_lists = new FreeList*[2 * num_tasks];
3381 for (int i = 0; i < num_tasks; i++) { 3379 for (int i = 0; i < num_tasks; i++) {
3382 compaction_spaces_for_tasks[i] = new CompactionSpaceCollection(heap()); 3380 compaction_spaces_for_tasks[i] = new CompactionSpaceCollection(heap());
3381 free_lists[i] = compaction_spaces_for_tasks[i]->Get(OLD_SPACE)->free_list();
3382 free_lists[i + num_tasks] =
3383 compaction_spaces_for_tasks[i]->Get(CODE_SPACE)->free_list();
3383 } 3384 }
3384 3385 heap()->old_space()->free_list()->Divide(free_lists, num_tasks, 1 * MB);
3385 compaction_spaces_for_tasks[0]->Get(OLD_SPACE)->MoveOverFreeMemory( 3386 heap()->code_space()->free_list()->Divide(&free_lists[num_tasks], num_tasks,
3386 heap()->old_space()); 3387 1 * MB);
3387 compaction_spaces_for_tasks[0] 3388 delete[] free_lists;
3388 ->Get(CODE_SPACE)
3389 ->MoveOverFreeMemory(heap()->code_space());
3390 3389
3391 compaction_in_progress_ = true; 3390 compaction_in_progress_ = true;
3392 // Kick off parallel tasks. 3391 // Kick off parallel tasks.
3393 for (int i = 1; i < num_tasks; i++) { 3392 for (int i = 1; i < num_tasks; i++) {
3394 concurrent_compaction_tasks_active_++; 3393 concurrent_compaction_tasks_active_++;
3395 V8::GetCurrentPlatform()->CallOnBackgroundThread( 3394 V8::GetCurrentPlatform()->CallOnBackgroundThread(
3396 new CompactionTask(heap(), compaction_spaces_for_tasks[i]), 3395 new CompactionTask(heap(), compaction_spaces_for_tasks[i]),
3397 v8::Platform::kShortRunningTask); 3396 v8::Platform::kShortRunningTask);
3398 } 3397 }
3399 3398
3400 // Contribute in main thread. Counter and signal are in principal not needed. 3399 // Contribute in main thread.
Hannes Payer (out of office) 2015/09/23 07:26:03 // Perform compaction on the main thread.
Michael Lippautz 2015/09/23 07:40:50 Done.
3401 concurrent_compaction_tasks_active_++;
3402 EvacuatePages(compaction_spaces_for_tasks[0], &migration_slots_buffer_); 3400 EvacuatePages(compaction_spaces_for_tasks[0], &migration_slots_buffer_);
3403 pending_compaction_tasks_semaphore_.Signal();
3404 3401
3405 WaitUntilCompactionCompleted(); 3402 WaitUntilCompactionCompleted();
3406 3403
3407 // Merge back memory (compacted and unused) from compaction spaces. 3404 // Merge back memory (compacted and unused) from compaction spaces.
3408 for (int i = 0; i < num_tasks; i++) { 3405 for (int i = 0; i < num_tasks; i++) {
3409 heap()->old_space()->MergeCompactionSpace( 3406 heap()->old_space()->MergeCompactionSpace(
3410 compaction_spaces_for_tasks[i]->Get(OLD_SPACE)); 3407 compaction_spaces_for_tasks[i]->Get(OLD_SPACE));
3411 heap()->code_space()->MergeCompactionSpace( 3408 heap()->code_space()->MergeCompactionSpace(
3412 compaction_spaces_for_tasks[i]->Get(CODE_SPACE)); 3409 compaction_spaces_for_tasks[i]->Get(CODE_SPACE));
3413 delete compaction_spaces_for_tasks[i]; 3410 delete compaction_spaces_for_tasks[i];
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4586 MarkBit mark_bit = Marking::MarkBitFrom(host); 4583 MarkBit mark_bit = Marking::MarkBitFrom(host);
4587 if (Marking::IsBlack(mark_bit)) { 4584 if (Marking::IsBlack(mark_bit)) {
4588 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); 4585 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host);
4589 RecordRelocSlot(&rinfo, target); 4586 RecordRelocSlot(&rinfo, target);
4590 } 4587 }
4591 } 4588 }
4592 } 4589 }
4593 4590
4594 } // namespace internal 4591 } // namespace internal
4595 } // namespace v8 4592 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698