| Index: src/counters.h
|
| diff --git a/src/counters.h b/src/counters.h
|
| index bf10a4ece0b298aa680a335b0064dffb5135ff44..533e26ea1212bacd30920011ee2d7de7ed1ae6b7 100644
|
| --- a/src/counters.h
|
| +++ b/src/counters.h
|
| @@ -701,27 +701,60 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
|
| /* Total count of functions compiled using the baseline compiler. */ \
|
| SC(total_baseline_compile_count, V8.TotalBaselineCompileCount)
|
|
|
| -typedef struct RuntimeCallCounter {
|
| +struct RuntimeCallCounter {
|
| + explicit RuntimeCallCounter(const char* name) : name(name) {}
|
| + void Reset();
|
| +
|
| + const char* name;
|
| int64_t count = 0;
|
| base::TimeDelta time;
|
| - RuntimeCallCounter* parent_counter;
|
| +};
|
|
|
| - void Reset();
|
| -} RuntimeCallCounter;
|
| +// TimerLink is used to keep track of the stack of currently active timers used
|
| +// for RuntimeCallCounter.
|
| +class TimerLink {
|
| + public:
|
| + TimerLink(RuntimeCallCounter* counter, TimerLink* parent)
|
| + : counter_(counter), parent_(parent) {}
|
| +
|
| + inline void Start() {
|
| + timer_.Start();
|
| + counter_->count++;
|
| + }
|
| +
|
| + inline TimerLink* Stop() {
|
| + base::TimeDelta delta = timer_.Elapsed();
|
| + counter_->time += delta;
|
| + if (parent_ != NULL) {
|
| + parent_->AdjustForSubTimer(delta);
|
| + }
|
| + return parent_;
|
| + }
|
| +
|
| + void AdjustForSubTimer(base::TimeDelta delta) { counter_->time -= delta; }
|
| +
|
| + private:
|
| + RuntimeCallCounter* counter_;
|
| + TimerLink* parent_;
|
| + base::ElapsedTimer timer_;
|
| +};
|
|
|
| struct RuntimeCallStats {
|
| + // Dummy counter for the unexpected stub miss.
|
| + RuntimeCallCounter UnexpectedStubMiss = {"UnexpectedStubMiss"};
|
| + // Counter for runtime callbacks into JavaScript.
|
| + RuntimeCallCounter RuntimeCallbacks = {"RuntimeCallback"};
|
| #define CALL_RUNTIME_COUNTER(name, nargs, ressize) \
|
| - RuntimeCallCounter Runtime_##name;
|
| + RuntimeCallCounter Runtime_##name = {#name};
|
| FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER)
|
| #undef CALL_RUNTIME_COUNTER
|
| -#define CALL_BUILTIN_COUNTER(name, type) RuntimeCallCounter Builtin_##name;
|
| +#define CALL_BUILTIN_COUNTER(name, type) \
|
| + RuntimeCallCounter Builtin_##name = {#name};
|
| BUILTIN_LIST_C(CALL_BUILTIN_COUNTER)
|
| #undef CALL_BUILTIN_COUNTER
|
|
|
| - // Dummy counter for the unexpected stub miss.
|
| - RuntimeCallCounter UnexpectedStubMiss;
|
| // Counter to track recursive time events.
|
| - RuntimeCallCounter* current_counter;
|
| + TimerLink* current_timer_link_;
|
|
|
| // Starting measuring the time for a function. This will establish the
|
| // connection to the parent counter for properly calculating the own times.
|
| @@ -729,7 +762,7 @@ struct RuntimeCallStats {
|
| // Leave a scope for a measured runtime function. This will properly add
|
| // the time delta to the current_counter and subtract the delta from its
|
| // parent.
|
| - void Leave(base::TimeDelta time);
|
| + void Leave();
|
|
|
| void Reset();
|
| void Print(std::ostream& os);
|
|
|