Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index 16d7a8040bd4bdc1307363521e0d3f1128cc04ad..bce53b9f142347b5b4c4668f95b0c2bd194f125e 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -99,7 +99,7 @@ Heap::Heap() |
| hidden_string_(NULL), |
| gc_safe_size_of_old_object_(NULL), |
| total_regexp_code_generated_(0), |
| - tracer_(NULL), |
| + tracer_(this), |
| high_survival_rate_period_length_(0), |
| promoted_objects_size_(0), |
| promotion_rate_(0), |
| @@ -840,7 +840,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, |
| bool next_gc_likely_to_collect_more = false; |
| - { GCTracer tracer(this, collector, gc_reason, collector_reason); |
| + { tracer()->start(collector, gc_reason, collector_reason); |
| ASSERT(AllowHeapAllocation::IsAllowed()); |
| DisallowHeapAllocation no_allocation_during_gc; |
| GarbageCollectionPrologue(); |
| @@ -850,10 +850,11 @@ bool Heap::CollectGarbage(GarbageCollector collector, |
| (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() |
| : isolate_->counters()->gc_compactor()); |
| next_gc_likely_to_collect_more = |
| - PerformGarbageCollection(collector, &tracer, gc_callback_flags); |
| + PerformGarbageCollection(collector, gc_callback_flags); |
| } |
| GarbageCollectionEpilogue(); |
| + tracer()->stop(); |
| } |
| // Start incremental marking for the next cycle. The heap snapshot |
| @@ -1055,7 +1056,6 @@ void Heap::UpdateSurvivalStatistics(int start_new_space_size) { |
| bool Heap::PerformGarbageCollection( |
| GarbageCollector collector, |
| - GCTracer* tracer, |
| const v8::GCCallbackFlags gc_callback_flags) { |
| int freed_global_handles = 0; |
| @@ -1075,7 +1075,7 @@ bool Heap::PerformGarbageCollection( |
| { GCCallbacksScope scope(this); |
| if (scope.CheckReenter()) { |
| AllowHeapAllocation allow_allocation; |
| - GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| + GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| VMState<EXTERNAL> state(isolate_); |
| HandleScope handle_scope(isolate_); |
| CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); |
| @@ -1095,7 +1095,7 @@ bool Heap::PerformGarbageCollection( |
| if (collector == MARK_COMPACTOR) { |
| // Perform mark-sweep with optional compaction. |
| - MarkCompact(tracer); |
| + MarkCompact(); |
| sweep_generation_++; |
| // Temporarily set the limit for case when PostGarbageCollectionProcessing |
| // allocates and triggers GC. The real limit is set at after |
| @@ -1104,9 +1104,7 @@ bool Heap::PerformGarbageCollection( |
| OldGenerationAllocationLimit(PromotedSpaceSizeOfObjects(), 0); |
| old_gen_exhausted_ = false; |
| } else { |
| - tracer_ = tracer; |
| Scavenge(); |
| - tracer_ = NULL; |
| } |
| UpdateSurvivalStatistics(start_new_space_size); |
| @@ -1119,7 +1117,7 @@ bool Heap::PerformGarbageCollection( |
| gc_post_processing_depth_++; |
| { AllowHeapAllocation allow_allocation; |
| - GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| + GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| freed_global_handles = |
| isolate_->global_handles()->PostGarbageCollectionProcessing(collector); |
| } |
| @@ -1142,7 +1140,7 @@ bool Heap::PerformGarbageCollection( |
| { GCCallbacksScope scope(this); |
| if (scope.CheckReenter()) { |
| AllowHeapAllocation allow_allocation; |
| - GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| + GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| VMState<EXTERNAL> state(isolate_); |
| HandleScope handle_scope(isolate_); |
| CallGCEpilogueCallbacks(gc_type, gc_callback_flags); |
| @@ -1195,13 +1193,13 @@ void Heap::CallGCEpilogueCallbacks(GCType gc_type, |
| } |
| -void Heap::MarkCompact(GCTracer* tracer) { |
| +void Heap::MarkCompact() { |
| gc_state_ = MARK_COMPACT; |
| LOG(isolate_, ResourceEvent("markcompact", "begin")); |
| uint64_t size_of_objects_before_gc = SizeOfObjects(); |
| - mark_compact_collector_.Prepare(tracer); |
| + mark_compact_collector_.Prepare(); |
| ms_count_++; |
| @@ -5977,24 +5975,43 @@ void Heap::UpdateGCStatistics(double start_time, |
| } |
| -GCTracer::GCTracer(Heap* heap, |
| - GarbageCollector collector, |
| - const char* gc_reason, |
| - const char* collector_reason) |
| +GCTracer::GCTracer(Heap* heap) |
| : start_time_(0.0), |
| end_time_(0.0), |
| start_object_size_(0), |
| end_object_size_(0), |
| start_memory_size_(0), |
| end_memory_size_(0), |
| - collector_(collector), |
| + in_free_list_or_wasted_before_gc_(0), |
| allocated_since_last_gc_(0), |
| spent_in_mutator_(0), |
| + steps_count_(0), |
| + steps_took_(0.0), |
| + longest_step_(0.0), |
| + steps_count_since_last_gc_(0), |
| + steps_took_since_last_gc_(0.0), |
| heap_(heap), |
| - gc_reason_(gc_reason), |
| - collector_reason_(collector_reason) { |
| + gc_reason_(NULL), |
| + collector_reason_(NULL) { |
| + for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| + scopes_[i] = 0; |
| + } |
| +} |
| + |
| + |
| +GCTracer::~GCTracer() { |
|
Hannes Payer (out of office)
2014/07/17 15:26:14
I guess we can remove the destructor.
ernstm
2014/07/18 08:32:28
Done.
|
| +} |
| + |
| + |
| +void GCTracer::start(GarbageCollector collector, |
| + const char* gc_reason, |
| + const char* collector_reason) { |
| if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| + collector_ = collector; |
| + gc_reason_ = gc_reason; |
| + collector_reason_ = collector_reason; |
| + |
| start_time_ = base::OS::TimeCurrentMillis(); |
| start_object_size_ = heap_->SizeOfObjects(); |
| start_memory_size_ = heap_->isolate()->memory_allocator()->Size(); |
| @@ -6003,13 +6020,15 @@ GCTracer::GCTracer(Heap* heap, |
| scopes_[i] = 0; |
| } |
| - in_free_list_or_wasted_before_gc_ = CountTotalHolesSize(heap); |
| + in_free_list_or_wasted_before_gc_ = CountTotalHolesSize(heap_); |
| allocated_since_last_gc_ = |
| heap_->SizeOfObjects() - heap_->alive_after_last_gc_; |
| if (heap_->last_gc_end_timestamp_ > 0) { |
| spent_in_mutator_ = Max(start_time_ - heap_->last_gc_end_timestamp_, 0.0); |
| + } else { |
| + spent_in_mutator_ = 0.0; |
|
Hannes Payer (out of office)
2014/07/17 15:26:14
That is actually wrong. We would like to record he
ernstm
2014/07/18 08:32:28
Done.
|
| } |
| steps_count_ = heap_->incremental_marking()->steps_count(); |
| @@ -6022,7 +6041,7 @@ GCTracer::GCTracer(Heap* heap, |
| } |
| -GCTracer::~GCTracer() { |
| +void GCTracer::stop() { |
| if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| end_time_ = base::OS::TimeCurrentMillis(); |