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

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

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