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

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

Issue 1494503004: Reland of "[heap] Clean up stale store buffer entries for aborted pages." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reorder to the right place Created 5 years 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 | src/heap/spaces.h » ('j') | 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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 int area_size = space->AreaSize(); 676 int area_size = space->AreaSize();
677 677
678 // Pairs of (live_bytes_in_page, page). 678 // Pairs of (live_bytes_in_page, page).
679 typedef std::pair<int, Page*> LiveBytesPagePair; 679 typedef std::pair<int, Page*> LiveBytesPagePair;
680 std::vector<LiveBytesPagePair> pages; 680 std::vector<LiveBytesPagePair> pages;
681 pages.reserve(number_of_pages); 681 pages.reserve(number_of_pages);
682 682
683 PageIterator it(space); 683 PageIterator it(space);
684 while (it.has_next()) { 684 while (it.has_next()) {
685 Page* p = it.next(); 685 Page* p = it.next();
686 // Invariant: No page should be marked as aborted after a GC.
687 DCHECK(!p->IsFlagSet(Page::COMPACTION_WAS_ABORTED));
686 if (p->NeverEvacuate()) continue; 688 if (p->NeverEvacuate()) continue;
687 if (p->IsFlagSet(Page::POPULAR_PAGE)) { 689 if (p->IsFlagSet(Page::POPULAR_PAGE)) {
688 // This page had slots buffer overflow on previous GC, skip it. 690 // This page had slots buffer overflow on previous GC, skip it.
689 p->ClearFlag(Page::POPULAR_PAGE); 691 p->ClearFlag(Page::POPULAR_PAGE);
690 continue; 692 continue;
691 } 693 }
692 // Invariant: Evacuation candidates are just created when marking is 694 // Invariant: Evacuation candidates are just created when marking is
693 // started. At the end of a GC all evacuation candidates are cleared and 695 // started. At the end of a GC all evacuation candidates are cleared and
694 // their slot buffers are released. 696 // their slot buffers are released.
695 CHECK(!p->IsEvacuationCandidate()); 697 CHECK(!p->IsEvacuationCandidate());
(...skipping 2575 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 // moved, others are still in place. 3273 // moved, others are still in place.
3272 // We need to: 3274 // We need to:
3273 // - Leave the evacuation candidate flag for later processing of 3275 // - Leave the evacuation candidate flag for later processing of
3274 // slots buffer entries. 3276 // slots buffer entries.
3275 // - Leave the slots buffer there for processing of entries added by 3277 // - Leave the slots buffer there for processing of entries added by
3276 // the write barrier. 3278 // the write barrier.
3277 // - Rescan the page as slot recording in the migration buffer only 3279 // - Rescan the page as slot recording in the migration buffer only
3278 // happens upon moving (which we potentially didn't do). 3280 // happens upon moving (which we potentially didn't do).
3279 // - Leave the page in the list of pages of a space since we could not 3281 // - Leave the page in the list of pages of a space since we could not
3280 // fully evacuate it. 3282 // fully evacuate it.
3283 // - Mark them for rescanning for store buffer entries as we otherwise
3284 // might have stale store buffer entries that become "valid" again
3285 // after reusing the memory. Note that all existing store buffer
3286 // entries of such pages are filtered before rescanning.
3281 DCHECK(p->IsEvacuationCandidate()); 3287 DCHECK(p->IsEvacuationCandidate());
3282 p->SetFlag(Page::COMPACTION_WAS_ABORTED); 3288 p->SetFlag(Page::COMPACTION_WAS_ABORTED);
3289 p->set_scan_on_scavenge(true);
3283 abandoned_pages++; 3290 abandoned_pages++;
3284 break; 3291 break;
3285 case MemoryChunk::kCompactingFinalize: 3292 case MemoryChunk::kCompactingFinalize:
3286 DCHECK(p->IsEvacuationCandidate()); 3293 DCHECK(p->IsEvacuationCandidate());
3287 p->SetWasSwept(); 3294 p->SetWasSwept();
3288 p->Unlink(); 3295 p->Unlink();
3289 break; 3296 break;
3290 case MemoryChunk::kCompactingDone: 3297 case MemoryChunk::kCompactingDone:
3291 DCHECK(p->IsFlagSet(Page::POPULAR_PAGE)); 3298 DCHECK(p->IsFlagSet(Page::POPULAR_PAGE));
3292 DCHECK(p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); 3299 DCHECK(p->IsFlagSet(Page::RESCAN_ON_EVACUATION));
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3651 } 3658 }
3652 } 3659 }
3653 3660
3654 { 3661 {
3655 GCTracer::Scope gc_scope(heap()->tracer(), 3662 GCTracer::Scope gc_scope(heap()->tracer(),
3656 GCTracer::Scope::MC_UPDATE_ROOT_TO_NEW_POINTERS); 3663 GCTracer::Scope::MC_UPDATE_ROOT_TO_NEW_POINTERS);
3657 // Update roots. 3664 // Update roots.
3658 heap_->IterateRoots(&updating_visitor, VISIT_ALL_IN_SWEEP_NEWSPACE); 3665 heap_->IterateRoots(&updating_visitor, VISIT_ALL_IN_SWEEP_NEWSPACE);
3659 } 3666 }
3660 3667
3661 {
3662 GCTracer::Scope gc_scope(heap()->tracer(),
3663 GCTracer::Scope::MC_UPDATE_OLD_TO_NEW_POINTERS);
3664 StoreBufferRebuildScope scope(heap_, heap_->store_buffer(),
3665 &Heap::ScavengeStoreBufferCallback);
3666 heap_->store_buffer()->IteratePointersToNewSpace(&UpdatePointer);
3667 }
3668
3669 int npages = evacuation_candidates_.length(); 3668 int npages = evacuation_candidates_.length();
3670 { 3669 {
3671 GCTracer::Scope gc_scope( 3670 GCTracer::Scope gc_scope(
3672 heap()->tracer(), 3671 heap()->tracer(),
3673 GCTracer::Scope::MC_UPDATE_POINTERS_BETWEEN_EVACUATED); 3672 GCTracer::Scope::MC_UPDATE_POINTERS_BETWEEN_EVACUATED);
3674 for (int i = 0; i < npages; i++) { 3673 for (int i = 0; i < npages; i++) {
3675 Page* p = evacuation_candidates_[i]; 3674 Page* p = evacuation_candidates_[i];
3676 DCHECK(p->IsEvacuationCandidate() || 3675 DCHECK(p->IsEvacuationCandidate() ||
3677 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); 3676 p->IsFlagSet(Page::RESCAN_ON_EVACUATION));
3678 3677
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3747 } 3746 }
3748 3747
3749 { 3748 {
3750 GCTracer::Scope gc_scope(heap()->tracer(), 3749 GCTracer::Scope gc_scope(heap()->tracer(),
3751 GCTracer::Scope::MC_SWEEP_ABORTED); 3750 GCTracer::Scope::MC_SWEEP_ABORTED);
3752 // After updating all pointers, we can finally sweep the aborted pages, 3751 // After updating all pointers, we can finally sweep the aborted pages,
3753 // effectively overriding any forward pointers. 3752 // effectively overriding any forward pointers.
3754 SweepAbortedPages(); 3753 SweepAbortedPages();
3755 } 3754 }
3756 3755
3756 {
3757 // Note that this phase needs to happen after making aborted pages iterable
3758 // in the previous (sweeping) phase.
3759 GCTracer::Scope gc_scope(heap()->tracer(),
3760 GCTracer::Scope::MC_UPDATE_OLD_TO_NEW_POINTERS);
3761 StoreBufferRebuildScope scope(heap_, heap_->store_buffer(),
3762 &Heap::ScavengeStoreBufferCallback);
3763 heap_->store_buffer()->IteratePointersToNewSpace(&UpdatePointer);
3764 }
3765
3757 heap_->isolate()->inner_pointer_to_code_cache()->Flush(); 3766 heap_->isolate()->inner_pointer_to_code_cache()->Flush();
3758 3767
3759 // The hashing of weak_object_to_code_table is no longer valid. 3768 // The hashing of weak_object_to_code_table is no longer valid.
3760 heap()->weak_object_to_code_table()->Rehash( 3769 heap()->weak_object_to_code_table()->Rehash(
3761 heap()->isolate()->factory()->undefined_value()); 3770 heap()->isolate()->factory()->undefined_value());
3762 } 3771 }
3763 3772
3764 3773
3765 void MarkCompactCollector::MoveEvacuationCandidatesToEndOfPagesList() { 3774 void MarkCompactCollector::MoveEvacuationCandidatesToEndOfPagesList() {
3766 int npages = evacuation_candidates_.length(); 3775 int npages = evacuation_candidates_.length();
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 MarkBit mark_bit = Marking::MarkBitFrom(host); 4134 MarkBit mark_bit = Marking::MarkBitFrom(host);
4126 if (Marking::IsBlack(mark_bit)) { 4135 if (Marking::IsBlack(mark_bit)) {
4127 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 4136 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
4128 RecordRelocSlot(&rinfo, target); 4137 RecordRelocSlot(&rinfo, target);
4129 } 4138 }
4130 } 4139 }
4131 } 4140 }
4132 4141
4133 } // namespace internal 4142 } // namespace internal
4134 } // namespace v8 4143 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698