| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/gc-tracer.h" | 5 #include "src/heap/gc-tracer.h" |
| 6 | 6 |
| 7 #include "src/counters.h" | 7 #include "src/counters.h" |
| 8 #include "src/heap/heap-inl.h" | 8 #include "src/heap/heap-inl.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) | 27 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) |
| 28 : tracer_(tracer), scope_(scope) { | 28 : tracer_(tracer), scope_(scope) { |
| 29 // All accesses to incremental_marking_scope assume that incremental marking | 29 // All accesses to incremental_marking_scope assume that incremental marking |
| 30 // scopes come first. | 30 // scopes come first. |
| 31 STATIC_ASSERT(FIRST_INCREMENTAL_SCOPE == 0); | 31 STATIC_ASSERT(FIRST_INCREMENTAL_SCOPE == 0); |
| 32 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); | 32 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); |
| 33 // TODO(cbruni): remove once we fully moved to a trace-based system. | 33 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 34 if (V8_UNLIKELY(FLAG_runtime_stats)) { | 34 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || |
| 35 FLAG_runtime_call_stats) { |
| 35 RuntimeCallStats::Enter( | 36 RuntimeCallStats::Enter( |
| 36 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_, | 37 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_, |
| 37 &RuntimeCallStats::GC); | 38 &RuntimeCallStats::GC); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 GCTracer::Scope::~Scope() { | 42 GCTracer::Scope::~Scope() { |
| 42 tracer_->AddScopeSample( | 43 tracer_->AddScopeSample( |
| 43 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); | 44 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); |
| 44 // TODO(cbruni): remove once we fully moved to a trace-based system. | 45 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 45 if (V8_UNLIKELY(FLAG_runtime_stats)) { | 46 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || |
| 47 FLAG_runtime_call_stats) { |
| 46 RuntimeCallStats::Leave( | 48 RuntimeCallStats::Leave( |
| 47 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_); | 49 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_); |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 | 52 |
| 51 const char* GCTracer::Scope::Name(ScopeId id) { | 53 const char* GCTracer::Scope::Name(ScopeId id) { |
| 52 #define CASE(scope) \ | 54 #define CASE(scope) \ |
| 53 case Scope::scope: \ | 55 case Scope::scope: \ |
| 54 return "V8.GC_" #scope; | 56 return "V8.GC_" #scope; |
| 55 switch (id) { | 57 switch (id) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 198 |
| 197 if (collector == SCAVENGER) { | 199 if (collector == SCAVENGER) { |
| 198 counters->scavenge_reason()->AddSample(static_cast<int>(gc_reason)); | 200 counters->scavenge_reason()->AddSample(static_cast<int>(gc_reason)); |
| 199 } else { | 201 } else { |
| 200 counters->mark_compact_reason()->AddSample(static_cast<int>(gc_reason)); | 202 counters->mark_compact_reason()->AddSample(static_cast<int>(gc_reason)); |
| 201 } | 203 } |
| 202 counters->aggregated_memory_heap_committed()->AddSample(start_time, | 204 counters->aggregated_memory_heap_committed()->AddSample(start_time, |
| 203 committed_memory); | 205 committed_memory); |
| 204 counters->aggregated_memory_heap_used()->AddSample(start_time, used_memory); | 206 counters->aggregated_memory_heap_used()->AddSample(start_time, used_memory); |
| 205 // TODO(cbruni): remove once we fully moved to a trace-based system. | 207 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 206 if (V8_UNLIKELY(FLAG_runtime_stats)) { | 208 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || |
| 209 FLAG_runtime_call_stats) { |
| 207 RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(), | 210 RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(), |
| 208 &timer_, &RuntimeCallStats::GC); | 211 &timer_, &RuntimeCallStats::GC); |
| 209 } | 212 } |
| 210 } | 213 } |
| 211 | 214 |
| 212 void GCTracer::ResetIncrementalMarkingCounters() { | 215 void GCTracer::ResetIncrementalMarkingCounters() { |
| 213 incremental_marking_bytes_ = 0; | 216 incremental_marking_bytes_ = 0; |
| 214 incremental_marking_duration_ = 0; | 217 incremental_marking_duration_ = 0; |
| 215 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { | 218 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { |
| 216 incremental_marking_scopes_[i].ResetCurrentCycle(); | 219 incremental_marking_scopes_[i].ResetCurrentCycle(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 PrintNVP(); | 289 PrintNVP(); |
| 287 } else { | 290 } else { |
| 288 Print(); | 291 Print(); |
| 289 } | 292 } |
| 290 | 293 |
| 291 if (FLAG_trace_gc) { | 294 if (FLAG_trace_gc) { |
| 292 heap_->PrintShortHeapStatistics(); | 295 heap_->PrintShortHeapStatistics(); |
| 293 } | 296 } |
| 294 | 297 |
| 295 // TODO(cbruni): remove once we fully moved to a trace-based system. | 298 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 296 if (V8_UNLIKELY(FLAG_runtime_stats)) { | 299 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || |
| 300 FLAG_runtime_call_stats) { |
| 297 RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(), | 301 RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(), |
| 298 &timer_); | 302 &timer_); |
| 299 } | 303 } |
| 300 } | 304 } |
| 301 | 305 |
| 302 | 306 |
| 303 void GCTracer::SampleAllocation(double current_ms, | 307 void GCTracer::SampleAllocation(double current_ms, |
| 304 size_t new_space_counter_bytes, | 308 size_t new_space_counter_bytes, |
| 305 size_t old_generation_counter_bytes) { | 309 size_t old_generation_counter_bytes) { |
| 306 if (allocation_time_ms_ == 0) { | 310 if (allocation_time_ms_ == 0) { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 818 } |
| 815 | 819 |
| 816 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } | 820 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } |
| 817 | 821 |
| 818 void GCTracer::NotifyIncrementalMarkingStart() { | 822 void GCTracer::NotifyIncrementalMarkingStart() { |
| 819 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); | 823 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); |
| 820 } | 824 } |
| 821 | 825 |
| 822 } // namespace internal | 826 } // namespace internal |
| 823 } // namespace v8 | 827 } // namespace v8 |
| OLD | NEW |