| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/gc-tracer.h" | 7 #include "src/gc-tracer.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 incremental_marking_duration_(0.0), | 71 incremental_marking_duration_(0.0), |
| 72 longest_incremental_marking_step_(0.0) { | 72 longest_incremental_marking_step_(0.0) { |
| 73 current_ = Event(Event::START, NULL, NULL); | 73 current_ = Event(Event::START, NULL, NULL); |
| 74 current_.end_time = base::OS::TimeCurrentMillis(); | 74 current_.end_time = base::OS::TimeCurrentMillis(); |
| 75 previous_ = previous_mark_compactor_event_ = current_; | 75 previous_ = previous_mark_compactor_event_ = current_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, | 79 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, |
| 80 const char* collector_reason) { | 80 const char* collector_reason) { |
| 81 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; | |
| 82 | |
| 83 previous_ = current_; | 81 previous_ = current_; |
| 84 if (current_.type == Event::MARK_COMPACTOR) | 82 if (current_.type == Event::MARK_COMPACTOR) |
| 85 previous_mark_compactor_event_ = current_; | 83 previous_mark_compactor_event_ = current_; |
| 86 | 84 |
| 87 if (collector == SCAVENGER) { | 85 if (collector == SCAVENGER) { |
| 88 current_ = Event(Event::SCAVENGER, gc_reason, collector_reason); | 86 current_ = Event(Event::SCAVENGER, gc_reason, collector_reason); |
| 89 } else { | 87 } else { |
| 90 current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason); | 88 current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason); |
| 91 } | 89 } |
| 92 | 90 |
| 93 current_.start_time = base::OS::TimeCurrentMillis(); | 91 current_.start_time = base::OS::TimeCurrentMillis(); |
| 94 current_.start_object_size = heap_->SizeOfObjects(); | 92 current_.start_object_size = heap_->SizeOfObjects(); |
| 95 current_.start_memory_size = heap_->isolate()->memory_allocator()->Size(); | 93 current_.start_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 96 current_.start_holes_size = CountTotalHolesSize(heap_); | 94 current_.start_holes_size = CountTotalHolesSize(heap_); |
| 97 | 95 |
| 98 current_.incremental_marking_steps = incremental_marking_steps_; | 96 current_.incremental_marking_steps = incremental_marking_steps_; |
| 99 current_.incremental_marking_duration = incremental_marking_duration_; | 97 current_.incremental_marking_duration = incremental_marking_duration_; |
| 100 current_.longest_incremental_marking_step = longest_incremental_marking_step_; | 98 current_.longest_incremental_marking_step = longest_incremental_marking_step_; |
| 101 | 99 |
| 102 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 100 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 103 current_.scopes[i] = 0; | 101 current_.scopes[i] = 0; |
| 104 } | 102 } |
| 105 } | 103 } |
| 106 | 104 |
| 107 | 105 |
| 108 void GCTracer::Stop() { | 106 void GCTracer::Stop() { |
| 109 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; | |
| 110 | |
| 111 current_.end_time = base::OS::TimeCurrentMillis(); | 107 current_.end_time = base::OS::TimeCurrentMillis(); |
| 112 current_.end_object_size = heap_->SizeOfObjects(); | 108 current_.end_object_size = heap_->SizeOfObjects(); |
| 113 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); | 109 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 114 current_.end_holes_size = CountTotalHolesSize(heap_); | 110 current_.end_holes_size = CountTotalHolesSize(heap_); |
| 115 | 111 |
| 116 if (current_.type == Event::SCAVENGER) { | 112 if (current_.type == Event::SCAVENGER) { |
| 117 scavenger_events_.push_front(current_); | 113 scavenger_events_.push_front(current_); |
| 118 } else { | 114 } else { |
| 119 mark_compactor_events_.push_front(current_); | 115 mark_compactor_events_.push_front(current_); |
| 120 } | 116 } |
| 121 | 117 |
| 122 if (current_.type == Event::MARK_COMPACTOR) | 118 if (current_.type == Event::MARK_COMPACTOR) |
| 123 longest_incremental_marking_step_ = 0.0; | 119 longest_incremental_marking_step_ = 0.0; |
| 124 | 120 |
| 121 // TODO(ernstm): move the code below out of GCTracer. |
| 122 |
| 123 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| 124 |
| 125 double duration = current_.end_time - current_.start_time; | 125 double duration = current_.end_time - current_.start_time; |
| 126 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); | 126 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); |
| 127 | 127 |
| 128 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator, | 128 heap_->UpdateCumulativeGCStatistics(duration, spent_in_mutator, |
| 129 current_.scopes[Scope::MC_MARK]); | 129 current_.scopes[Scope::MC_MARK]); |
| 130 | 130 |
| 131 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) | 131 if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (FLAG_trace_gc) { | 134 if (FLAG_trace_gc) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 | 309 |
| 310 double GCTracer::MaxIncrementalMarkingDuration() const { | 310 double GCTracer::MaxIncrementalMarkingDuration() const { |
| 311 if (mark_compactor_events_.empty()) return 0.0; | 311 if (mark_compactor_events_.empty()) return 0.0; |
| 312 | 312 |
| 313 EventBuffer::const_iterator last_mc = mark_compactor_events_.begin(); | 313 EventBuffer::const_iterator last_mc = mark_compactor_events_.begin(); |
| 314 return last_mc->longest_incremental_marking_step; | 314 return last_mc->longest_incremental_marking_step; |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 } // namespace v8::internal | 317 } // namespace v8::internal |
| OLD | NEW |