OLD | NEW |
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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 841 |
842 DCHECK(!FLAG_never_compact || !FLAG_always_compact); | 842 DCHECK(!FLAG_never_compact || !FLAG_always_compact); |
843 | 843 |
844 if (sweeping_in_progress()) { | 844 if (sweeping_in_progress()) { |
845 // Instead of waiting we could also abort the sweeper threads here. | 845 // Instead of waiting we could also abort the sweeper threads here. |
846 EnsureSweepingCompleted(); | 846 EnsureSweepingCompleted(); |
847 } | 847 } |
848 | 848 |
849 // If concurrent unmapping tasks are still running, we should wait for | 849 // If concurrent unmapping tasks are still running, we should wait for |
850 // them here. | 850 // them here. |
851 heap()->memory_allocator()->unmapper()->WaitUntilCompleted(); | 851 heap()->WaitUntilUnmappingOfFreeChunksCompleted(); |
852 | 852 |
853 // Clear marking bits if incremental marking is aborted. | 853 // Clear marking bits if incremental marking is aborted. |
854 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) { | 854 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) { |
855 heap()->incremental_marking()->Stop(); | 855 heap()->incremental_marking()->Stop(); |
856 ClearMarkbits(); | 856 ClearMarkbits(); |
857 AbortWeakCollections(); | 857 AbortWeakCollections(); |
858 AbortWeakCells(); | 858 AbortWeakCells(); |
859 AbortTransitionArrays(); | 859 AbortTransitionArrays(); |
860 AbortCompaction(); | 860 AbortCompaction(); |
861 was_marked_incrementally_ = false; | 861 was_marked_incrementally_ = false; |
(...skipping 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3534 EvacuateNewSpaceEpilogue(); | 3534 EvacuateNewSpaceEpilogue(); |
3535 heap()->new_space()->set_age_mark(heap()->new_space()->top()); | 3535 heap()->new_space()->set_age_mark(heap()->new_space()->top()); |
3536 } | 3536 } |
3537 | 3537 |
3538 UpdatePointersAfterEvacuation(); | 3538 UpdatePointersAfterEvacuation(); |
3539 | 3539 |
3540 // Give pages that are queued to be freed back to the OS. Note that filtering | 3540 // Give pages that are queued to be freed back to the OS. Note that filtering |
3541 // slots only handles old space (for unboxed doubles), and thus map space can | 3541 // slots only handles old space (for unboxed doubles), and thus map space can |
3542 // still contain stale pointers. We only free the chunks after pointer updates | 3542 // still contain stale pointers. We only free the chunks after pointer updates |
3543 // to still have access to page headers. | 3543 // to still have access to page headers. |
3544 heap()->memory_allocator()->unmapper()->FreeQueuedChunks(); | 3544 heap()->FreeQueuedChunks(); |
3545 | 3545 |
3546 { | 3546 { |
3547 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_CLEAN_UP); | 3547 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_CLEAN_UP); |
3548 | 3548 |
3549 for (Page* p : evacuation_candidates_) { | 3549 for (Page* p : evacuation_candidates_) { |
3550 // Important: skip list should be cleared only after roots were updated | 3550 // Important: skip list should be cleared only after roots were updated |
3551 // because root iteration traverses the stack and might have to find | 3551 // because root iteration traverses the stack and might have to find |
3552 // code objects from non-updated pc pointing into evacuation candidate. | 3552 // code objects from non-updated pc pointing into evacuation candidate. |
3553 SkipList* list = p->skip_list(); | 3553 SkipList* list = p->skip_list(); |
3554 if (list != NULL) list->Clear(); | 3554 if (list != NULL) list->Clear(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3722 void MarkCompactCollector::ReleaseEvacuationCandidates() { | 3722 void MarkCompactCollector::ReleaseEvacuationCandidates() { |
3723 for (Page* p : evacuation_candidates_) { | 3723 for (Page* p : evacuation_candidates_) { |
3724 if (!p->IsEvacuationCandidate()) continue; | 3724 if (!p->IsEvacuationCandidate()) continue; |
3725 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); | 3725 PagedSpace* space = static_cast<PagedSpace*>(p->owner()); |
3726 p->ResetLiveBytes(); | 3726 p->ResetLiveBytes(); |
3727 CHECK(p->SweepingDone()); | 3727 CHECK(p->SweepingDone()); |
3728 space->ReleasePage(p); | 3728 space->ReleasePage(p); |
3729 } | 3729 } |
3730 evacuation_candidates_.Rewind(0); | 3730 evacuation_candidates_.Rewind(0); |
3731 compacting_ = false; | 3731 compacting_ = false; |
3732 heap()->memory_allocator()->unmapper()->FreeQueuedChunks(); | 3732 heap()->FreeQueuedChunks(); |
3733 } | 3733 } |
3734 | 3734 |
3735 int MarkCompactCollector::Sweeper::ParallelSweepSpace(AllocationSpace identity, | 3735 int MarkCompactCollector::Sweeper::ParallelSweepSpace(AllocationSpace identity, |
3736 int required_freed_bytes, | 3736 int required_freed_bytes, |
3737 int max_pages) { | 3737 int max_pages) { |
3738 int max_freed = 0; | 3738 int max_freed = 0; |
3739 int pages_freed = 0; | 3739 int pages_freed = 0; |
3740 Page* page = nullptr; | 3740 Page* page = nullptr; |
3741 while ((page = GetSweepingPageSafe(identity)) != nullptr) { | 3741 while ((page = GetSweepingPageSafe(identity)) != nullptr) { |
3742 int freed = ParallelSweepPage(page, heap_->paged_space(identity)); | 3742 int freed = ParallelSweepPage(page, heap_->paged_space(identity)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3948 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3948 MarkBit mark_bit = Marking::MarkBitFrom(host); |
3949 if (Marking::IsBlack(mark_bit)) { | 3949 if (Marking::IsBlack(mark_bit)) { |
3950 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3950 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
3951 RecordRelocSlot(host, &rinfo, target); | 3951 RecordRelocSlot(host, &rinfo, target); |
3952 } | 3952 } |
3953 } | 3953 } |
3954 } | 3954 } |
3955 | 3955 |
3956 } // namespace internal | 3956 } // namespace internal |
3957 } // namespace v8 | 3957 } // namespace v8 |
OLD | NEW |