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 3129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3140 } | 3140 } |
3141 break; | 3141 break; |
3142 default: | 3142 default: |
3143 UNREACHABLE(); | 3143 UNREACHABLE(); |
3144 } | 3144 } |
3145 } | 3145 } |
3146 ReportCompactionProgress(evacuation_time, saved_live_bytes); | 3146 ReportCompactionProgress(evacuation_time, saved_live_bytes); |
3147 if (FLAG_trace_evacuation) { | 3147 if (FLAG_trace_evacuation) { |
3148 PrintIsolate(heap->isolate(), | 3148 PrintIsolate(heap->isolate(), |
3149 "evacuation[%p]: page=%p new_space=%d " | 3149 "evacuation[%p]: page=%p new_space=%d " |
3150 "page_evacuation=%d executable=%d live_bytes=%d time=%f\n", | 3150 "page_evacuation=%d executable=%d contains_age_mark=%d " |
| 3151 "live_bytes=%d time=%f\n", |
3151 static_cast<void*>(this), static_cast<void*>(page), | 3152 static_cast<void*>(this), static_cast<void*>(page), |
3152 page->InNewSpace(), | 3153 page->InNewSpace(), |
3153 page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) || | 3154 page->IsFlagSet(Page::PAGE_NEW_OLD_PROMOTION) || |
3154 page->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION), | 3155 page->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION), |
3155 page->IsFlagSet(MemoryChunk::IS_EXECUTABLE), saved_live_bytes, | 3156 page->IsFlagSet(MemoryChunk::IS_EXECUTABLE), |
3156 evacuation_time); | 3157 page->Contains(heap->new_space()->age_mark()), |
| 3158 saved_live_bytes, evacuation_time); |
3157 } | 3159 } |
3158 return success; | 3160 return success; |
3159 } | 3161 } |
3160 | 3162 |
3161 void MarkCompactCollector::Evacuator::Finalize() { | 3163 void MarkCompactCollector::Evacuator::Finalize() { |
3162 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE)); | 3164 heap()->old_space()->MergeCompactionSpace(compaction_spaces_.Get(OLD_SPACE)); |
3163 heap()->code_space()->MergeCompactionSpace( | 3165 heap()->code_space()->MergeCompactionSpace( |
3164 compaction_spaces_.Get(CODE_SPACE)); | 3166 compaction_spaces_.Get(CODE_SPACE)); |
3165 heap()->tracer()->AddCompactionEvent(duration_, bytes_compacted_); | 3167 heap()->tracer()->AddCompactionEvent(duration_, bytes_compacted_); |
3166 heap()->IncrementPromotedObjectsSize(new_space_visitor_.promoted_size() + | 3168 heap()->IncrementPromotedObjectsSize(new_space_visitor_.promoted_size() + |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 &page_parallel_job_semaphore_); | 3259 &page_parallel_job_semaphore_); |
3258 | 3260 |
3259 int abandoned_pages = 0; | 3261 int abandoned_pages = 0; |
3260 intptr_t live_bytes = 0; | 3262 intptr_t live_bytes = 0; |
3261 for (Page* page : evacuation_candidates_) { | 3263 for (Page* page : evacuation_candidates_) { |
3262 live_bytes += page->LiveBytes(); | 3264 live_bytes += page->LiveBytes(); |
3263 job.AddPage(page, &abandoned_pages); | 3265 job.AddPage(page, &abandoned_pages); |
3264 } | 3266 } |
3265 | 3267 |
3266 const bool reduce_memory = heap()->ShouldReduceMemory(); | 3268 const bool reduce_memory = heap()->ShouldReduceMemory(); |
| 3269 const Address age_mark = heap()->new_space()->age_mark(); |
3267 for (Page* page : newspace_evacuation_candidates_) { | 3270 for (Page* page : newspace_evacuation_candidates_) { |
3268 live_bytes += page->LiveBytes(); | 3271 live_bytes += page->LiveBytes(); |
3269 if (!reduce_memory && !page->NeverEvacuate() && | 3272 if (!reduce_memory && !page->NeverEvacuate() && |
3270 (page->LiveBytes() > Evacuator::PageEvacuationThreshold())) { | 3273 (page->LiveBytes() > Evacuator::PageEvacuationThreshold()) && |
3271 if (page->InIntermediateGeneration()) { | 3274 !page->Contains(age_mark)) { |
| 3275 if (page->IsFlagSet(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK)) { |
3272 EvacuateNewSpacePageVisitor::MoveToOldSpace(page, heap()->old_space()); | 3276 EvacuateNewSpacePageVisitor::MoveToOldSpace(page, heap()->old_space()); |
3273 } else { | 3277 } else { |
3274 EvacuateNewSpacePageVisitor::MoveToToSpace(page); | 3278 EvacuateNewSpacePageVisitor::MoveToToSpace(page); |
3275 } | 3279 } |
3276 } | 3280 } |
3277 | 3281 |
3278 job.AddPage(page, &abandoned_pages); | 3282 job.AddPage(page, &abandoned_pages); |
3279 } | 3283 } |
3280 DCHECK_GE(job.NumberOfPages(), 1); | 3284 DCHECK_GE(job.NumberOfPages(), 1); |
3281 | 3285 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { | 3511 void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
3508 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); | 3512 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE); |
3509 Heap::RelocationLock relocation_lock(heap()); | 3513 Heap::RelocationLock relocation_lock(heap()); |
3510 | 3514 |
3511 { | 3515 { |
3512 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_COPY); | 3516 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_EVACUATE_COPY); |
3513 EvacuationScope evacuation_scope(this); | 3517 EvacuationScope evacuation_scope(this); |
3514 | 3518 |
3515 EvacuateNewSpacePrologue(); | 3519 EvacuateNewSpacePrologue(); |
3516 EvacuatePagesInParallel(); | 3520 EvacuatePagesInParallel(); |
3517 heap()->new_space()->SealIntermediateGeneration(); | 3521 heap()->new_space()->set_age_mark(heap()->new_space()->top()); |
3518 } | 3522 } |
3519 | 3523 |
3520 UpdatePointersAfterEvacuation(); | 3524 UpdatePointersAfterEvacuation(); |
3521 | 3525 |
3522 if (!heap()->new_space()->Rebalance()) { | 3526 if (!heap()->new_space()->Rebalance()) { |
3523 FatalProcessOutOfMemory("NewSpace::Rebalance"); | 3527 FatalProcessOutOfMemory("NewSpace::Rebalance"); |
3524 } | 3528 } |
3525 | 3529 |
3526 // Give pages that are queued to be freed back to the OS. Note that filtering | 3530 // Give pages that are queued to be freed back to the OS. Note that filtering |
3527 // slots only handles old space (for unboxed doubles), and thus map space can | 3531 // slots only handles old space (for unboxed doubles), and thus map space can |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3994 // The target is always in old space, we don't have to record the slot in | 3998 // The target is always in old space, we don't have to record the slot in |
3995 // the old-to-new remembered set. | 3999 // the old-to-new remembered set. |
3996 DCHECK(!heap()->InNewSpace(target)); | 4000 DCHECK(!heap()->InNewSpace(target)); |
3997 RecordRelocSlot(host, &rinfo, target); | 4001 RecordRelocSlot(host, &rinfo, target); |
3998 } | 4002 } |
3999 } | 4003 } |
4000 } | 4004 } |
4001 | 4005 |
4002 } // namespace internal | 4006 } // namespace internal |
4003 } // namespace v8 | 4007 } // namespace v8 |
OLD | NEW |