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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // Make sure that Prepare() has been called. The individual steps below will | 329 // Make sure that Prepare() has been called. The individual steps below will |
330 // update the state as they proceed. | 330 // update the state as they proceed. |
331 DCHECK(state_ == PREPARE_GC); | 331 DCHECK(state_ == PREPARE_GC); |
332 | 332 |
333 MarkLiveObjects(); | 333 MarkLiveObjects(); |
334 | 334 |
335 DCHECK(heap_->incremental_marking()->IsStopped()); | 335 DCHECK(heap_->incremental_marking()->IsStopped()); |
336 | 336 |
337 ClearNonLiveReferences(); | 337 ClearNonLiveReferences(); |
338 | 338 |
| 339 RecordObjectStats(); |
| 340 |
339 #ifdef VERIFY_HEAP | 341 #ifdef VERIFY_HEAP |
340 if (FLAG_verify_heap) { | 342 if (FLAG_verify_heap) { |
341 VerifyMarking(heap_); | 343 VerifyMarking(heap_); |
342 } | 344 } |
343 #endif | 345 #endif |
344 | 346 |
345 SweepSpaces(); | 347 SweepSpaces(); |
346 | 348 |
347 EvacuateNewSpaceAndCandidates(); | 349 EvacuateNewSpaceAndCandidates(); |
348 | 350 |
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2266 SpaceIterator space_it(heap()); | 2268 SpaceIterator space_it(heap()); |
2267 HeapObject* obj = nullptr; | 2269 HeapObject* obj = nullptr; |
2268 while (space_it.has_next()) { | 2270 while (space_it.has_next()) { |
2269 ObjectIterator* it = space_it.next(); | 2271 ObjectIterator* it = space_it.next(); |
2270 while ((obj = it->Next()) != nullptr) { | 2272 while ((obj = it->Next()) != nullptr) { |
2271 visitor->Visit(obj); | 2273 visitor->Visit(obj); |
2272 } | 2274 } |
2273 } | 2275 } |
2274 } | 2276 } |
2275 | 2277 |
| 2278 void MarkCompactCollector::RecordObjectStats() { |
| 2279 if (FLAG_track_gc_object_stats) { |
| 2280 ObjectStatsVisitor visitor(heap()->live_object_stats_, |
| 2281 heap()->dead_object_stats_); |
| 2282 VisitAllObjects(&visitor); |
| 2283 if (FLAG_trace_gc_object_stats) { |
| 2284 heap()->live_object_stats_->PrintJSON("live"); |
| 2285 heap()->dead_object_stats_->PrintJSON("dead"); |
| 2286 } |
| 2287 heap()->live_object_stats_->CheckpointObjectStats(); |
| 2288 heap()->dead_object_stats_->ClearObjectStats(); |
| 2289 } |
| 2290 } |
| 2291 |
2276 void MarkCompactCollector::MarkLiveObjects() { | 2292 void MarkCompactCollector::MarkLiveObjects() { |
2277 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK); | 2293 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK); |
2278 double start_time = 0.0; | 2294 double start_time = 0.0; |
2279 if (FLAG_print_cumulative_gc_stat) { | 2295 if (FLAG_print_cumulative_gc_stat) { |
2280 start_time = heap_->MonotonicallyIncreasingTimeInMs(); | 2296 start_time = heap_->MonotonicallyIncreasingTimeInMs(); |
2281 } | 2297 } |
2282 // The recursive GC marker detects when it is nearing stack overflow, | 2298 // The recursive GC marker detects when it is nearing stack overflow, |
2283 // and switches to a different marking system. JS interrupts interfere | 2299 // and switches to a different marking system. JS interrupts interfere |
2284 // with the C stack limit check. | 2300 // with the C stack limit check. |
2285 PostponeInterruptsScope postpone(isolate()); | 2301 PostponeInterruptsScope postpone(isolate()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 if (UsingEmbedderHeapTracer()) { | 2381 if (UsingEmbedderHeapTracer()) { |
2366 embedder_heap_tracer()->TraceEpilogue(); | 2382 embedder_heap_tracer()->TraceEpilogue(); |
2367 } | 2383 } |
2368 } | 2384 } |
2369 } | 2385 } |
2370 | 2386 |
2371 if (FLAG_print_cumulative_gc_stat) { | 2387 if (FLAG_print_cumulative_gc_stat) { |
2372 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | 2388 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - |
2373 start_time); | 2389 start_time); |
2374 } | 2390 } |
2375 if (FLAG_track_gc_object_stats) { | |
2376 ObjectStatsVisitor visitor(heap()->live_object_stats_, | |
2377 heap()->dead_object_stats_); | |
2378 VisitAllObjects(&visitor); | |
2379 if (FLAG_trace_gc_object_stats) { | |
2380 heap()->live_object_stats_->PrintJSON("live"); | |
2381 heap()->dead_object_stats_->PrintJSON("dead"); | |
2382 } | |
2383 heap()->live_object_stats_->CheckpointObjectStats(); | |
2384 heap()->dead_object_stats_->ClearObjectStats(); | |
2385 } | |
2386 } | 2391 } |
2387 | 2392 |
2388 | 2393 |
2389 void MarkCompactCollector::ClearNonLiveReferences() { | 2394 void MarkCompactCollector::ClearNonLiveReferences() { |
2390 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); | 2395 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR); |
2391 | 2396 |
2392 { | 2397 { |
2393 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_STRING_TABLE); | 2398 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_STRING_TABLE); |
2394 | 2399 |
2395 // Prune the string table removing all strings only pointed to by the | 2400 // Prune the string table removing all strings only pointed to by the |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4078 // The target is always in old space, we don't have to record the slot in | 4083 // The target is always in old space, we don't have to record the slot in |
4079 // the old-to-new remembered set. | 4084 // the old-to-new remembered set. |
4080 DCHECK(!heap()->InNewSpace(target)); | 4085 DCHECK(!heap()->InNewSpace(target)); |
4081 RecordRelocSlot(host, &rinfo, target); | 4086 RecordRelocSlot(host, &rinfo, target); |
4082 } | 4087 } |
4083 } | 4088 } |
4084 } | 4089 } |
4085 | 4090 |
4086 } // namespace internal | 4091 } // namespace internal |
4087 } // namespace v8 | 4092 } // namespace v8 |
OLD | NEW |