Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index d172ceb54d0d588fba6294024529c1d9174bae7a..99b3b1af4368ceab4a4e9d42d63f2e4f56dce57a 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), |
@@ -834,26 +834,27 @@ bool Heap::CollectGarbage(GarbageCollector collector, |
bool next_gc_likely_to_collect_more = false; |
- { GCTracer tracer(this, gc_reason, collector_reason); |
+ { tracer()->start(gc_reason, collector_reason); |
ASSERT(AllowHeapAllocation::IsAllowed()); |
DisallowHeapAllocation no_allocation_during_gc; |
GarbageCollectionPrologue(); |
// The GC count was incremented in the prologue. Tell the tracer about |
// it. |
- tracer.set_gc_count(gc_count_); |
+ tracer()->set_gc_count(gc_count_); |
// Tell the tracer which collector we've selected. |
- tracer.set_collector(collector); |
+ tracer()->set_collector(collector); |
{ |
HistogramTimerScope histogram_timer_scope( |
(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,10 +1117,10 @@ 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, tracer); |
+ collector); |
} |
gc_post_processing_depth_--; |
@@ -1143,7 +1141,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); |
@@ -1196,16 +1194,16 @@ 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_++; |
- tracer->set_full_gc_count(ms_count_); |
+ tracer()->set_full_gc_count(ms_count_); |
MarkCompactPrologue(); |
@@ -5961,23 +5959,50 @@ static intptr_t CountTotalHolesSize(Heap* heap) { |
} |
-GCTracer::GCTracer(Heap* heap, |
- const char* gc_reason, |
- const char* collector_reason) |
+GCTracer::GCTracer(Heap* heap) |
: start_time_(0.0), |
start_object_size_(0), |
start_memory_size_(0), |
gc_count_(0), |
full_gc_count_(0), |
+ in_free_list_or_wasted_before_gc_(0), |
allocated_since_last_gc_(0), |
spent_in_mutator_(0), |
nodes_died_in_new_space_(0), |
nodes_copied_in_new_space_(0), |
nodes_promoted_(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) { |
- if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
+ gc_reason_(NULL), |
+ collector_reason_(NULL) { |
+ |
+ for (int i = 0; i < Scope::kNumberOfScopes; i++) { |
+ scopes_[i] = 0; |
+ } |
+} |
+ |
+ |
+GCTracer::~GCTracer() { |
+} |
+ |
+ |
+void GCTracer::start(const char* gc_reason, const char* collector_reason) { |
+ if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) |
+ return; |
+ |
+ gc_count_ = 0; |
+ full_gc_count_ = 0; |
+ spent_in_mutator_ = 0; |
+ nodes_died_in_new_space_ = 0; |
+ nodes_copied_in_new_space_ = 0; |
+ nodes_promoted_ = 0; |
+ 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(); |
@@ -5986,7 +6011,7 @@ 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_; |
@@ -5994,18 +6019,10 @@ GCTracer::GCTracer(Heap* heap, |
if (heap_->last_gc_end_timestamp_ > 0) { |
spent_in_mutator_ = Max(start_time_ - heap_->last_gc_end_timestamp_, 0.0); |
} |
- |
- steps_count_ = heap_->incremental_marking()->steps_count(); |
- steps_took_ = heap_->incremental_marking()->steps_took(); |
- longest_step_ = heap_->incremental_marking()->longest_step(); |
- steps_count_since_last_gc_ = |
- heap_->incremental_marking()->steps_count_since_last_gc(); |
- steps_took_since_last_gc_ = |
- heap_->incremental_marking()->steps_took_since_last_gc(); |
} |
-GCTracer::~GCTracer() { |
+void GCTracer::stop() { |
// Printf ONE line iff flag is set. |
if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |