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 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 heap()->live_object_stats_->PrintJSON("live"); | 2282 heap()->live_object_stats_->PrintJSON("live"); |
2283 heap()->dead_object_stats_->PrintJSON("dead"); | 2283 heap()->dead_object_stats_->PrintJSON("dead"); |
2284 } | 2284 } |
2285 heap()->live_object_stats_->CheckpointObjectStats(); | 2285 heap()->live_object_stats_->CheckpointObjectStats(); |
2286 heap()->dead_object_stats_->ClearObjectStats(); | 2286 heap()->dead_object_stats_->ClearObjectStats(); |
2287 } | 2287 } |
2288 } | 2288 } |
2289 | 2289 |
2290 void MarkCompactCollector::MarkLiveObjects() { | 2290 void MarkCompactCollector::MarkLiveObjects() { |
2291 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK); | 2291 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK); |
2292 double start_time = 0.0; | |
2293 if (FLAG_print_cumulative_gc_stat) { | |
2294 start_time = heap_->MonotonicallyIncreasingTimeInMs(); | |
2295 } | |
2296 // The recursive GC marker detects when it is nearing stack overflow, | 2292 // The recursive GC marker detects when it is nearing stack overflow, |
2297 // and switches to a different marking system. JS interrupts interfere | 2293 // and switches to a different marking system. JS interrupts interfere |
2298 // with the C stack limit check. | 2294 // with the C stack limit check. |
2299 PostponeInterruptsScope postpone(isolate()); | 2295 PostponeInterruptsScope postpone(isolate()); |
2300 | 2296 |
2301 { | 2297 { |
2302 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_FINISH_INCREMENTAL); | 2298 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_FINISH_INCREMENTAL); |
2303 IncrementalMarking* incremental_marking = heap_->incremental_marking(); | 2299 IncrementalMarking* incremental_marking = heap_->incremental_marking(); |
2304 if (was_marked_incrementally_) { | 2300 if (was_marked_incrementally_) { |
2305 incremental_marking->Finalize(); | 2301 incremental_marking->Finalize(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 // processed and no weakly reachable node can discover new objects groups. | 2371 // processed and no weakly reachable node can discover new objects groups. |
2376 { | 2372 { |
2377 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); | 2373 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); |
2378 ProcessEphemeralMarking(&root_visitor, true); | 2374 ProcessEphemeralMarking(&root_visitor, true); |
2379 if (UsingEmbedderHeapTracer()) { | 2375 if (UsingEmbedderHeapTracer()) { |
2380 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE); | 2376 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WRAPPER_EPILOGUE); |
2381 embedder_heap_tracer()->TraceEpilogue(); | 2377 embedder_heap_tracer()->TraceEpilogue(); |
2382 } | 2378 } |
2383 } | 2379 } |
2384 } | 2380 } |
2385 | |
2386 if (FLAG_print_cumulative_gc_stat) { | |
2387 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | |
2388 start_time); | |
2389 } | |
2390 } | 2381 } |
2391 | 2382 |
2392 | 2383 |
2393 void MarkCompactCollector::ClearNonLiveReferences() { | 2384 void MarkCompactCollector::ClearNonLiveReferences() { |
2394 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); | 2385 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); |
2395 | 2386 |
2396 { | 2387 { |
2397 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_STRING_TABLE); | 2388 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_STRING_TABLE); |
2398 | 2389 |
2399 // Prune the string table removing all strings only pointed to by the | 2390 // Prune the string table removing all strings only pointed to by the |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 | 3955 |
3965 if (FLAG_gc_verbose) { | 3956 if (FLAG_gc_verbose) { |
3966 PrintIsolate(isolate(), "sweeping: space=%s initialized_for_sweeping=%d", | 3957 PrintIsolate(isolate(), "sweeping: space=%s initialized_for_sweeping=%d", |
3967 AllocationSpaceName(space->identity()), will_be_swept); | 3958 AllocationSpaceName(space->identity()), will_be_swept); |
3968 } | 3959 } |
3969 } | 3960 } |
3970 | 3961 |
3971 | 3962 |
3972 void MarkCompactCollector::SweepSpaces() { | 3963 void MarkCompactCollector::SweepSpaces() { |
3973 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_SWEEP); | 3964 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_SWEEP); |
3974 double start_time = 0.0; | |
3975 if (FLAG_print_cumulative_gc_stat) { | |
3976 start_time = heap_->MonotonicallyIncreasingTimeInMs(); | |
3977 } | |
3978 | |
3979 #ifdef DEBUG | 3965 #ifdef DEBUG |
3980 state_ = SWEEP_SPACES; | 3966 state_ = SWEEP_SPACES; |
3981 #endif | 3967 #endif |
3982 | 3968 |
3983 { | 3969 { |
3984 { | 3970 { |
3985 GCTracer::Scope sweep_scope(heap()->tracer(), | 3971 GCTracer::Scope sweep_scope(heap()->tracer(), |
3986 GCTracer::Scope::MC_SWEEP_OLD); | 3972 GCTracer::Scope::MC_SWEEP_OLD); |
3987 StartSweepSpace(heap()->old_space()); | 3973 StartSweepSpace(heap()->old_space()); |
3988 } | 3974 } |
3989 { | 3975 { |
3990 GCTracer::Scope sweep_scope(heap()->tracer(), | 3976 GCTracer::Scope sweep_scope(heap()->tracer(), |
3991 GCTracer::Scope::MC_SWEEP_CODE); | 3977 GCTracer::Scope::MC_SWEEP_CODE); |
3992 StartSweepSpace(heap()->code_space()); | 3978 StartSweepSpace(heap()->code_space()); |
3993 } | 3979 } |
3994 { | 3980 { |
3995 GCTracer::Scope sweep_scope(heap()->tracer(), | 3981 GCTracer::Scope sweep_scope(heap()->tracer(), |
3996 GCTracer::Scope::MC_SWEEP_MAP); | 3982 GCTracer::Scope::MC_SWEEP_MAP); |
3997 StartSweepSpace(heap()->map_space()); | 3983 StartSweepSpace(heap()->map_space()); |
3998 } | 3984 } |
3999 sweeper().StartSweeping(); | 3985 sweeper().StartSweeping(); |
4000 } | 3986 } |
4001 | 3987 |
4002 // Deallocate unmarked large objects. | 3988 // Deallocate unmarked large objects. |
4003 heap_->lo_space()->FreeUnmarkedObjects(); | 3989 heap_->lo_space()->FreeUnmarkedObjects(); |
4004 | |
4005 if (FLAG_print_cumulative_gc_stat) { | |
4006 heap_->tracer()->AddSweepingTime(heap_->MonotonicallyIncreasingTimeInMs() - | |
4007 start_time); | |
4008 } | |
4009 } | 3990 } |
4010 | 3991 |
4011 Isolate* MarkCompactCollector::isolate() const { return heap_->isolate(); } | 3992 Isolate* MarkCompactCollector::isolate() const { return heap_->isolate(); } |
4012 | 3993 |
4013 | 3994 |
4014 void MarkCompactCollector::Initialize() { | 3995 void MarkCompactCollector::Initialize() { |
4015 MarkCompactMarkingVisitor::Initialize(); | 3996 MarkCompactMarkingVisitor::Initialize(); |
4016 IncrementalMarking::Initialize(); | 3997 IncrementalMarking::Initialize(); |
4017 } | 3998 } |
4018 | 3999 |
(...skipping 23 matching lines...) Expand all Loading... |
4042 // The target is always in old space, we don't have to record the slot in | 4023 // The target is always in old space, we don't have to record the slot in |
4043 // the old-to-new remembered set. | 4024 // the old-to-new remembered set. |
4044 DCHECK(!heap()->InNewSpace(target)); | 4025 DCHECK(!heap()->InNewSpace(target)); |
4045 RecordRelocSlot(host, &rinfo, target); | 4026 RecordRelocSlot(host, &rinfo, target); |
4046 } | 4027 } |
4047 } | 4028 } |
4048 } | 4029 } |
4049 | 4030 |
4050 } // namespace internal | 4031 } // namespace internal |
4051 } // namespace v8 | 4032 } // namespace v8 |
OLD | NEW |