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

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

Issue 2049063004: Reland of "heap] Fix Sweeper::IsSweepingCompleted" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « src/heap/mark-compact.h ('k') | 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (FLAG_concurrent_sweeping) { 501 if (FLAG_concurrent_sweeping) {
502 ForAllSweepingSpaces([this](AllocationSpace space) { 502 ForAllSweepingSpaces([this](AllocationSpace space) {
503 if (space == NEW_SPACE) return; 503 if (space == NEW_SPACE) return;
504 StartSweepingHelper(space); 504 StartSweepingHelper(space);
505 }); 505 });
506 } 506 }
507 } 507 }
508 508
509 void MarkCompactCollector::Sweeper::StartSweepingHelper( 509 void MarkCompactCollector::Sweeper::StartSweepingHelper(
510 AllocationSpace space_to_start) { 510 AllocationSpace space_to_start) {
511 num_sweeping_tasks_++; 511 num_sweeping_tasks_.Increment(1);
512 V8::GetCurrentPlatform()->CallOnBackgroundThread( 512 V8::GetCurrentPlatform()->CallOnBackgroundThread(
513 new SweeperTask(this, &pending_sweeper_tasks_semaphore_, space_to_start), 513 new SweeperTask(this, &pending_sweeper_tasks_semaphore_, space_to_start),
514 v8::Platform::kShortRunningTask); 514 v8::Platform::kShortRunningTask);
515 } 515 }
516 516
517 void MarkCompactCollector::Sweeper::SweepOrWaitUntilSweepingCompleted( 517 void MarkCompactCollector::Sweeper::SweepOrWaitUntilSweepingCompleted(
518 Page* page) { 518 Page* page) {
519 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner()); 519 PagedSpace* owner = reinterpret_cast<PagedSpace*>(page->owner());
520 if (!page->SweepingDone()) { 520 if (!page->SweepingDone()) {
521 ParallelSweepPage(page, owner); 521 ParallelSweepPage(page, owner);
(...skipping 26 matching lines...) Expand all
548 if (!sweeping_in_progress_) return; 548 if (!sweeping_in_progress_) return;
549 549
550 // If sweeping is not completed or not running at all, we try to complete it 550 // If sweeping is not completed or not running at all, we try to complete it
551 // here. 551 // here.
552 if (!FLAG_concurrent_sweeping || !IsSweepingCompleted()) { 552 if (!FLAG_concurrent_sweeping || !IsSweepingCompleted()) {
553 ForAllSweepingSpaces( 553 ForAllSweepingSpaces(
554 [this](AllocationSpace space) { ParallelSweepSpace(space, 0); }); 554 [this](AllocationSpace space) { ParallelSweepSpace(space, 0); });
555 } 555 }
556 556
557 if (FLAG_concurrent_sweeping) { 557 if (FLAG_concurrent_sweeping) {
558 while (num_sweeping_tasks_ > 0) { 558 while (num_sweeping_tasks_.Value() > 0) {
559 pending_sweeper_tasks_semaphore_.Wait(); 559 pending_sweeper_tasks_semaphore_.Wait();
560 num_sweeping_tasks_--; 560 num_sweeping_tasks_.Increment(-1);
561 } 561 }
562 } 562 }
563 563
564 ForAllSweepingSpaces( 564 ForAllSweepingSpaces(
565 [this](AllocationSpace space) { DCHECK(sweeping_list_[space].empty()); }); 565 [this](AllocationSpace space) { DCHECK(sweeping_list_[space].empty()); });
566 late_pages_ = false; 566 late_pages_ = false;
567 sweeping_in_progress_ = false; 567 sweeping_in_progress_ = false;
568 } 568 }
569 569
570 void MarkCompactCollector::EnsureSweepingCompleted() { 570 void MarkCompactCollector::EnsureSweepingCompleted() {
571 if (!sweeper().sweeping_in_progress()) return; 571 if (!sweeper().sweeping_in_progress()) return;
572 572
573 sweeper().EnsureCompleted(); 573 sweeper().EnsureCompleted();
574 heap()->old_space()->RefillFreeList(); 574 heap()->old_space()->RefillFreeList();
575 heap()->code_space()->RefillFreeList(); 575 heap()->code_space()->RefillFreeList();
576 heap()->map_space()->RefillFreeList(); 576 heap()->map_space()->RefillFreeList();
577 577
578 #ifdef VERIFY_HEAP 578 #ifdef VERIFY_HEAP
579 if (FLAG_verify_heap && !evacuation()) { 579 if (FLAG_verify_heap && !evacuation()) {
580 VerifyEvacuation(heap_); 580 VerifyEvacuation(heap_);
581 } 581 }
582 #endif 582 #endif
583 } 583 }
584 584
585 bool MarkCompactCollector::Sweeper::IsSweepingCompleted() { 585 bool MarkCompactCollector::Sweeper::IsSweepingCompleted() {
586 if (!pending_sweeper_tasks_semaphore_.WaitFor( 586 while (pending_sweeper_tasks_semaphore_.WaitFor(
587 base::TimeDelta::FromSeconds(0))) { 587 base::TimeDelta::FromSeconds(0))) {
588 return false; 588 num_sweeping_tasks_.Increment(-1);
589 } 589 }
590 pending_sweeper_tasks_semaphore_.Signal(); 590 return num_sweeping_tasks_.Value() == 0;
591 return true;
592 } 591 }
593 592
594 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) { 593 void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) {
595 // This is only used when resizing an object. 594 // This is only used when resizing an object.
596 DCHECK(MemoryChunk::FromAddress(old_start) == 595 DCHECK(MemoryChunk::FromAddress(old_start) ==
597 MemoryChunk::FromAddress(new_start)); 596 MemoryChunk::FromAddress(new_start));
598 597
599 if (!heap->incremental_marking()->IsMarking() || 598 if (!heap->incremental_marking()->IsMarking() ||
600 Page::FromAddress(old_start)->IsFlagSet(Page::BLACK_PAGE)) 599 Page::FromAddress(old_start)->IsFlagSet(Page::BLACK_PAGE))
601 return; 600 return;
(...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 MarkBit mark_bit = Marking::MarkBitFrom(host); 3992 MarkBit mark_bit = Marking::MarkBitFrom(host);
3994 if (Marking::IsBlack(mark_bit)) { 3993 if (Marking::IsBlack(mark_bit)) {
3995 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3994 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3996 RecordRelocSlot(host, &rinfo, target); 3995 RecordRelocSlot(host, &rinfo, target);
3997 } 3996 }
3998 } 3997 }
3999 } 3998 }
4000 3999
4001 } // namespace internal 4000 } // namespace internal
4002 } // namespace v8 4001 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698