| 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 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 static intptr_t CountTotalHolesSize(Heap* heap) { | 14 static intptr_t CountTotalHolesSize(Heap* heap) { |
| 15 intptr_t holes_size = 0; | 15 intptr_t holes_size = 0; |
| 16 OldSpaces spaces(heap); | 16 OldSpaces spaces(heap); |
| 17 for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) { | 17 for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) { |
| 18 holes_size += space->Waste() + space->Available(); | 18 holes_size += space->Waste() + space->Available(); |
| 19 } | 19 } |
| 20 return holes_size; | 20 return holes_size; |
| 21 } | 21 } |
| 22 | 22 |
| 23 | 23 |
| 24 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) | 24 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) |
| 25 : tracer_(tracer), scope_(scope) { | 25 : tracer_(tracer), scope_(scope) { |
| 26 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); | 26 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); |
| 27 // TODO(cbruni): remove once we fully moved to a trace-based system. | 27 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 28 if (FLAG_runtime_call_stats) { | 28 if (FLAG_runtime_call_stats) { |
| 29 RuntimeCallStats::Enter(tracer_->heap_->isolate(), &timer_, | 29 RuntimeCallStats::Enter( |
| 30 &RuntimeCallStats::GC); | 30 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_, |
| 31 &RuntimeCallStats::GC); |
| 31 } | 32 } |
| 33 // TODO(lpy): Add a tracing equivalent for the runtime call stats. |
| 32 } | 34 } |
| 33 | 35 |
| 34 GCTracer::Scope::~Scope() { | 36 GCTracer::Scope::~Scope() { |
| 35 tracer_->AddScopeSample( | 37 tracer_->AddScopeSample( |
| 36 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); | 38 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); |
| 37 // TODO(cbruni): remove once we fully moved to a trace-based system. | 39 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 38 if (FLAG_runtime_call_stats) { | 40 if (FLAG_runtime_call_stats) { |
| 39 RuntimeCallStats::Leave(tracer_->heap_->isolate(), &timer_); | 41 RuntimeCallStats::Leave( |
| 42 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_); |
| 40 } | 43 } |
| 44 // TODO(lpy): Add a tracing equivalent for the runtime call stats. |
| 41 } | 45 } |
| 42 | 46 |
| 43 const char* GCTracer::Scope::Name(ScopeId id) { | 47 const char* GCTracer::Scope::Name(ScopeId id) { |
| 44 #define CASE(scope) \ | 48 #define CASE(scope) \ |
| 45 case Scope::scope: \ | 49 case Scope::scope: \ |
| 46 return "V8.GC_" #scope; | 50 return "V8.GC_" #scope; |
| 47 switch (id) { | 51 switch (id) { |
| 48 TRACER_SCOPES(CASE) | 52 TRACER_SCOPES(CASE) |
| 49 case Scope::NUMBER_OF_SCOPES: | 53 case Scope::NUMBER_OF_SCOPES: |
| 50 break; | 54 break; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 203 } |
| 200 | 204 |
| 201 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); | 205 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); |
| 202 int used_memory = static_cast<int>(current_.start_object_size / KB); | 206 int used_memory = static_cast<int>(current_.start_object_size / KB); |
| 203 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( | 207 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
| 204 start_time, committed_memory); | 208 start_time, committed_memory); |
| 205 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( | 209 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
| 206 start_time, used_memory); | 210 start_time, used_memory); |
| 207 // TODO(cbruni): remove once we fully moved to a trace-based system. | 211 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 208 if (FLAG_runtime_call_stats) { | 212 if (FLAG_runtime_call_stats) { |
| 209 RuntimeCallStats::Enter(heap_->isolate(), &timer_, &RuntimeCallStats::GC); | 213 RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(), |
| 214 &timer_, &RuntimeCallStats::GC); |
| 210 } | 215 } |
| 216 // TODO(lpy): Add a tracing equivalent for the runtime call stats. |
| 211 } | 217 } |
| 212 | 218 |
| 213 void GCTracer::MergeBaseline(const Event& baseline) { | 219 void GCTracer::MergeBaseline(const Event& baseline) { |
| 214 current_.incremental_marking_bytes = | 220 current_.incremental_marking_bytes = |
| 215 current_.cumulative_incremental_marking_bytes - | 221 current_.cumulative_incremental_marking_bytes - |
| 216 baseline.cumulative_incremental_marking_bytes; | 222 baseline.cumulative_incremental_marking_bytes; |
| 217 current_.pure_incremental_marking_duration = | 223 current_.pure_incremental_marking_duration = |
| 218 current_.cumulative_pure_incremental_marking_duration - | 224 current_.cumulative_pure_incremental_marking_duration - |
| 219 baseline.cumulative_pure_incremental_marking_duration; | 225 baseline.cumulative_pure_incremental_marking_duration; |
| 220 for (int i = Scope::FIRST_INCREMENTAL_SCOPE; | 226 for (int i = Scope::FIRST_INCREMENTAL_SCOPE; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } else { | 309 } else { |
| 304 Print(); | 310 Print(); |
| 305 } | 311 } |
| 306 | 312 |
| 307 if (FLAG_trace_gc) { | 313 if (FLAG_trace_gc) { |
| 308 heap_->PrintShortHeapStatistics(); | 314 heap_->PrintShortHeapStatistics(); |
| 309 } | 315 } |
| 310 | 316 |
| 311 // TODO(cbruni): remove once we fully moved to a trace-based system. | 317 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 312 if (FLAG_runtime_call_stats) { | 318 if (FLAG_runtime_call_stats) { |
| 313 RuntimeCallStats::Leave(heap_->isolate(), &timer_); | 319 RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(), |
| 320 &timer_); |
| 314 } | 321 } |
| 322 // TODO(lpy): Add a tracing equivalent for the runtime call stats. |
| 315 } | 323 } |
| 316 | 324 |
| 317 | 325 |
| 318 void GCTracer::SampleAllocation(double current_ms, | 326 void GCTracer::SampleAllocation(double current_ms, |
| 319 size_t new_space_counter_bytes, | 327 size_t new_space_counter_bytes, |
| 320 size_t old_generation_counter_bytes) { | 328 size_t old_generation_counter_bytes) { |
| 321 if (allocation_time_ms_ == 0) { | 329 if (allocation_time_ms_ == 0) { |
| 322 // It is the first sample. | 330 // It is the first sample. |
| 323 allocation_time_ms_ = current_ms; | 331 allocation_time_ms_ = current_ms; |
| 324 new_space_allocation_counter_bytes_ = new_space_counter_bytes; | 332 new_space_allocation_counter_bytes_ = new_space_counter_bytes; |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 } | 827 } |
| 820 | 828 |
| 821 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } | 829 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } |
| 822 | 830 |
| 823 void GCTracer::NotifyIncrementalMarkingStart() { | 831 void GCTracer::NotifyIncrementalMarkingStart() { |
| 824 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); | 832 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); |
| 825 } | 833 } |
| 826 | 834 |
| 827 } // namespace internal | 835 } // namespace internal |
| 828 } // namespace v8 | 836 } // namespace v8 |
| OLD | NEW |