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

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

Issue 1678863002: [heap] Collaborating sweeper tasks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/sys-info.h" 9 #include "src/base/sys-info.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 472 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
473 Marking::MarkWhite(Marking::MarkBitFrom(obj)); 473 Marking::MarkWhite(Marking::MarkBitFrom(obj));
474 Page::FromAddress(obj->address())->ResetProgressBar(); 474 Page::FromAddress(obj->address())->ResetProgressBar();
475 Page::FromAddress(obj->address())->ResetLiveBytes(); 475 Page::FromAddress(obj->address())->ResetLiveBytes();
476 } 476 }
477 } 477 }
478 478
479 479
480 class MarkCompactCollector::SweeperTask : public v8::Task { 480 class MarkCompactCollector::SweeperTask : public v8::Task {
481 public: 481 public:
482 SweeperTask(Heap* heap, PagedSpace* space) : heap_(heap), space_(space) {} 482 SweeperTask(Heap* heap, AllocationSpace space_to_start)
483 : heap_(heap), space_to_start_(space_to_start) {}
483 484
484 virtual ~SweeperTask() {} 485 virtual ~SweeperTask() {}
485 486
486 private: 487 private:
487 // v8::Task overrides. 488 // v8::Task overrides.
488 void Run() override { 489 void Run() override {
489 heap_->mark_compact_collector()->SweepInParallel(space_, 0); 490 DCHECK_GE(space_to_start_, FIRST_PAGED_SPACE);
491 DCHECK_LE(space_to_start_, LAST_PAGED_SPACE);
492 const int offset = space_to_start_ - FIRST_PAGED_SPACE;
493 const int num_spaces = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
494 for (int i = 0; i < num_spaces; i++) {
495 const int space_id = FIRST_PAGED_SPACE + ((i + offset) % num_spaces);
496 DCHECK_GE(space_id, FIRST_PAGED_SPACE);
497 DCHECK_LE(space_id, LAST_PAGED_SPACE);
498 heap_->mark_compact_collector()->SweepInParallel(
499 heap_->paged_space(space_id), 0);
500 }
490 heap_->mark_compact_collector()->pending_sweeper_tasks_semaphore_.Signal(); 501 heap_->mark_compact_collector()->pending_sweeper_tasks_semaphore_.Signal();
491 } 502 }
492 503
493 Heap* heap_; 504 Heap* heap_;
494 PagedSpace* space_; 505 AllocationSpace space_to_start_;
495 506
496 DISALLOW_COPY_AND_ASSIGN(SweeperTask); 507 DISALLOW_COPY_AND_ASSIGN(SweeperTask);
497 }; 508 };
498 509
499 510
500 void MarkCompactCollector::StartSweeperThreads() { 511 void MarkCompactCollector::StartSweeperThreads() {
501 DCHECK(free_list_old_space_.get()->IsEmpty()); 512 DCHECK(free_list_old_space_.get()->IsEmpty());
502 DCHECK(free_list_code_space_.get()->IsEmpty()); 513 DCHECK(free_list_code_space_.get()->IsEmpty());
503 DCHECK(free_list_map_space_.get()->IsEmpty()); 514 DCHECK(free_list_map_space_.get()->IsEmpty());
504 V8::GetCurrentPlatform()->CallOnBackgroundThread( 515 V8::GetCurrentPlatform()->CallOnBackgroundThread(
505 new SweeperTask(heap(), heap()->old_space()), 516 new SweeperTask(heap(), OLD_SPACE), v8::Platform::kShortRunningTask);
506 v8::Platform::kShortRunningTask);
507 V8::GetCurrentPlatform()->CallOnBackgroundThread( 517 V8::GetCurrentPlatform()->CallOnBackgroundThread(
508 new SweeperTask(heap(), heap()->code_space()), 518 new SweeperTask(heap(), CODE_SPACE), v8::Platform::kShortRunningTask);
509 v8::Platform::kShortRunningTask);
510 V8::GetCurrentPlatform()->CallOnBackgroundThread( 519 V8::GetCurrentPlatform()->CallOnBackgroundThread(
511 new SweeperTask(heap(), heap()->map_space()), 520 new SweeperTask(heap(), MAP_SPACE), v8::Platform::kShortRunningTask);
512 v8::Platform::kShortRunningTask);
513 } 521 }
514 522
515 523
516 void MarkCompactCollector::SweepOrWaitUntilSweepingCompleted(Page* page) { 524 void MarkCompactCollector::SweepOrWaitUntilSweepingCompleted(Page* page) {
517 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner()); 525 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner());
518 if (!page->SweepingDone()) { 526 if (!page->SweepingDone()) {
519 SweepInParallel(page, owner); 527 SweepInParallel(page, owner);
520 if (!page->SweepingDone()) { 528 if (!page->SweepingDone()) {
521 // We were not able to sweep that page, i.e., a concurrent 529 // We were not able to sweep that page, i.e., a concurrent
522 // sweeper thread currently owns this page. Wait for the sweeper 530 // sweeper thread currently owns this page. Wait for the sweeper
(...skipping 3533 matching lines...) Expand 10 before | Expand all | Expand 10 after
4056 MarkBit mark_bit = Marking::MarkBitFrom(host); 4064 MarkBit mark_bit = Marking::MarkBitFrom(host);
4057 if (Marking::IsBlack(mark_bit)) { 4065 if (Marking::IsBlack(mark_bit)) {
4058 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 4066 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
4059 RecordRelocSlot(&rinfo, target); 4067 RecordRelocSlot(&rinfo, target);
4060 } 4068 }
4061 } 4069 }
4062 } 4070 }
4063 4071
4064 } // namespace internal 4072 } // namespace internal
4065 } // namespace v8 4073 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698