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