Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/once.h" | 9 #include "src/base/once.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 semi_space_copied_object_size_(0), | 106 semi_space_copied_object_size_(0), |
| 107 semi_space_copied_rate_(0), | 107 semi_space_copied_rate_(0), |
| 108 nodes_died_in_new_space_(0), | 108 nodes_died_in_new_space_(0), |
| 109 nodes_copied_in_new_space_(0), | 109 nodes_copied_in_new_space_(0), |
| 110 nodes_promoted_(0), | 110 nodes_promoted_(0), |
| 111 maximum_size_scavenges_(0), | 111 maximum_size_scavenges_(0), |
| 112 max_gc_pause_(0.0), | 112 max_gc_pause_(0.0), |
| 113 total_gc_time_ms_(0.0), | 113 total_gc_time_ms_(0.0), |
| 114 max_alive_after_gc_(0), | 114 max_alive_after_gc_(0), |
| 115 min_in_mutator_(kMaxInt), | 115 min_in_mutator_(kMaxInt), |
| 116 alive_after_last_gc_(0), | |
| 117 last_gc_end_timestamp_(base::OS::TimeCurrentMillis()), | |
| 118 marking_time_(0.0), | 116 marking_time_(0.0), |
| 119 sweeping_time_(0.0), | 117 sweeping_time_(0.0), |
| 120 mark_compact_collector_(this), | 118 mark_compact_collector_(this), |
| 121 store_buffer_(this), | 119 store_buffer_(this), |
| 122 marking_(this), | 120 marking_(this), |
| 123 incremental_marking_(this), | 121 incremental_marking_(this), |
| 124 number_idle_notifications_(0), | 122 number_idle_notifications_(0), |
| 125 last_idle_notification_gc_count_(0), | 123 last_idle_notification_gc_count_(0), |
| 126 last_idle_notification_gc_count_init_(false), | 124 last_idle_notification_gc_count_init_(false), |
| 127 mark_sweeps_since_idle_round_started_(0), | 125 mark_sweeps_since_idle_round_started_(0), |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 if (FLAG_trace_incremental_marking) { | 831 if (FLAG_trace_incremental_marking) { |
| 834 PrintF("[IncrementalMarking] Delaying MarkSweep.\n"); | 832 PrintF("[IncrementalMarking] Delaying MarkSweep.\n"); |
| 835 } | 833 } |
| 836 collector = SCAVENGER; | 834 collector = SCAVENGER; |
| 837 collector_reason = "incremental marking delaying mark-sweep"; | 835 collector_reason = "incremental marking delaying mark-sweep"; |
| 838 } | 836 } |
| 839 } | 837 } |
| 840 | 838 |
| 841 bool next_gc_likely_to_collect_more = false; | 839 bool next_gc_likely_to_collect_more = false; |
| 842 | 840 |
| 843 { tracer()->start(collector, gc_reason, collector_reason); | 841 { tracer()->Start(collector, gc_reason, collector_reason); |
| 844 ASSERT(AllowHeapAllocation::IsAllowed()); | 842 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 845 DisallowHeapAllocation no_allocation_during_gc; | 843 DisallowHeapAllocation no_allocation_during_gc; |
| 846 GarbageCollectionPrologue(); | 844 GarbageCollectionPrologue(); |
| 847 | 845 |
| 848 { | 846 { |
| 849 HistogramTimerScope histogram_timer_scope( | 847 HistogramTimerScope histogram_timer_scope( |
| 850 (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() | 848 (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() |
| 851 : isolate_->counters()->gc_compactor()); | 849 : isolate_->counters()->gc_compactor()); |
| 852 next_gc_likely_to_collect_more = | 850 next_gc_likely_to_collect_more = |
| 853 PerformGarbageCollection(collector, gc_callback_flags); | 851 PerformGarbageCollection(collector, gc_callback_flags); |
| 854 } | 852 } |
| 855 | 853 |
| 856 GarbageCollectionEpilogue(); | 854 GarbageCollectionEpilogue(); |
| 857 tracer()->stop(); | 855 tracer()->Stop(); |
| 858 } | 856 } |
| 859 | 857 |
| 860 // Start incremental marking for the next cycle. The heap snapshot | 858 // Start incremental marking for the next cycle. The heap snapshot |
| 861 // generator needs incremental marking to stay off after it aborted. | 859 // generator needs incremental marking to stay off after it aborted. |
| 862 if (!mark_compact_collector()->abort_incremental_marking() && | 860 if (!mark_compact_collector()->abort_incremental_marking() && |
| 863 incremental_marking()->IsStopped() && | 861 incremental_marking()->IsStopped() && |
| 864 incremental_marking()->WorthActivating() && | 862 incremental_marking()->WorthActivating() && |
| 865 NextGCIsLikelyToBeFull()) { | 863 NextGCIsLikelyToBeFull()) { |
| 866 incremental_marking()->Start(); | 864 incremental_marking()->Start(); |
| 867 } | 865 } |
| (...skipping 5083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5951 OldSpaces spaces(heap); | 5949 OldSpaces spaces(heap); |
| 5952 for (OldSpace* space = spaces.next(); | 5950 for (OldSpace* space = spaces.next(); |
| 5953 space != NULL; | 5951 space != NULL; |
| 5954 space = spaces.next()) { | 5952 space = spaces.next()) { |
| 5955 holes_size += space->Waste() + space->Available(); | 5953 holes_size += space->Waste() + space->Available(); |
| 5956 } | 5954 } |
| 5957 return holes_size; | 5955 return holes_size; |
| 5958 } | 5956 } |
| 5959 | 5957 |
| 5960 | 5958 |
| 5961 void Heap::UpdateGCStatistics(double start_time, | 5959 void Heap::UpdateCumulativeGCStatistics(double duration, |
| 5962 double end_time, | 5960 double spent_in_mutator, |
| 5963 double spent_in_mutator, | 5961 double marking_time) { |
| 5964 double marking_time) { | |
| 5965 double duration = end_time - start_time; | |
| 5966 alive_after_last_gc_ = SizeOfObjects(); | |
| 5967 last_gc_end_timestamp_ = end_time; | |
| 5968 | |
| 5969 if (FLAG_print_cumulative_gc_stat) { | 5962 if (FLAG_print_cumulative_gc_stat) { |
| 5970 total_gc_time_ms_ += duration; | 5963 total_gc_time_ms_ += duration; |
| 5971 max_gc_pause_ = Max(max_gc_pause_, duration); | 5964 max_gc_pause_ = Max(max_gc_pause_, duration); |
| 5972 max_alive_after_gc_ = Max(max_alive_after_gc_, alive_after_last_gc_); | 5965 max_alive_after_gc_ = Max(max_alive_after_gc_, SizeOfObjects()); |
| 5973 min_in_mutator_ = Min(min_in_mutator_, spent_in_mutator); | 5966 min_in_mutator_ = Min(min_in_mutator_, spent_in_mutator); |
| 5974 } else if (FLAG_trace_gc_verbose) { | 5967 } else if (FLAG_trace_gc_verbose) { |
| 5975 total_gc_time_ms_ += duration; | 5968 total_gc_time_ms_ += duration; |
| 5976 } | 5969 } |
| 5977 | 5970 |
| 5978 marking_time_ += marking_time; | 5971 marking_time_ += marking_time; |
| 5979 } | 5972 } |
| 5980 | 5973 |
| 5974 GCTracer::Event::Event() | |
|
Hannes Payer (out of office)
2014/07/22 15:21:30
Why do we need the default constructor?
ernstm
2014/07/22 15:57:24
RingBuffer allocates an array of Events. The defau
Hannes Payer (out of office)
2014/07/22 16:29:12
Yes, I overlooked this one. Fine.
| |
| 5975 : type(Event::INVALID), | |
| 5976 gc_reason(NULL), | |
| 5977 collector_reason(NULL), | |
| 5978 start_time(0.0), | |
| 5979 end_time(0.0), | |
| 5980 start_object_size(0), | |
| 5981 end_object_size(0), | |
| 5982 start_memory_size(0), | |
| 5983 end_memory_size(0), | |
| 5984 start_holes_size(0), | |
| 5985 end_holes_size(0), | |
| 5986 incremental_marking_steps(0), | |
| 5987 incremental_marking_duration(0.0) { | |
| 5988 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | |
| 5989 scopes[i] = 0; | |
| 5990 } | |
| 5991 } | |
| 5992 | |
| 5993 GCTracer::Event::Event(Type type, | |
| 5994 const char* gc_reason, | |
| 5995 const char* collector_reason) | |
| 5996 : type(type), | |
| 5997 gc_reason(gc_reason), | |
| 5998 collector_reason(collector_reason), | |
| 5999 start_time(0.0), | |
| 6000 end_time(0.0), | |
| 6001 start_object_size(0), | |
| 6002 end_object_size(0), | |
| 6003 start_memory_size(0), | |
| 6004 end_memory_size(0), | |
| 6005 start_holes_size(0), | |
| 6006 end_holes_size(0), | |
| 6007 incremental_marking_steps(0), | |
| 6008 incremental_marking_duration(0.0) { | |
| 6009 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | |
| 6010 scopes[i] = 0; | |
| 6011 } | |
| 6012 } | |
| 6013 | |
| 6014 | |
| 6015 const char* GCTracer::Event::TypeName(bool short_name) const { | |
| 6016 switch (type) { | |
| 6017 case SCAVENGER: | |
| 6018 if (short_name) | |
| 6019 return "s"; | |
| 6020 else | |
| 6021 return "Scavenge"; | |
| 6022 case MARK_COMPACTOR: | |
| 6023 if (short_name) | |
| 6024 return "ms"; | |
| 6025 else | |
| 6026 return "Mark-sweep"; | |
| 6027 case ANCHOR: | |
| 6028 if (short_name) | |
| 6029 return "a"; | |
| 6030 else | |
| 6031 return "Anchor"; | |
| 6032 case INVALID: | |
| 6033 if (short_name) | |
| 6034 return "i"; | |
| 6035 else | |
| 6036 return "Invalid"; | |
| 6037 } | |
| 6038 return "Unknown Event Type"; | |
| 6039 } | |
| 6040 | |
| 5981 | 6041 |
| 5982 GCTracer::GCTracer(Heap* heap) | 6042 GCTracer::GCTracer(Heap* heap) |
| 5983 : start_time_(0.0), | 6043 : heap_(heap), |
| 5984 end_time_(0.0), | 6044 incremental_marking_steps_(0), |
| 5985 start_object_size_(0), | 6045 incremental_marking_duration_(0.0), |
| 5986 end_object_size_(0), | 6046 longest_incremental_marking_step_(0.0) { |
| 5987 start_memory_size_(0), | 6047 Event anchor_event(Event::ANCHOR, NULL, NULL); |
| 5988 end_memory_size_(0), | 6048 anchor_event.end_time = base::OS::TimeCurrentMillis(); |
| 5989 in_free_list_or_wasted_before_gc_(0), | 6049 scavenger_events_.push_back(anchor_event); |
| 5990 allocated_since_last_gc_(0), | 6050 mark_compactor_events_.push_back(anchor_event); |
| 5991 spent_in_mutator_(0), | 6051 } |
| 5992 steps_count_(0), | 6052 |
| 5993 steps_took_(0.0), | 6053 |
| 5994 longest_step_(0.0), | 6054 void GCTracer::Start(GarbageCollector collector, |
| 5995 steps_count_since_last_gc_(0), | 6055 const char* gc_reason, |
| 5996 steps_took_since_last_gc_(0.0), | 6056 const char* collector_reason) { |
| 5997 heap_(heap), | 6057 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| 5998 gc_reason_(NULL), | 6058 |
| 5999 collector_reason_(NULL) { | 6059 if (collector == SCAVENGER) |
|
Hannes Payer (out of office)
2014/07/22 15:21:30
coding style: if/else likes curly braces
ernstm
2014/07/22 15:57:24
Done.
| |
| 6060 pending_ = Event(Event::SCAVENGER, gc_reason, collector_reason); | |
| 6061 else | |
| 6062 pending_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason); | |
| 6063 | |
| 6064 pending_.start_time = base::OS::TimeCurrentMillis(); | |
| 6065 pending_.start_object_size = heap_->SizeOfObjects(); | |
| 6066 pending_.start_memory_size = heap_->isolate()->memory_allocator()->Size(); | |
| 6067 pending_.start_holes_size = CountTotalHolesSize(heap_); | |
| 6068 | |
| 6069 pending_.incremental_marking_steps = incremental_marking_steps_; | |
| 6070 pending_.incremental_marking_duration = incremental_marking_duration_; | |
| 6071 pending_.longest_incremental_marking_step = longest_incremental_marking_step_; | |
| 6072 | |
| 6000 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 6073 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 6001 scopes_[i] = 0; | 6074 pending_.scopes[i] = 0; |
| 6002 } | 6075 } |
| 6003 } | 6076 } |
| 6004 | 6077 |
| 6005 | 6078 |
| 6006 void GCTracer::start(GarbageCollector collector, | 6079 void GCTracer::Stop() { |
| 6007 const char* gc_reason, | |
| 6008 const char* collector_reason) { | |
| 6009 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; | 6080 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| 6010 | 6081 |
| 6011 collector_ = collector; | 6082 pending_.end_time = base::OS::TimeCurrentMillis(); |
| 6012 gc_reason_ = gc_reason; | 6083 pending_.end_object_size = heap_->SizeOfObjects(); |
| 6013 collector_reason_ = collector_reason; | 6084 pending_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 6085 pending_.end_holes_size = CountTotalHolesSize(heap_); | |
| 6014 | 6086 |
| 6015 start_time_ = base::OS::TimeCurrentMillis(); | 6087 if (pending_.type == Event::SCAVENGER) |
| 6016 start_object_size_ = heap_->SizeOfObjects(); | 6088 scavenger_events_.push_back(pending_); |
|
Hannes Payer (out of office)
2014/07/22 15:21:30
coding style: if/else likes curly braces
ernstm
2014/07/22 15:57:24
Done.
| |
| 6017 start_memory_size_ = heap_->isolate()->memory_allocator()->Size(); | 6089 else |
| 6090 mark_compactor_events_.push_back(pending_); | |
| 6018 | 6091 |
| 6019 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 6092 if (pending_.type == Event::MARK_COMPACTOR) |
| 6020 scopes_[i] = 0; | 6093 longest_incremental_marking_step_ = 0.0; |
| 6021 } | |
| 6022 | 6094 |
| 6023 in_free_list_or_wasted_before_gc_ = CountTotalHolesSize(heap_); | 6095 double duration = pending_.end_time - pending_.start_time; |
| 6096 double spent_in_mutator = | |
| 6097 Max(pending_.start_time - Previous()->end_time, 0.0); | |
| 6024 | 6098 |
| 6025 allocated_since_last_gc_ = | 6099 heap_->UpdateCumulativeGCStatistics(duration, |
| 6026 heap_->SizeOfObjects() - heap_->alive_after_last_gc_; | 6100 spent_in_mutator, |
| 6101 Current()->scopes[Scope::MC_MARK]); | |
| 6027 | 6102 |
| 6028 spent_in_mutator_ = Max(start_time_ - heap_->last_gc_end_timestamp_, 0.0); | 6103 if (Current()->type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) |
| 6029 | 6104 return; |
| 6030 steps_count_ = heap_->incremental_marking()->steps_count(); | |
| 6031 steps_took_ = heap_->incremental_marking()->steps_took(); | |
| 6032 longest_step_ = heap_->incremental_marking()->longest_step(); | |
| 6033 steps_count_since_last_gc_ = | |
| 6034 heap_->incremental_marking()->steps_count_since_last_gc(); | |
| 6035 steps_took_since_last_gc_ = | |
| 6036 heap_->incremental_marking()->steps_took_since_last_gc(); | |
| 6037 } | |
| 6038 | |
| 6039 | |
| 6040 void GCTracer::stop() { | |
| 6041 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; | |
| 6042 | |
| 6043 end_time_ = base::OS::TimeCurrentMillis(); | |
| 6044 end_object_size_ = heap_->SizeOfObjects(); | |
| 6045 end_memory_size_ = heap_->isolate()->memory_allocator()->Size(); | |
| 6046 | |
| 6047 heap_->UpdateGCStatistics(start_time_, | |
| 6048 end_time_, | |
| 6049 spent_in_mutator_, | |
| 6050 scopes_[Scope::MC_MARK]); | |
| 6051 | |
| 6052 if (collector_ == SCAVENGER && FLAG_trace_gc_ignore_scavenger) return; | |
| 6053 | 6105 |
| 6054 if (FLAG_trace_gc) { | 6106 if (FLAG_trace_gc) { |
| 6055 if (FLAG_trace_gc_nvp) | 6107 if (FLAG_trace_gc_nvp) |
| 6056 PrintNVP(); | 6108 PrintNVP(); |
| 6057 else | 6109 else |
| 6058 Print(); | 6110 Print(); |
| 6059 | 6111 |
| 6060 heap_->PrintShortHeapStatistics(); | 6112 heap_->PrintShortHeapStatistics(); |
| 6061 } | 6113 } |
| 6062 } | 6114 } |
| 6063 | 6115 |
| 6064 | 6116 |
| 6117 void GCTracer::AddIncrementalMarkingStep(double duration) { | |
| 6118 incremental_marking_steps_++; | |
| 6119 incremental_marking_duration_ += duration; | |
| 6120 longest_incremental_marking_step_ = | |
| 6121 Max(longest_incremental_marking_step_, duration); | |
| 6122 } | |
| 6123 | |
| 6124 | |
| 6125 GCTracer::EventBuffer::const_iterator GCTracer::Current() const { | |
| 6126 ASSERT(!scavenger_events_.empty() && | |
| 6127 !mark_compactor_events_.empty()); | |
| 6128 | |
| 6129 if (scavenger_events_.back()->end_time >= | |
| 6130 mark_compactor_events_.back()->end_time) | |
|
Hannes Payer (out of office)
2014/07/22 15:21:30
coding style: if/else likes curly braces
ernstm
2014/07/22 15:57:24
Done.
| |
| 6131 return scavenger_events_.back(); | |
| 6132 else | |
| 6133 return mark_compactor_events_.back(); | |
| 6134 } | |
| 6135 | |
| 6136 | |
| 6137 GCTracer::EventBuffer::const_iterator GCTracer::Previous() const { | |
| 6138 EventBuffer::const_iterator current = this->Current(); | |
| 6139 | |
| 6140 const EventBuffer& current_buffer = (current->type == Event::SCAVENGER) ? | |
| 6141 mark_compactor_events_ : scavenger_events_; | |
| 6142 | |
| 6143 const EventBuffer& other_buffer = (current->type == Event::SCAVENGER) ? | |
| 6144 mark_compactor_events_ : scavenger_events_; | |
| 6145 | |
| 6146 EventBuffer::const_iterator last_in_other_buffer = | |
| 6147 other_buffer.back(); | |
| 6148 | |
| 6149 // If we only have one event of the curren type, return the last event of the | |
| 6150 // other type. | |
| 6151 if (current == current_buffer.begin()) | |
| 6152 return last_in_other_buffer; | |
| 6153 | |
| 6154 EventBuffer::const_iterator previous_in_current_buffer = current; | |
| 6155 --previous_in_current_buffer; | |
| 6156 | |
| 6157 // If there is a more recent event in the other event buffer, return that one. | |
| 6158 if (last_in_other_buffer->end_time > previous_in_current_buffer->end_time) | |
| 6159 return last_in_other_buffer; | |
|
Hannes Payer (out of office)
2014/07/22 15:21:30
coding style: if/else likes curly braces
ernstm
2014/07/22 15:57:24
Done.
| |
| 6160 else | |
| 6161 return previous_in_current_buffer; | |
| 6162 } | |
| 6163 | |
| 6164 | |
| 6065 void GCTracer::Print() const { | 6165 void GCTracer::Print() const { |
| 6166 EventBuffer::const_iterator current = Current(); | |
| 6167 EventBuffer::const_iterator previous = Previous(); | |
| 6168 | |
| 6066 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); | 6169 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); |
| 6067 | 6170 |
| 6068 PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", | 6171 PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", |
| 6069 CollectorString(), | 6172 current->TypeName(false), |
| 6070 static_cast<double>(start_object_size_) / MB, | 6173 static_cast<double>(current->start_object_size) / MB, |
| 6071 static_cast<double>(start_memory_size_) / MB, | 6174 static_cast<double>(current->start_memory_size) / MB, |
| 6072 static_cast<double>(end_object_size_) / MB, | 6175 static_cast<double>(current->end_object_size) / MB, |
| 6073 static_cast<double>(end_memory_size_) / MB); | 6176 static_cast<double>(current->end_memory_size) / MB); |
| 6074 | 6177 |
| 6075 int external_time = static_cast<int>(scopes_[Scope::EXTERNAL]); | 6178 int external_time = static_cast<int>(current->scopes[Scope::EXTERNAL]); |
| 6076 if (external_time > 0) PrintF("%d / ", external_time); | 6179 if (external_time > 0) PrintF("%d / ", external_time); |
| 6077 | 6180 |
| 6078 PrintF("%.1f ms", end_time_ - start_time_); | 6181 double duration = current->end_time - current->start_time; |
| 6079 if (steps_count_ > 0) { | 6182 PrintF("%.1f ms", duration); |
| 6080 if (collector_ == SCAVENGER) { | 6183 if (current->type == Event::SCAVENGER) { |
| 6184 int steps = current->incremental_marking_steps - | |
| 6185 previous->incremental_marking_steps; | |
| 6186 if (steps > 0) { | |
| 6081 PrintF(" (+ %.1f ms in %d steps since last GC)", | 6187 PrintF(" (+ %.1f ms in %d steps since last GC)", |
| 6082 steps_took_since_last_gc_, | 6188 current->incremental_marking_duration - |
| 6083 steps_count_since_last_gc_); | 6189 previous->incremental_marking_duration, |
| 6084 } else { | 6190 steps); |
| 6191 } | |
| 6192 } else { | |
| 6193 EventBuffer::const_iterator previous_mark_compactor = current; | |
| 6194 --previous_mark_compactor; | |
| 6195 int steps = current->incremental_marking_steps - | |
| 6196 previous_mark_compactor->incremental_marking_steps; | |
| 6197 if (steps > 0) { | |
| 6085 PrintF(" (+ %.1f ms in %d steps since start of marking, " | 6198 PrintF(" (+ %.1f ms in %d steps since start of marking, " |
| 6086 "biggest step %.1f ms)", | 6199 "biggest step %.1f ms)", |
| 6087 steps_took_, | 6200 current->incremental_marking_duration - |
| 6088 steps_count_, | 6201 previous_mark_compactor->incremental_marking_duration, |
| 6089 longest_step_); | 6202 steps, |
| 6203 current->longest_incremental_marking_step); | |
| 6090 } | 6204 } |
| 6091 } | 6205 } |
| 6092 | 6206 |
| 6093 if (gc_reason_ != NULL) { | 6207 if (current->gc_reason != NULL) { |
| 6094 PrintF(" [%s]", gc_reason_); | 6208 PrintF(" [%s]", current->gc_reason); |
| 6095 } | 6209 } |
| 6096 | 6210 |
| 6097 if (collector_reason_ != NULL) { | 6211 if (current->collector_reason != NULL) { |
| 6098 PrintF(" [%s]", collector_reason_); | 6212 PrintF(" [%s]", current->collector_reason); |
| 6099 } | 6213 } |
| 6100 | 6214 |
| 6101 PrintF(".\n"); | 6215 PrintF(".\n"); |
| 6102 } | 6216 } |
| 6103 | 6217 |
| 6104 | 6218 |
| 6105 void GCTracer::PrintNVP() const { | 6219 void GCTracer::PrintNVP() const { |
| 6220 EventBuffer::const_iterator current = Current(); | |
| 6221 EventBuffer::const_iterator previous = Previous(); | |
| 6222 | |
| 6106 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); | 6223 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); |
| 6107 | 6224 |
| 6108 PrintF("pause=%.1f ", end_time_ - start_time_); | 6225 double duration = current->end_time - current->start_time; |
| 6109 PrintF("mutator=%.1f ", spent_in_mutator_); | 6226 double spent_in_mutator = current->start_time - previous->end_time; |
| 6110 PrintF("gc="); | |
| 6111 switch (collector_) { | |
| 6112 case SCAVENGER: | |
| 6113 PrintF("s"); | |
| 6114 break; | |
| 6115 case MARK_COMPACTOR: | |
| 6116 PrintF("ms"); | |
| 6117 break; | |
| 6118 default: | |
| 6119 UNREACHABLE(); | |
| 6120 } | |
| 6121 PrintF(" "); | |
| 6122 | 6227 |
| 6123 PrintF("external=%.1f ", scopes_[Scope::EXTERNAL]); | 6228 PrintF("pause=%.1f ", duration); |
| 6124 PrintF("mark=%.1f ", scopes_[Scope::MC_MARK]); | 6229 PrintF("mutator=%.1f ", spent_in_mutator); |
| 6125 PrintF("sweep=%.2f ", scopes_[Scope::MC_SWEEP]); | 6230 PrintF("gc=%s ", current->TypeName(true)); |
| 6126 PrintF("sweepns=%.2f ", scopes_[Scope::MC_SWEEP_NEWSPACE]); | 6231 |
| 6127 PrintF("sweepos=%.2f ", scopes_[Scope::MC_SWEEP_OLDSPACE]); | 6232 PrintF("external=%.1f ", current->scopes[Scope::EXTERNAL]); |
| 6128 PrintF("sweepcode=%.2f ", scopes_[Scope::MC_SWEEP_CODE]); | 6233 PrintF("mark=%.1f ", current->scopes[Scope::MC_MARK]); |
| 6129 PrintF("sweepcell=%.2f ", scopes_[Scope::MC_SWEEP_CELL]); | 6234 PrintF("sweep=%.2f ", current->scopes[Scope::MC_SWEEP]); |
| 6130 PrintF("sweepmap=%.2f ", scopes_[Scope::MC_SWEEP_MAP]); | 6235 PrintF("sweepns=%.2f ", current->scopes[Scope::MC_SWEEP_NEWSPACE]); |
| 6131 PrintF("evacuate=%.1f ", scopes_[Scope::MC_EVACUATE_PAGES]); | 6236 PrintF("sweepos=%.2f ", current->scopes[Scope::MC_SWEEP_OLDSPACE]); |
| 6132 PrintF("new_new=%.1f ", scopes_[Scope::MC_UPDATE_NEW_TO_NEW_POINTERS]); | 6237 PrintF("sweepcode=%.2f ", current->scopes[Scope::MC_SWEEP_CODE]); |
| 6133 PrintF("root_new=%.1f ", scopes_[Scope::MC_UPDATE_ROOT_TO_NEW_POINTERS]); | 6238 PrintF("sweepcell=%.2f ", current->scopes[Scope::MC_SWEEP_CELL]); |
| 6134 PrintF("old_new=%.1f ", scopes_[Scope::MC_UPDATE_OLD_TO_NEW_POINTERS]); | 6239 PrintF("sweepmap=%.2f ", current->scopes[Scope::MC_SWEEP_MAP]); |
| 6240 PrintF("evacuate=%.1f ", current->scopes[Scope::MC_EVACUATE_PAGES]); | |
| 6241 PrintF("new_new=%.1f ", | |
| 6242 current->scopes[Scope::MC_UPDATE_NEW_TO_NEW_POINTERS]); | |
| 6243 PrintF("root_new=%.1f ", | |
| 6244 current->scopes[Scope::MC_UPDATE_ROOT_TO_NEW_POINTERS]); | |
| 6245 PrintF("old_new=%.1f ", | |
| 6246 current->scopes[Scope::MC_UPDATE_OLD_TO_NEW_POINTERS]); | |
| 6135 PrintF("compaction_ptrs=%.1f ", | 6247 PrintF("compaction_ptrs=%.1f ", |
| 6136 scopes_[Scope::MC_UPDATE_POINTERS_TO_EVACUATED]); | 6248 current->scopes[Scope::MC_UPDATE_POINTERS_TO_EVACUATED]); |
| 6137 PrintF("intracompaction_ptrs=%.1f ", | 6249 PrintF("intracompaction_ptrs=%.1f ", |
| 6138 scopes_[Scope::MC_UPDATE_POINTERS_BETWEEN_EVACUATED]); | 6250 current->scopes[Scope::MC_UPDATE_POINTERS_BETWEEN_EVACUATED]); |
| 6139 PrintF("misc_compaction=%.1f ", scopes_[Scope::MC_UPDATE_MISC_POINTERS]); | 6251 PrintF("misc_compaction=%.1f ", |
| 6252 current->scopes[Scope::MC_UPDATE_MISC_POINTERS]); | |
| 6140 PrintF("weakcollection_process=%.1f ", | 6253 PrintF("weakcollection_process=%.1f ", |
| 6141 scopes_[Scope::MC_WEAKCOLLECTION_PROCESS]); | 6254 current->scopes[Scope::MC_WEAKCOLLECTION_PROCESS]); |
| 6142 PrintF("weakcollection_clear=%.1f ", | 6255 PrintF("weakcollection_clear=%.1f ", |
| 6143 scopes_[Scope::MC_WEAKCOLLECTION_CLEAR]); | 6256 current->scopes[Scope::MC_WEAKCOLLECTION_CLEAR]); |
| 6144 | 6257 |
| 6145 PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_object_size_); | 6258 PrintF("total_size_before=%" V8_PTR_PREFIX "d ", current->start_object_size); |
| 6146 PrintF("total_size_after=%" V8_PTR_PREFIX "d ", end_object_size_); | 6259 PrintF("total_size_after=%" V8_PTR_PREFIX "d ", current->end_object_size); |
| 6147 PrintF("holes_size_before=%" V8_PTR_PREFIX "d ", | 6260 PrintF("holes_size_before=%" V8_PTR_PREFIX "d ", current->start_holes_size); |
| 6148 in_free_list_or_wasted_before_gc_); | 6261 PrintF("holes_size_after=%" V8_PTR_PREFIX "d ", current->end_holes_size); |
| 6149 PrintF("holes_size_after=%" V8_PTR_PREFIX "d ", CountTotalHolesSize(heap_)); | |
| 6150 | 6262 |
| 6151 PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_); | 6263 intptr_t allocated_since_last_gc = |
| 6264 current->start_object_size - previous->end_object_size; | |
| 6265 PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc); | |
| 6152 PrintF("promoted=%" V8_PTR_PREFIX "d ", heap_->promoted_objects_size_); | 6266 PrintF("promoted=%" V8_PTR_PREFIX "d ", heap_->promoted_objects_size_); |
| 6153 PrintF("semi_space_copied=%" V8_PTR_PREFIX "d ", | 6267 PrintF("semi_space_copied=%" V8_PTR_PREFIX "d ", |
| 6154 heap_->semi_space_copied_object_size_); | 6268 heap_->semi_space_copied_object_size_); |
| 6155 PrintF("nodes_died_in_new=%d ", heap_->nodes_died_in_new_space_); | 6269 PrintF("nodes_died_in_new=%d ", heap_->nodes_died_in_new_space_); |
| 6156 PrintF("nodes_copied_in_new=%d ", heap_->nodes_copied_in_new_space_); | 6270 PrintF("nodes_copied_in_new=%d ", heap_->nodes_copied_in_new_space_); |
| 6157 PrintF("nodes_promoted=%d ", heap_->nodes_promoted_); | 6271 PrintF("nodes_promoted=%d ", heap_->nodes_promoted_); |
| 6158 PrintF("promotion_rate=%.1f%% ", heap_->promotion_rate_); | 6272 PrintF("promotion_rate=%.1f%% ", heap_->promotion_rate_); |
| 6159 PrintF("semi_space_copy_rate=%.1f%% ", heap_->semi_space_copied_rate_); | 6273 PrintF("semi_space_copy_rate=%.1f%% ", heap_->semi_space_copied_rate_); |
| 6160 | 6274 |
| 6161 if (collector_ == SCAVENGER) { | 6275 if (current->type == Event::SCAVENGER) { |
| 6162 PrintF("stepscount=%d ", steps_count_since_last_gc_); | 6276 PrintF("stepscount=%d ", current->incremental_marking_steps - |
| 6163 PrintF("stepstook=%.1f ", steps_took_since_last_gc_); | 6277 previous->incremental_marking_steps); |
| 6278 PrintF("stepstook=%.1f ", current->incremental_marking_duration - | |
| 6279 previous->incremental_marking_duration); | |
| 6164 } else { | 6280 } else { |
| 6165 PrintF("stepscount=%d ", steps_count_); | 6281 EventBuffer::const_iterator previous_mark_compactor = current; |
| 6166 PrintF("stepstook=%.1f ", steps_took_); | 6282 --previous_mark_compactor; |
| 6167 PrintF("longeststep=%.1f ", longest_step_); | 6283 PrintF("stepscount=%d ", current->incremental_marking_steps - |
| 6284 previous_mark_compactor->incremental_marking_steps); | |
| 6285 PrintF("stepstook=%.1f ", current->incremental_marking_duration - | |
| 6286 previous_mark_compactor->incremental_marking_duration); | |
| 6287 PrintF("longeststep=%.1f ", current->longest_incremental_marking_step); | |
| 6168 } | 6288 } |
| 6169 | 6289 |
| 6170 PrintF("\n"); | 6290 PrintF("\n"); |
| 6171 } | 6291 } |
| 6172 | 6292 |
| 6173 | 6293 |
| 6174 const char* GCTracer::CollectorString() const { | |
| 6175 switch (collector_) { | |
| 6176 case SCAVENGER: | |
| 6177 return "Scavenge"; | |
| 6178 case MARK_COMPACTOR: | |
| 6179 return "Mark-sweep"; | |
| 6180 } | |
| 6181 return "Unknown GC"; | |
| 6182 } | |
| 6183 | |
| 6184 | |
| 6185 int KeyedLookupCache::Hash(Handle<Map> map, Handle<Name> name) { | 6294 int KeyedLookupCache::Hash(Handle<Map> map, Handle<Name> name) { |
| 6186 DisallowHeapAllocation no_gc; | 6295 DisallowHeapAllocation no_gc; |
| 6187 // Uses only lower 32 bits if pointers are larger. | 6296 // Uses only lower 32 bits if pointers are larger. |
| 6188 uintptr_t addr_hash = | 6297 uintptr_t addr_hash = |
| 6189 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*map)) >> kMapHashShift; | 6298 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*map)) >> kMapHashShift; |
| 6190 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); | 6299 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); |
| 6191 } | 6300 } |
| 6192 | 6301 |
| 6193 | 6302 |
| 6194 int KeyedLookupCache::Lookup(Handle<Map> map, Handle<Name> name) { | 6303 int KeyedLookupCache::Lookup(Handle<Map> map, Handle<Name> name) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6441 static_cast<int>(object_sizes_last_time_[index])); | 6550 static_cast<int>(object_sizes_last_time_[index])); |
| 6442 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6551 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6443 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6552 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6444 | 6553 |
| 6445 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6554 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6446 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6555 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6447 ClearObjectStats(); | 6556 ClearObjectStats(); |
| 6448 } | 6557 } |
| 6449 | 6558 |
| 6450 } } // namespace v8::internal | 6559 } } // namespace v8::internal |
| OLD | NEW |