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

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

Issue 1788753002: [heap] Remove left-overs of RESCAN_ON_EVACUATION flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 candidate_count, total_live_bytes / KB); 773 candidate_count, total_live_bytes / KB);
774 } 774 }
775 } 775 }
776 776
777 777
778 void MarkCompactCollector::AbortCompaction() { 778 void MarkCompactCollector::AbortCompaction() {
779 if (compacting_) { 779 if (compacting_) {
780 RememberedSet<OLD_TO_OLD>::ClearAll(heap()); 780 RememberedSet<OLD_TO_OLD>::ClearAll(heap());
781 for (Page* p : evacuation_candidates_) { 781 for (Page* p : evacuation_candidates_) {
782 p->ClearEvacuationCandidate(); 782 p->ClearEvacuationCandidate();
783 p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION);
784 } 783 }
785 compacting_ = false; 784 compacting_ = false;
786 evacuation_candidates_.Rewind(0); 785 evacuation_candidates_.Rewind(0);
787 } 786 }
788 DCHECK_EQ(0, evacuation_candidates_.length()); 787 DCHECK_EQ(0, evacuation_candidates_.length());
789 } 788 }
790 789
791 790
792 void MarkCompactCollector::Prepare() { 791 void MarkCompactCollector::Prepare() {
793 was_marked_incrementally_ = heap()->incremental_marking()->IsMarking(); 792 was_marked_incrementally_ = heap()->incremental_marking()->IsMarking();
(...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3022 3021
3023 bool MarkCompactCollector::Evacuator::EvacuatePage(MemoryChunk* chunk) { 3022 bool MarkCompactCollector::Evacuator::EvacuatePage(MemoryChunk* chunk) {
3024 bool success = false; 3023 bool success = false;
3025 if (chunk->InNewSpace()) { 3024 if (chunk->InNewSpace()) {
3026 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(), 3025 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(),
3027 NewSpacePage::kSweepingDone); 3026 NewSpacePage::kSweepingDone);
3028 success = EvacuateSinglePage(chunk, &new_space_visitor_); 3027 success = EvacuateSinglePage(chunk, &new_space_visitor_);
3029 DCHECK(success); 3028 DCHECK(success);
3030 USE(success); 3029 USE(success);
3031 } else { 3030 } else {
3032 DCHECK(chunk->IsEvacuationCandidate() || 3031 DCHECK(chunk->IsEvacuationCandidate());
3033 chunk->IsFlagSet(MemoryChunk::RESCAN_ON_EVACUATION));
3034 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(), Page::kSweepingDone); 3032 DCHECK_EQ(chunk->concurrent_sweeping_state().Value(), Page::kSweepingDone);
3035 success = EvacuateSinglePage(chunk, &old_space_visitor_); 3033 success = EvacuateSinglePage(chunk, &old_space_visitor_);
3036 } 3034 }
3037 return success; 3035 return success;
3038 } 3036 }
3039 3037
3040 void MarkCompactCollector::Evacuator::Finalize() { 3038 void MarkCompactCollector::Evacuator::Finalize() {
3041 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE)); 3039 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE));
3042 heap()->code_space()->MergeCompactionSpace( 3040 heap()->code_space()->MergeCompactionSpace(
3043 compaction_spaces_.Get(CODE_SPACE)); 3041 compaction_spaces_.Get(CODE_SPACE));
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 heap->tracer(), 3577 heap->tracer(),
3580 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED); 3578 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED);
3581 UpdatePointersInParallel<OLD_TO_OLD>(heap_); 3579 UpdatePointersInParallel<OLD_TO_OLD>(heap_);
3582 } 3580 }
3583 3581
3584 { 3582 {
3585 GCTracer::Scope gc_scope( 3583 GCTracer::Scope gc_scope(
3586 heap()->tracer(), 3584 heap()->tracer(),
3587 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED); 3585 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED);
3588 for (Page* p : evacuation_candidates_) { 3586 for (Page* p : evacuation_candidates_) {
3589 DCHECK(p->IsEvacuationCandidate() || 3587 DCHECK(p->IsEvacuationCandidate());
3590 p->IsFlagSet(Page::RESCAN_ON_EVACUATION)); 3588 // Important: skip list should be cleared only after roots were updated
3589 // because root iteration traverses the stack and might have to find
3590 // code objects from non-updated pc pointing into evacuation candidate.
3591 SkipList* list = p->skip_list();
3592 if (list != NULL) list->Clear();
3591 3593
3592 if (p->IsEvacuationCandidate()) { 3594 // First pass on aborted pages, fixing up all live objects.
3593 // Important: skip list should be cleared only after roots were updated 3595 if (p->IsFlagSet(Page::COMPACTION_WAS_ABORTED)) {
3594 // because root iteration traverses the stack and might have to find 3596 p->ClearEvacuationCandidate();
3595 // code objects from non-updated pc pointing into evacuation candidate. 3597 VisitLiveObjectsBody(p, &updating_visitor);
3596 SkipList* list = p->skip_list();
3597 if (list != NULL) list->Clear();
3598
3599 // First pass on aborted pages, fixing up all live objects.
3600 if (p->IsFlagSet(Page::COMPACTION_WAS_ABORTED)) {
3601 p->ClearEvacuationCandidate();
3602 VisitLiveObjectsBody(p, &updating_visitor);
3603 }
3604 }
3605
3606 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
3607 if (FLAG_gc_verbose) {
3608 PrintF("Sweeping 0x%" V8PRIxPTR " during evacuation.\n",
3609 reinterpret_cast<intptr_t>(p));
3610 }
3611 PagedSpace* space = static_cast<PagedSpace*>(p->owner());
3612 p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION);
3613 p->concurrent_sweeping_state().SetValue(Page::kSweepingInProgress);
3614
3615 switch (space->identity()) {
3616 case OLD_SPACE:
3617 Sweep<SWEEP_AND_VISIT_LIVE_OBJECTS, SWEEP_ON_MAIN_THREAD,
3618 IGNORE_SKIP_LIST, IGNORE_FREE_SPACE>(space, NULL, p,
3619 &updating_visitor);
3620 break;
3621 case CODE_SPACE:
3622 if (FLAG_zap_code_space) {
3623 Sweep<SWEEP_AND_VISIT_LIVE_OBJECTS, SWEEP_ON_MAIN_THREAD,
3624 REBUILD_SKIP_LIST, ZAP_FREE_SPACE>(space, NULL, p,
3625 &updating_visitor);
3626 } else {
3627 Sweep<SWEEP_AND_VISIT_LIVE_OBJECTS, SWEEP_ON_MAIN_THREAD,
3628 REBUILD_SKIP_LIST, IGNORE_FREE_SPACE>(space, NULL, p,
3629 &updating_visitor);
3630 }
3631 break;
3632 default:
3633 UNREACHABLE();
3634 break;
3635 }
3636 } 3598 }
3637 } 3599 }
3638 } 3600 }
3639 3601
3640 { 3602 {
3641 GCTracer::Scope gc_scope(heap()->tracer(), 3603 GCTracer::Scope gc_scope(heap()->tracer(),
3642 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_WEAK); 3604 GCTracer::Scope::MC_EVACUATE_UPDATE_POINTERS_WEAK);
3643 heap_->string_table()->Iterate(&updating_visitor); 3605 heap_->string_table()->Iterate(&updating_visitor);
3644 3606
3645 // Update pointers from external string table. 3607 // Update pointers from external string table.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3729 3691
3730 PageIterator it(space); 3692 PageIterator it(space);
3731 3693
3732 int will_be_swept = 0; 3694 int will_be_swept = 0;
3733 bool unused_page_present = false; 3695 bool unused_page_present = false;
3734 3696
3735 while (it.has_next()) { 3697 while (it.has_next()) {
3736 Page* p = it.next(); 3698 Page* p = it.next();
3737 DCHECK(p->SweepingDone()); 3699 DCHECK(p->SweepingDone());
3738 3700
3739 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION) || 3701 if (p->IsEvacuationCandidate()) {
3740 p->IsEvacuationCandidate()) {
3741 // Will be processed in EvacuateNewSpaceAndCandidates. 3702 // Will be processed in EvacuateNewSpaceAndCandidates.
3742 DCHECK(evacuation_candidates_.length() > 0); 3703 DCHECK(evacuation_candidates_.length() > 0);
3743 continue; 3704 continue;
3744 } 3705 }
3745 3706
3746 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) { 3707 if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) {
3747 // We need to sweep the page to get it into an iterable state again. Note 3708 // We need to sweep the page to get it into an iterable state again. Note
3748 // that this adds unusable memory into the free list that is later on 3709 // that this adds unusable memory into the free list that is later on
3749 // (in the free list) dropped again. Since we only use the flag for 3710 // (in the free list) dropped again. Since we only use the flag for
3750 // testing this is fine. 3711 // testing this is fine.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3859 MarkBit mark_bit = Marking::MarkBitFrom(host); 3820 MarkBit mark_bit = Marking::MarkBitFrom(host);
3860 if (Marking::IsBlack(mark_bit)) { 3821 if (Marking::IsBlack(mark_bit)) {
3861 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3822 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3862 RecordRelocSlot(host, &rinfo, target); 3823 RecordRelocSlot(host, &rinfo, target);
3863 } 3824 }
3864 } 3825 }
3865 } 3826 }
3866 3827
3867 } // namespace internal 3828 } // namespace internal
3868 } // namespace v8 3829 } // 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