Index: src/counters.cc |
diff --git a/src/counters.cc b/src/counters.cc |
index 5089eb22e8ba397dc7108af37071dd2a74915cde..0468d0fbd5b02f39cf4984955a5828db2b03aa73 100644 |
--- a/src/counters.cc |
+++ b/src/counters.cc |
@@ -216,10 +216,11 @@ class RuntimeCallStatEntries { |
// binary size increase: std::vector::push_back expands to a large amount of |
// instructions, and this function is invoked repeatedly by macros. |
V8_NOINLINE void Add(RuntimeCallCounter* counter) { |
- if (counter->count == 0) return; |
- entries.push_back(Entry(counter->name, counter->time, counter->count)); |
- total_time += counter->time; |
- total_call_count += counter->count; |
+ if (counter->count() == 0) return; |
+ entries.push_back( |
+ Entry(counter->name(), counter->time(), counter->count())); |
+ total_time += counter->time(); |
+ total_call_count += counter->count(); |
} |
private: |
@@ -273,20 +274,33 @@ class RuntimeCallStatEntries { |
}; |
void RuntimeCallCounter::Reset() { |
- count = 0; |
- time = base::TimeDelta(); |
+ count_ = 0; |
+ time_ = base::TimeDelta(); |
} |
void RuntimeCallCounter::Dump(v8::tracing::TracedValue* value) { |
- value->BeginArray(name); |
- value->AppendLongInteger(count); |
- value->AppendLongInteger(time.InMicroseconds()); |
+ value->BeginArray(name_); |
+ value->AppendLongInteger(count_); |
+ value->AppendLongInteger(time_.InMicroseconds()); |
value->EndArray(); |
} |
void RuntimeCallCounter::Add(RuntimeCallCounter* other) { |
- count += other->count; |
- time += other->time; |
+ count_ += other->count(); |
+ time_ += other->time(); |
+} |
+ |
+void RuntimeCallTimer::Snapshot() { |
+ base::TimeTicks now = Now(); |
+ // Pause only / topmost timer in the timer stack. |
+ Pause(now); |
+ // Commit all the timer's elapsed time to the counters. |
+ RuntimeCallTimer* timer = this; |
+ while (timer != nullptr) { |
+ timer->CommitTimeToCounter(); |
+ timer = timer->parent(); |
+ } |
+ Resume(now); |
} |
// static |
@@ -313,7 +327,7 @@ const RuntimeCallStats::CounterId RuntimeCallStats::counters[] = { |
void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, |
CounterId counter_id) { |
RuntimeCallCounter* counter = &(stats->*counter_id); |
- DCHECK(counter->name != nullptr); |
+ DCHECK(counter->name() != nullptr); |
timer->Start(counter, stats->current_timer_.Value()); |
stats->current_timer_.SetValue(timer); |
} |
@@ -329,7 +343,7 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { |
RuntimeCallTimer* next = stats->current_timer_.Value(); |
while (next && next->parent() != timer) next = next->parent(); |
if (next == nullptr) return; |
- next->parent_.SetValue(timer->Stop()); |
+ next->set_parent(timer->Stop()); |
} |
} |
@@ -348,13 +362,13 @@ void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, |
RuntimeCallTimer* timer = stats->current_timer_.Value(); |
// When RCS are enabled dynamically there might be no current timer set up. |
if (timer == nullptr) return; |
- timer->counter_ = &(stats->*counter_id); |
+ timer->set_counter(&(stats->*counter_id)); |
} |
void RuntimeCallStats::Print(std::ostream& os) { |
RuntimeCallStatEntries entries; |
if (current_timer_.Value() != nullptr) { |
- current_timer_.Value()->Elapsed(); |
+ current_timer_.Value()->Snapshot(); |
} |
for (const RuntimeCallStats::CounterId counter_id : |
RuntimeCallStats::counters) { |
@@ -388,7 +402,7 @@ void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { |
for (const RuntimeCallStats::CounterId counter_id : |
RuntimeCallStats::counters) { |
RuntimeCallCounter* counter = &(this->*counter_id); |
- if (counter->count > 0) counter->Dump(value); |
+ if (counter->count() > 0) counter->Dump(value); |
} |
in_use_ = false; |