| 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/heap/gc-tracer.h" | 7 #include "src/heap/gc-tracer.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 previous_ = previous_incremental_mark_compactor_event_ = current_; | 106 previous_ = previous_incremental_mark_compactor_event_ = current_; |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, | 110 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, |
| 111 const char* collector_reason) { | 111 const char* collector_reason) { |
| 112 start_counter_++; | 112 start_counter_++; |
| 113 if (start_counter_ != 1) return; | 113 if (start_counter_ != 1) return; |
| 114 | 114 |
| 115 previous_ = current_; | 115 previous_ = current_; |
| 116 double start_time = base::OS::TimeCurrentMillis(); | 116 double start_time = heap_->MonotonicallyIncreasingTimeInMs(); |
| 117 if (new_space_top_after_gc_ != 0) { | 117 if (new_space_top_after_gc_ != 0) { |
| 118 AddNewSpaceAllocationTime( | 118 AddNewSpaceAllocationTime( |
| 119 start_time - previous_.end_time, | 119 start_time - previous_.end_time, |
| 120 reinterpret_cast<intptr_t>((heap_->new_space()->top()) - | 120 reinterpret_cast<intptr_t>((heap_->new_space()->top()) - |
| 121 new_space_top_after_gc_)); | 121 new_space_top_after_gc_)); |
| 122 } | 122 } |
| 123 if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) | 123 if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) |
| 124 previous_incremental_mark_compactor_event_ = current_; | 124 previous_incremental_mark_compactor_event_ = current_; |
| 125 | 125 |
| 126 if (collector == SCAVENGER) { | 126 if (collector == SCAVENGER) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 147 cumulative_incremental_marking_bytes_; | 147 cumulative_incremental_marking_bytes_; |
| 148 current_.cumulative_incremental_marking_duration = | 148 current_.cumulative_incremental_marking_duration = |
| 149 cumulative_incremental_marking_duration_; | 149 cumulative_incremental_marking_duration_; |
| 150 current_.cumulative_pure_incremental_marking_duration = | 150 current_.cumulative_pure_incremental_marking_duration = |
| 151 cumulative_pure_incremental_marking_duration_; | 151 cumulative_pure_incremental_marking_duration_; |
| 152 current_.longest_incremental_marking_step = longest_incremental_marking_step_; | 152 current_.longest_incremental_marking_step = longest_incremental_marking_step_; |
| 153 | 153 |
| 154 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 154 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 155 current_.scopes[i] = 0; | 155 current_.scopes[i] = 0; |
| 156 } | 156 } |
| 157 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); |
| 158 int used_memory = static_cast<int>(current_.start_object_size / KB); |
| 159 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
| 160 start_time, committed_memory); |
| 161 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
| 162 start_time, used_memory); |
| 157 } | 163 } |
| 158 | 164 |
| 159 | 165 |
| 160 void GCTracer::Stop(GarbageCollector collector) { | 166 void GCTracer::Stop(GarbageCollector collector) { |
| 161 start_counter_--; | 167 start_counter_--; |
| 162 if (start_counter_ != 0) { | 168 if (start_counter_ != 0) { |
| 163 if (FLAG_trace_gc) { | 169 if (FLAG_trace_gc) { |
| 164 PrintF("[Finished reentrant %s during %s.]\n", | 170 PrintF("[Finished reentrant %s during %s.]\n", |
| 165 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", | 171 collector == SCAVENGER ? "Scavenge" : "Mark-sweep", |
| 166 current_.TypeName(false)); | 172 current_.TypeName(false)); |
| 167 } | 173 } |
| 168 return; | 174 return; |
| 169 } | 175 } |
| 170 | 176 |
| 171 DCHECK(start_counter_ >= 0); | 177 DCHECK(start_counter_ >= 0); |
| 172 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) || | 178 DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) || |
| 173 (collector == MARK_COMPACTOR && | 179 (collector == MARK_COMPACTOR && |
| 174 (current_.type == Event::MARK_COMPACTOR || | 180 (current_.type == Event::MARK_COMPACTOR || |
| 175 current_.type == Event::INCREMENTAL_MARK_COMPACTOR))); | 181 current_.type == Event::INCREMENTAL_MARK_COMPACTOR))); |
| 176 | 182 |
| 177 current_.end_time = base::OS::TimeCurrentMillis(); | 183 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); |
| 178 current_.end_object_size = heap_->SizeOfObjects(); | 184 current_.end_object_size = heap_->SizeOfObjects(); |
| 179 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); | 185 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 180 current_.end_holes_size = CountTotalHolesSize(heap_); | 186 current_.end_holes_size = CountTotalHolesSize(heap_); |
| 181 new_space_top_after_gc_ = | 187 new_space_top_after_gc_ = |
| 182 reinterpret_cast<intptr_t>(heap_->new_space()->top()); | 188 reinterpret_cast<intptr_t>(heap_->new_space()->top()); |
| 183 | 189 |
| 190 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); |
| 191 int used_memory = static_cast<int>(current_.end_object_size / KB); |
| 192 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
| 193 current_.end_time, committed_memory); |
| 194 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
| 195 current_.end_time, used_memory); |
| 196 |
| 184 if (current_.type == Event::SCAVENGER) { | 197 if (current_.type == Event::SCAVENGER) { |
| 185 current_.incremental_marking_steps = | 198 current_.incremental_marking_steps = |
| 186 current_.cumulative_incremental_marking_steps - | 199 current_.cumulative_incremental_marking_steps - |
| 187 previous_.cumulative_incremental_marking_steps; | 200 previous_.cumulative_incremental_marking_steps; |
| 188 current_.incremental_marking_bytes = | 201 current_.incremental_marking_bytes = |
| 189 current_.cumulative_incremental_marking_bytes - | 202 current_.cumulative_incremental_marking_bytes - |
| 190 previous_.cumulative_incremental_marking_bytes; | 203 previous_.cumulative_incremental_marking_bytes; |
| 191 current_.incremental_marking_duration = | 204 current_.incremental_marking_duration = |
| 192 current_.cumulative_incremental_marking_duration - | 205 current_.cumulative_incremental_marking_duration - |
| 193 previous_.cumulative_incremental_marking_duration; | 206 previous_.cumulative_incremental_marking_duration; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 602 |
| 590 | 603 |
| 591 bool GCTracer::SurvivalEventsRecorded() const { | 604 bool GCTracer::SurvivalEventsRecorded() const { |
| 592 return survival_events_.size() > 0; | 605 return survival_events_.size() > 0; |
| 593 } | 606 } |
| 594 | 607 |
| 595 | 608 |
| 596 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } | 609 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } |
| 597 } | 610 } |
| 598 } // namespace v8::internal | 611 } // namespace v8::internal |
| OLD | NEW |