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