| 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. |
| 28 if (FLAG_runtime_call_stats) { |
| 29 RuntimeCallStats* stats = |
| 30 tracer_->heap_->isolate()->counters()->runtime_call_stats(); |
| 31 timer_.Initialize(&stats->GC, stats->current_timer()); |
| 32 stats->Enter(&timer_); |
| 33 } |
| 27 } | 34 } |
| 28 | 35 |
| 29 | 36 |
| 30 GCTracer::Scope::~Scope() { | 37 GCTracer::Scope::~Scope() { |
| 31 DCHECK(scope_ < NUMBER_OF_SCOPES); // scope_ is unsigned. | 38 DCHECK(scope_ < NUMBER_OF_SCOPES); // scope_ is unsigned. |
| 32 tracer_->current_.scopes[scope_] += | 39 tracer_->current_.scopes[scope_] += |
| 33 tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_; | 40 tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_; |
| 41 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 42 if (FLAG_runtime_call_stats) { |
| 43 tracer_->heap_->isolate()->counters()->runtime_call_stats()->Leave(&timer_); |
| 44 } |
| 34 } | 45 } |
| 35 | 46 |
| 36 | 47 |
| 37 GCTracer::AllocationEvent::AllocationEvent(double duration, | 48 GCTracer::AllocationEvent::AllocationEvent(double duration, |
| 38 size_t allocation_in_bytes) { | 49 size_t allocation_in_bytes) { |
| 39 duration_ = duration; | 50 duration_ = duration; |
| 40 allocation_in_bytes_ = allocation_in_bytes; | 51 allocation_in_bytes_ = allocation_in_bytes; |
| 41 } | 52 } |
| 42 | 53 |
| 43 | 54 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 186 |
| 176 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 187 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 177 current_.scopes[i] = 0; | 188 current_.scopes[i] = 0; |
| 178 } | 189 } |
| 179 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); | 190 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); |
| 180 int used_memory = static_cast<int>(current_.start_object_size / KB); | 191 int used_memory = static_cast<int>(current_.start_object_size / KB); |
| 181 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( | 192 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
| 182 start_time, committed_memory); | 193 start_time, committed_memory); |
| 183 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( | 194 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
| 184 start_time, used_memory); | 195 start_time, used_memory); |
| 196 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 197 if (FLAG_runtime_call_stats) { |
| 198 RuntimeCallStats* stats = |
| 199 heap_->isolate()->counters()->runtime_call_stats(); |
| 200 timer_.Initialize(&stats->GC, stats->current_timer()); |
| 201 stats->Enter(&timer_); |
| 202 } |
| 185 } | 203 } |
| 186 | 204 |
| 187 | 205 |
| 188 void GCTracer::Stop(GarbageCollector collector) { | 206 void GCTracer::Stop(GarbageCollector collector) { |
| 189 start_counter_--; | 207 start_counter_--; |
| 190 if (start_counter_ != 0) { | 208 if (start_counter_ != 0) { |
| 191 Output("[Finished reentrant %s during %s.]\n", | 209 Output("[Finished reentrant %s during %s.]\n", |
| 192 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", | 210 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", |
| 193 current_.TypeName(false)); | 211 current_.TypeName(false)); |
| 194 return; | 212 return; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 else | 292 else |
| 275 Print(); | 293 Print(); |
| 276 | 294 |
| 277 if (FLAG_trace_gc) { | 295 if (FLAG_trace_gc) { |
| 278 heap_->PrintShortHeapStatistics(); | 296 heap_->PrintShortHeapStatistics(); |
| 279 } | 297 } |
| 280 | 298 |
| 281 longest_incremental_marking_finalization_step_ = 0.0; | 299 longest_incremental_marking_finalization_step_ = 0.0; |
| 282 cumulative_incremental_marking_finalization_steps_ = 0; | 300 cumulative_incremental_marking_finalization_steps_ = 0; |
| 283 cumulative_incremental_marking_finalization_duration_ = 0.0; | 301 cumulative_incremental_marking_finalization_duration_ = 0.0; |
| 302 // TODO(cbruni): remove once we fully moved to a trace-based system. |
| 303 if (FLAG_runtime_call_stats) { |
| 304 heap_->isolate()->counters()->runtime_call_stats()->Leave(&timer_); |
| 305 } |
| 284 } | 306 } |
| 285 | 307 |
| 286 | 308 |
| 287 void GCTracer::SampleAllocation(double current_ms, | 309 void GCTracer::SampleAllocation(double current_ms, |
| 288 size_t new_space_counter_bytes, | 310 size_t new_space_counter_bytes, |
| 289 size_t old_generation_counter_bytes) { | 311 size_t old_generation_counter_bytes) { |
| 290 if (allocation_time_ms_ == 0) { | 312 if (allocation_time_ms_ == 0) { |
| 291 // It is the first sample. | 313 // It is the first sample. |
| 292 allocation_time_ms_ = current_ms; | 314 allocation_time_ms_ = current_ms; |
| 293 new_space_allocation_counter_bytes_ = new_space_counter_bytes; | 315 new_space_allocation_counter_bytes_ = new_space_counter_bytes; |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 | 942 |
| 921 | 943 |
| 922 bool GCTracer::SurvivalEventsRecorded() const { | 944 bool GCTracer::SurvivalEventsRecorded() const { |
| 923 return survival_events_.size() > 0; | 945 return survival_events_.size() > 0; |
| 924 } | 946 } |
| 925 | 947 |
| 926 | 948 |
| 927 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } | 949 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } |
| 928 } // namespace internal | 950 } // namespace internal |
| 929 } // namespace v8 | 951 } // namespace v8 |
| OLD | NEW |