| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 GCTracer::GCTracer(Heap* heap) | 111 GCTracer::GCTracer(Heap* heap) |
| 112 : heap_(heap), | 112 : heap_(heap), |
| 113 current_(Event::START, GarbageCollectionReason::kUnknown, nullptr), | 113 current_(Event::START, GarbageCollectionReason::kUnknown, nullptr), |
| 114 previous_(current_), | 114 previous_(current_), |
| 115 previous_incremental_mark_compactor_event_(current_), | 115 previous_incremental_mark_compactor_event_(current_), |
| 116 cumulative_incremental_marking_bytes_(0), | 116 cumulative_incremental_marking_bytes_(0), |
| 117 cumulative_incremental_marking_duration_(0.0), | 117 cumulative_incremental_marking_duration_(0.0), |
| 118 cumulative_pure_incremental_marking_duration_(0.0), | 118 cumulative_pure_incremental_marking_duration_(0.0), |
| 119 cumulative_marking_duration_(0.0), | |
| 120 cumulative_sweeping_duration_(0.0), | |
| 121 allocation_time_ms_(0.0), | 119 allocation_time_ms_(0.0), |
| 122 new_space_allocation_counter_bytes_(0), | 120 new_space_allocation_counter_bytes_(0), |
| 123 old_generation_allocation_counter_bytes_(0), | 121 old_generation_allocation_counter_bytes_(0), |
| 124 allocation_duration_since_gc_(0.0), | 122 allocation_duration_since_gc_(0.0), |
| 125 new_space_allocation_in_bytes_since_gc_(0), | 123 new_space_allocation_in_bytes_since_gc_(0), |
| 126 old_generation_allocation_in_bytes_since_gc_(0), | 124 old_generation_allocation_in_bytes_since_gc_(0), |
| 127 combined_mark_compact_speed_cache_(0.0), | 125 combined_mark_compact_speed_cache_(0.0), |
| 128 start_counter_(0) { | 126 start_counter_(0) { |
| 129 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); | 127 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); |
| 130 } | 128 } |
| 131 | 129 |
| 132 void GCTracer::ResetForTesting() { | 130 void GCTracer::ResetForTesting() { |
| 133 current_ = Event(Event::START, GarbageCollectionReason::kTesting, nullptr); | 131 current_ = Event(Event::START, GarbageCollectionReason::kTesting, nullptr); |
| 134 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); | 132 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); |
| 135 previous_ = previous_incremental_mark_compactor_event_ = current_; | 133 previous_ = previous_incremental_mark_compactor_event_ = current_; |
| 136 cumulative_incremental_marking_bytes_ = 0.0; | 134 cumulative_incremental_marking_bytes_ = 0.0; |
| 137 cumulative_incremental_marking_duration_ = 0.0; | 135 cumulative_incremental_marking_duration_ = 0.0; |
| 138 cumulative_pure_incremental_marking_duration_ = 0.0; | 136 cumulative_pure_incremental_marking_duration_ = 0.0; |
| 139 cumulative_marking_duration_ = 0.0; | |
| 140 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { | 137 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { |
| 141 incremental_marking_scopes_[i].cumulative_duration = 0.0; | 138 incremental_marking_scopes_[i].cumulative_duration = 0.0; |
| 142 incremental_marking_scopes_[i].steps = 0; | 139 incremental_marking_scopes_[i].steps = 0; |
| 143 incremental_marking_scopes_[i].longest_step = 0.0; | 140 incremental_marking_scopes_[i].longest_step = 0.0; |
| 144 } | 141 } |
| 145 cumulative_sweeping_duration_ = 0.0; | |
| 146 allocation_time_ms_ = 0.0; | 142 allocation_time_ms_ = 0.0; |
| 147 new_space_allocation_counter_bytes_ = 0.0; | 143 new_space_allocation_counter_bytes_ = 0.0; |
| 148 old_generation_allocation_counter_bytes_ = 0.0; | 144 old_generation_allocation_counter_bytes_ = 0.0; |
| 149 allocation_duration_since_gc_ = 0.0; | 145 allocation_duration_since_gc_ = 0.0; |
| 150 new_space_allocation_in_bytes_since_gc_ = 0.0; | 146 new_space_allocation_in_bytes_since_gc_ = 0.0; |
| 151 old_generation_allocation_in_bytes_since_gc_ = 0.0; | 147 old_generation_allocation_in_bytes_since_gc_ = 0.0; |
| 152 combined_mark_compact_speed_cache_ = 0.0; | 148 combined_mark_compact_speed_cache_ = 0.0; |
| 153 recorded_scavenges_total_.Reset(); | 149 recorded_scavenges_total_.Reset(); |
| 154 recorded_scavenges_survived_.Reset(); | 150 recorded_scavenges_survived_.Reset(); |
| 155 recorded_compactions_.Reset(); | 151 recorded_compactions_.Reset(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DCHECK(current_.incremental_marking_bytes == 0); | 294 DCHECK(current_.incremental_marking_bytes == 0); |
| 299 DCHECK(current_.pure_incremental_marking_duration == 0); | 295 DCHECK(current_.pure_incremental_marking_duration == 0); |
| 300 recorded_mark_compacts_.Push( | 296 recorded_mark_compacts_.Push( |
| 301 MakeBytesAndDuration(current_.start_object_size, duration)); | 297 MakeBytesAndDuration(current_.start_object_size, duration)); |
| 302 combined_mark_compact_speed_cache_ = 0.0; | 298 combined_mark_compact_speed_cache_ = 0.0; |
| 303 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { | 299 for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { |
| 304 incremental_marking_scopes_[i].ResetCurrentCycle(); | 300 incremental_marking_scopes_[i].ResetCurrentCycle(); |
| 305 } | 301 } |
| 306 } | 302 } |
| 307 | 303 |
| 308 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); | 304 heap_->UpdateTotalGCTime(duration); |
| 309 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator, | |
| 310 current_.scopes[Scope::MC_MARK]); | |
| 311 | 305 |
| 312 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) | 306 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) |
| 313 return; | 307 return; |
| 314 | 308 |
| 315 if (FLAG_trace_gc_nvp) { | 309 if (FLAG_trace_gc_nvp) { |
| 316 PrintNVP(); | 310 PrintNVP(); |
| 317 } else { | 311 } else { |
| 318 Print(); | 312 Print(); |
| 319 } | 313 } |
| 320 | 314 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 381 |
| 388 | 382 |
| 389 void GCTracer::AddSurvivalRatio(double promotion_ratio) { | 383 void GCTracer::AddSurvivalRatio(double promotion_ratio) { |
| 390 recorded_survival_ratios_.Push(promotion_ratio); | 384 recorded_survival_ratios_.Push(promotion_ratio); |
| 391 } | 385 } |
| 392 | 386 |
| 393 | 387 |
| 394 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { | 388 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { |
| 395 cumulative_incremental_marking_bytes_ += bytes; | 389 cumulative_incremental_marking_bytes_ += bytes; |
| 396 cumulative_incremental_marking_duration_ += duration; | 390 cumulative_incremental_marking_duration_ += duration; |
| 397 cumulative_marking_duration_ += duration; | |
| 398 if (bytes > 0) { | 391 if (bytes > 0) { |
| 399 cumulative_pure_incremental_marking_duration_ += duration; | 392 cumulative_pure_incremental_marking_duration_ += duration; |
| 400 } | 393 } |
| 401 } | 394 } |
| 402 | 395 |
| 403 void GCTracer::Output(const char* format, ...) const { | 396 void GCTracer::Output(const char* format, ...) const { |
| 404 if (FLAG_trace_gc) { | 397 if (FLAG_trace_gc) { |
| 405 va_list arguments; | 398 va_list arguments; |
| 406 va_start(arguments, format); | 399 va_start(arguments, format); |
| 407 base::OS::VPrint(format, arguments); | 400 base::OS::VPrint(format, arguments); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 827 } |
| 835 | 828 |
| 836 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } | 829 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } |
| 837 | 830 |
| 838 void GCTracer::NotifyIncrementalMarkingStart() { | 831 void GCTracer::NotifyIncrementalMarkingStart() { |
| 839 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); | 832 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); |
| 840 } | 833 } |
| 841 | 834 |
| 842 } // namespace internal | 835 } // namespace internal |
| 843 } // namespace v8 | 836 } // namespace v8 |
| OLD | NEW |