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 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 } | 3181 } |
3182 break; | 3182 break; |
3183 default: | 3183 default: |
3184 UNREACHABLE(); | 3184 UNREACHABLE(); |
3185 } | 3185 } |
3186 } | 3186 } |
3187 ReportCompactionProgress(evacuation_time, saved_live_bytes); | 3187 ReportCompactionProgress(evacuation_time, saved_live_bytes); |
3188 if (FLAG_trace_evacuation) { | 3188 if (FLAG_trace_evacuation) { |
3189 PrintIsolate(heap->isolate(), | 3189 PrintIsolate(heap->isolate(), |
3190 "evacuation[%p]: page=%p new_space=%d " | 3190 "evacuation[%p]: page=%p new_space=%d " |
3191 "page_evacuation=%d executable=%d contains_age_mark=%d " | 3191 "page_evacuation=%d executable=%d live_bytes=%d time=%f\n", |
3192 "live_bytes=%d time=%f\n", | |
3193 static_cast<void*>(this), static_cast<void*>(page), | 3192 static_cast<void*>(this), static_cast<void*>(page), |
3194 page->InNewSpace(), | 3193 page->InNewSpace(), |
3195 page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) || | 3194 page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) || |
3196 page->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION), | 3195 page->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION), |
3197 page->IsFlagSet(MemoryChunk::IS_EXECUTABLE), | 3196 page->IsFlagSet(MemoryChunk::IS_EXECUTABLE), saved_live_bytes, |
3198 page->Contains(heap->new_space()->age_mark()), | 3197 evacuation_time); |
3199 saved_live_bytes, evacuation_time); | |
3200 } | 3198 } |
3201 return success; | 3199 return success; |
3202 } | 3200 } |
3203 | 3201 |
3204 void MarkCompactCollector::Evacuator::Finalize() { | 3202 void MarkCompactCollector::Evacuator::Finalize() { |
3205 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE)); | 3203 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE)); |
3206 heap()->code_space()->MergeCompactionSpace( | 3204 heap()->code_space()->MergeCompactionSpace( |
3207 compaction_spaces_.Get(CODE_SPACE)); | 3205 compaction_spaces_.Get(CODE_SPACE)); |
3208 heap()->tracer()->AddCompactionEvent(duration_, bytes_compacted_); | 3206 heap()->tracer()->AddCompactionEvent(duration_, bytes_compacted_); |
3209 heap()->IncrementPromotedObjectsSize(new_space_visitor_.promoted_size() + | 3207 heap()->IncrementPromotedObjectsSize(new_space_visitor_.promoted_size() + |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3299 heap_, heap_->isolate()->cancelable_task_manager(), | 3297 heap_, heap_->isolate()->cancelable_task_manager(), |
3300 &page_parallel_job_semaphore_); | 3298 &page_parallel_job_semaphore_); |
3301 | 3299 |
3302 int abandoned_pages = 0; | 3300 int abandoned_pages = 0; |
3303 intptr_t live_bytes = 0; | 3301 intptr_t live_bytes = 0; |
3304 for (Page* page : evacuation_candidates_) { | 3302 for (Page* page : evacuation_candidates_) { |
3305 live_bytes += page->LiveBytes(); | 3303 live_bytes += page->LiveBytes(); |
3306 job.AddPage(page, &abandoned_pages); | 3304 job.AddPage(page, &abandoned_pages); |
3307 } | 3305 } |
3308 | 3306 |
3309 const Address age_mark = heap()->new_space()->age_mark(); | |
3310 for (Page* page : newspace_evacuation_candidates_) { | 3307 for (Page* page : newspace_evacuation_candidates_) { |
3311 live_bytes += page->LiveBytes(); | 3308 live_bytes += page->LiveBytes(); |
3312 if (!page->NeverEvacuate() && | 3309 if (!page->NeverEvacuate() && |
3313 (page->LiveBytes() > Evacuator::PageEvacuationThreshold()) && | 3310 (page->LiveBytes() > Evacuator::PageEvacuationThreshold())) { |
3314 !page->Contains(age_mark)) { | 3311 if (page->InIntermediateGeneration()) { |
3315 if (page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK)) { | |
3316 EvacuateNewSpacePageVisitor::MoveToOldSpace(page, heap()->old_space()); | 3312 EvacuateNewSpacePageVisitor::MoveToOldSpace(page, heap()->old_space()); |
3317 } else { | 3313 } else { |
3318 EvacuateNewSpacePageVisitor::MoveToToSpace(page); | 3314 EvacuateNewSpacePageVisitor::MoveToToSpace(page); |
3319 } | 3315 } |
3320 } | 3316 } |
3321 | 3317 |
3322 job.AddPage(page, &abandoned_pages); | 3318 job.AddPage(page, &abandoned_pages); |
3323 } | 3319 } |
3324 DCHECK_GE(job.NumberOfPages(), 1); | 3320 DCHECK_GE(job.NumberOfPages(), 1); |
3325 | 3321 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { | 3547 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
3552 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); | 3548 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); |
3553 Heap::RelocationLock relocation_lock(heap()); | 3549 Heap::RelocationLock relocation_lock(heap()); |
3554 | 3550 |
3555 { | 3551 { |
3556 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_COPY); | 3552 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_COPY); |
3557 EvacuationScope evacuation_scope(this); | 3553 EvacuationScope evacuation_scope(this); |
3558 | 3554 |
3559 EvacuateNewSpacePrologue(); | 3555 EvacuateNewSpacePrologue(); |
3560 EvacuatePagesInParallel(); | 3556 EvacuatePagesInParallel(); |
3561 heap()->new_space()->set_age_mark(heap()->new_space()->top()); | 3557 heap()->new_space()->SealIntermediateGeneration(); |
3562 } | 3558 } |
3563 | 3559 |
3564 UpdatePointersAfterEvacuation(); | 3560 UpdatePointersAfterEvacuation(); |
3565 | 3561 |
3566 if (!heap()->new_space()->Rebalance()) { | 3562 if (!heap()->new_space()->Rebalance()) { |
3567 FatalProcessOutOfMemory("NewSpace::Rebalance"); | 3563 FatalProcessOutOfMemory("NewSpace::Rebalance"); |
3568 } | 3564 } |
3569 | 3565 |
3570 // Give pages that are queued to be freed back to the OS. Note that filtering | 3566 // Give pages that are queued to be freed back to the OS. Note that filtering |
3571 // slots only handles old space (for unboxed doubles), and thus map space can | 3567 // slots only handles old space (for unboxed doubles), and thus map space can |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4042 // The target is always in old space, we don't have to record the slot in | 4038 // The target is always in old space, we don't have to record the slot in |
4043 // the old-to-new remembered set. | 4039 // the old-to-new remembered set. |
4044 DCHECK(!heap()->InNewSpace(target)); | 4040 DCHECK(!heap()->InNewSpace(target)); |
4045 RecordRelocSlot(host, &rinfo, target); | 4041 RecordRelocSlot(host, &rinfo, target); |
4046 } | 4042 } |
4047 } | 4043 } |
4048 } | 4044 } |
4049 | 4045 |
4050 } // namespace internal | 4046 } // namespace internal |
4051 } // namespace v8 | 4047 } // namespace v8 |
OLD | NEW |