Chromium Code Reviews| Index: src/heap/gc-tracer.cc |
| diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc |
| index eb4885db47984ef419ed0d1312dfa14c305964cc..655e3c82d568d42eab52b8c3c6f1b8660aa5e549 100644 |
| --- a/src/heap/gc-tracer.cc |
| +++ b/src/heap/gc-tracer.cc |
| @@ -84,28 +84,17 @@ GCTracer::Event::Event(Type type, GarbageCollectionReason gc_reason, |
| } |
| } |
| - |
| const char* GCTracer::Event::TypeName(bool short_name) const { |
| switch (type) { |
| case SCAVENGER: |
| - if (short_name) { |
| - return "s"; |
| - } else { |
| - return "Scavenge"; |
| - } |
| + return (short_name) ? "s" : "Scavenge"; |
| case MARK_COMPACTOR: |
| case INCREMENTAL_MARK_COMPACTOR: |
| - if (short_name) { |
| - return "ms"; |
| - } else { |
| - return "Mark-sweep"; |
| - } |
| + return (short_name) ? "ms" : "Mark-sweep"; |
| + case MINOR_MARK_COMPACTOR: |
| + return (short_name) ? "mmc" : "Minor Mark-Compact"; |
| case START: |
| - if (short_name) { |
| - return "st"; |
| - } else { |
| - return "Start"; |
| - } |
| + return (short_name) ? "st" : "Start"; |
| } |
| return "Unknown Event Type"; |
| } |
| @@ -116,6 +105,7 @@ GCTracer::GCTracer(Heap* heap) |
| previous_(current_), |
| incremental_marking_bytes_(0), |
| incremental_marking_duration_(0.0), |
| + incremental_marking_start_time_(0.0), |
| recorded_incremental_marking_speed_(0.0), |
| allocation_time_ms_(0.0), |
| new_space_allocation_counter_bytes_(0), |
| @@ -163,15 +153,22 @@ void GCTracer::Start(GarbageCollector collector, |
| SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(), |
| heap_->OldGenerationAllocationCounter()); |
| - if (collector == SCAVENGER) { |
| - current_ = Event(Event::SCAVENGER, gc_reason, collector_reason); |
| - } else if (collector == MARK_COMPACTOR) { |
| - if (heap_->incremental_marking()->WasActivated()) { |
| + switch (collector) { |
| + case SCAVENGER: |
| + current_ = Event(Event::SCAVENGER, gc_reason, collector_reason); |
| + break; |
| + case MINOR_MARK_COMPACTOR: |
| current_ = |
| - Event(Event::INCREMENTAL_MARK_COMPACTOR, gc_reason, collector_reason); |
| - } else { |
| - current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason); |
| - } |
| + Event(Event::MINOR_MARK_COMPACTOR, gc_reason, collector_reason); |
| + break; |
| + case MARK_COMPACTOR: |
| + if (heap_->incremental_marking()->WasActivated()) { |
| + current_ = Event(Event::INCREMENTAL_MARK_COMPACTOR, gc_reason, |
| + collector_reason); |
| + } else { |
| + current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason); |
| + } |
| + break; |
| } |
| current_.reduce_memory = heap_->ShouldReduceMemory(); |
| @@ -194,7 +191,7 @@ void GCTracer::Start(GarbageCollector collector, |
| Counters* counters = heap_->isolate()->counters(); |
| - if (collector == SCAVENGER) { |
| + if (Heap::IsYoungGenerationCollector(collector)) { |
| counters->scavenge_reason()->AddSample(static_cast<int>(gc_reason)); |
| } else { |
| counters->mark_compact_reason()->AddSample(static_cast<int>(gc_reason)); |
| @@ -220,15 +217,16 @@ void GCTracer::ResetIncrementalMarkingCounters() { |
| void GCTracer::Stop(GarbageCollector collector) { |
| start_counter_--; |
| if (start_counter_ != 0) { |
| - heap_->isolate()->PrintWithTimestamp( |
| - "[Finished reentrant %s during %s.]\n", |
| - collector == SCAVENGER ? "Scavenge" : "Mark-sweep", |
| - current_.TypeName(false)); |
| + heap_->isolate()->PrintWithTimestamp("[Finished reentrant %s during %s.]\n", |
| + Heap::CollectorName(collector), |
| + current_.TypeName(false)); |
| return; |
| } |
| DCHECK(start_counter_ >= 0); |
| DCHECK((collector == SCAVENGER && current_.type == Event::SCAVENGER) || |
| + (collector == MINOR_MARK_COMPACTOR && |
| + current_.type == Event::MINOR_MARK_COMPACTOR) || |
| (collector == MARK_COMPACTOR && |
| (current_.type == Event::MARK_COMPACTOR || |
| current_.type == Event::INCREMENTAL_MARK_COMPACTOR))); |
| @@ -250,36 +248,45 @@ void GCTracer::Stop(GarbageCollector collector) { |
| double duration = current_.end_time - current_.start_time; |
| - if (current_.type == Event::SCAVENGER) { |
| - recorded_scavenges_total_.Push( |
| - MakeBytesAndDuration(current_.new_space_object_size, duration)); |
| - recorded_scavenges_survived_.Push(MakeBytesAndDuration( |
| - current_.survived_new_space_object_size, duration)); |
| - } else if (current_.type == Event::INCREMENTAL_MARK_COMPACTOR) { |
| - current_.incremental_marking_bytes = incremental_marking_bytes_; |
| - current_.incremental_marking_duration = incremental_marking_duration_; |
| - for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { |
| - current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i]; |
| - current_.scopes[i] = incremental_marking_scopes_[i].duration; |
| - } |
| - RecordIncrementalMarkingSpeed(current_.incremental_marking_bytes, |
| - current_.incremental_marking_duration); |
| - recorded_incremental_mark_compacts_.Push( |
| - MakeBytesAndDuration(current_.start_object_size, duration)); |
| - ResetIncrementalMarkingCounters(); |
| - combined_mark_compact_speed_cache_ = 0.0; |
| - } else { |
| - DCHECK_EQ(0, current_.incremental_marking_bytes); |
| - DCHECK_EQ(0, current_.incremental_marking_duration); |
| - recorded_mark_compacts_.Push( |
| - MakeBytesAndDuration(current_.start_object_size, duration)); |
| - ResetIncrementalMarkingCounters(); |
| - combined_mark_compact_speed_cache_ = 0.0; |
| + switch (current_.type) { |
| + case Event::SCAVENGER: |
| + case Event::MINOR_MARK_COMPACTOR: |
| + recorded_scavenges_total_.Push( |
|
Hannes Payer (out of office)
2016/11/11 14:02:42
recorded_scavenges_total_ should change recorded_m
Michael Lippautz
2016/11/11 15:11:00
Done.
|
| + MakeBytesAndDuration(current_.new_space_object_size, duration)); |
| + recorded_scavenges_survived_.Push(MakeBytesAndDuration( |
| + current_.survived_new_space_object_size, duration)); |
| + break; |
| + case Event::INCREMENTAL_MARK_COMPACTOR: |
| + current_.incremental_marking_bytes = incremental_marking_bytes_; |
| + current_.incremental_marking_duration = incremental_marking_duration_; |
| + for (int i = 0; i < Scope::NUMBER_OF_INCREMENTAL_SCOPES; i++) { |
| + current_.incremental_marking_scopes[i] = incremental_marking_scopes_[i]; |
| + current_.scopes[i] = incremental_marking_scopes_[i].duration; |
| + } |
| + RecordIncrementalMarkingSpeed(current_.incremental_marking_bytes, |
| + current_.incremental_marking_duration); |
| + recorded_incremental_mark_compacts_.Push( |
| + MakeBytesAndDuration(current_.start_object_size, duration)); |
| + ResetIncrementalMarkingCounters(); |
| + combined_mark_compact_speed_cache_ = 0.0; |
| + break; |
| + case Event::MARK_COMPACTOR: |
| + DCHECK_EQ(0, current_.incremental_marking_bytes); |
| + DCHECK_EQ(0, current_.incremental_marking_duration); |
| + recorded_mark_compacts_.Push( |
| + MakeBytesAndDuration(current_.start_object_size, duration)); |
| + ResetIncrementalMarkingCounters(); |
| + combined_mark_compact_speed_cache_ = 0.0; |
| + break; |
| + case Event::START: |
| + UNREACHABLE(); |
| } |
| heap_->UpdateTotalGCTime(duration); |
| - if (current_.type == Event::SCAVENGER && FLAG_trace_gc_ignore_scavenger) |
| + if ((current_.type == Event::SCAVENGER || |
| + current_.type == Event::MINOR_MARK_COMPACTOR) && |
| + FLAG_trace_gc_ignore_scavenger) |
| return; |
| if (FLAG_trace_gc_nvp) { |
| @@ -500,6 +507,15 @@ void GCTracer::PrintNVP() const { |
| NewSpaceAllocationThroughputInBytesPerMillisecond(), |
| ContextDisposalRateInMilliseconds()); |
| break; |
| + case Event::MINOR_MARK_COMPACTOR: |
| + heap_->isolate()->PrintWithTimestamp( |
| + "pause=%.1f " |
| + "mutator=%.1f " |
| + "gc=%s " |
| + "reduce_memory=%d\n", |
| + duration, spent_in_mutator, current_.TypeName(true), |
| + current_.reduce_memory); |
| + break; |
| case Event::MARK_COMPACTOR: |
| case Event::INCREMENTAL_MARK_COMPACTOR: |
| heap_->isolate()->PrintWithTimestamp( |