| 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) |
| 25 : tracer_(tracer), scope_(scope) { |
| 26 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); |
| 27 } |
| 28 |
| 29 |
| 30 GCTracer::Scope::~Scope() { |
| 31 DCHECK(scope_ < NUMBER_OF_SCOPES); // scope_ is unsigned. |
| 32 tracer_->current_.scopes[scope_] += |
| 33 tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_; |
| 34 } |
| 35 |
| 36 |
| 24 GCTracer::AllocationEvent::AllocationEvent(double duration, | 37 GCTracer::AllocationEvent::AllocationEvent(double duration, |
| 25 size_t allocation_in_bytes) { | 38 size_t allocation_in_bytes) { |
| 26 duration_ = duration; | 39 duration_ = duration; |
| 27 allocation_in_bytes_ = allocation_in_bytes; | 40 allocation_in_bytes_ = allocation_in_bytes; |
| 28 } | 41 } |
| 29 | 42 |
| 30 | 43 |
| 31 GCTracer::ContextDisposalEvent::ContextDisposalEvent(double time) { | 44 GCTracer::ContextDisposalEvent::ContextDisposalEvent(double time) { |
| 32 time_ = time; | 45 time_ = time; |
| 33 } | 46 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 cumulative_sweeping_duration_(0.0), | 117 cumulative_sweeping_duration_(0.0), |
| 105 allocation_time_ms_(0.0), | 118 allocation_time_ms_(0.0), |
| 106 new_space_allocation_counter_bytes_(0), | 119 new_space_allocation_counter_bytes_(0), |
| 107 old_generation_allocation_counter_bytes_(0), | 120 old_generation_allocation_counter_bytes_(0), |
| 108 allocation_duration_since_gc_(0.0), | 121 allocation_duration_since_gc_(0.0), |
| 109 new_space_allocation_in_bytes_since_gc_(0), | 122 new_space_allocation_in_bytes_since_gc_(0), |
| 110 old_generation_allocation_in_bytes_since_gc_(0), | 123 old_generation_allocation_in_bytes_since_gc_(0), |
| 111 combined_mark_compact_speed_cache_(0.0), | 124 combined_mark_compact_speed_cache_(0.0), |
| 112 start_counter_(0) { | 125 start_counter_(0) { |
| 113 current_ = Event(Event::START, NULL, NULL); | 126 current_ = Event(Event::START, NULL, NULL); |
| 114 current_.end_time = base::OS::TimeCurrentMillis(); | 127 current_.end_time = heap_->MonotonicallyIncreasingTimeInMs(); |
| 115 previous_ = previous_incremental_mark_compactor_event_ = current_; | 128 previous_ = previous_incremental_mark_compactor_event_ = current_; |
| 116 } | 129 } |
| 117 | 130 |
| 118 | 131 |
| 119 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, | 132 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, |
| 120 const char* collector_reason) { | 133 const char* collector_reason) { |
| 121 start_counter_++; | 134 start_counter_++; |
| 122 if (start_counter_ != 1) return; | 135 if (start_counter_ != 1) return; |
| 123 | 136 |
| 124 previous_ = current_; | 137 previous_ = current_; |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 size_t GCTracer::CurrentOldGenerationAllocationThroughputInBytesPerMillisecond() | 857 size_t GCTracer::CurrentOldGenerationAllocationThroughputInBytesPerMillisecond() |
| 845 const { | 858 const { |
| 846 return OldGenerationAllocationThroughputInBytesPerMillisecond( | 859 return OldGenerationAllocationThroughputInBytesPerMillisecond( |
| 847 kThroughputTimeFrameMs); | 860 kThroughputTimeFrameMs); |
| 848 } | 861 } |
| 849 | 862 |
| 850 | 863 |
| 851 double GCTracer::ContextDisposalRateInMilliseconds() const { | 864 double GCTracer::ContextDisposalRateInMilliseconds() const { |
| 852 if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0; | 865 if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0; |
| 853 | 866 |
| 854 double begin = base::OS::TimeCurrentMillis(); | 867 double begin = heap_->MonotonicallyIncreasingTimeInMs(); |
| 855 double end = 0.0; | 868 double end = 0.0; |
| 856 ContextDisposalEventBuffer::const_iterator iter = | 869 ContextDisposalEventBuffer::const_iterator iter = |
| 857 context_disposal_events_.begin(); | 870 context_disposal_events_.begin(); |
| 858 while (iter != context_disposal_events_.end()) { | 871 while (iter != context_disposal_events_.end()) { |
| 859 end = iter->time_; | 872 end = iter->time_; |
| 860 ++iter; | 873 ++iter; |
| 861 } | 874 } |
| 862 | 875 |
| 863 return (begin - end) / context_disposal_events_.size(); | 876 return (begin - end) / context_disposal_events_.size(); |
| 864 } | 877 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 879 | 892 |
| 880 | 893 |
| 881 bool GCTracer::SurvivalEventsRecorded() const { | 894 bool GCTracer::SurvivalEventsRecorded() const { |
| 882 return survival_events_.size() > 0; | 895 return survival_events_.size() > 0; |
| 883 } | 896 } |
| 884 | 897 |
| 885 | 898 |
| 886 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } | 899 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } |
| 887 } // namespace internal | 900 } // namespace internal |
| 888 } // namespace v8 | 901 } // namespace v8 |
| OLD | NEW |