diff options
Diffstat (limited to 'deps/v8/src/counters.cc')
-rw-r--r-- | deps/v8/src/counters.cc | 99 |
1 files changed, 29 insertions, 70 deletions
diff --git a/deps/v8/src/counters.cc b/deps/v8/src/counters.cc index c754e6fdef..e41fa276a8 100644 --- a/deps/v8/src/counters.cc +++ b/deps/v8/src/counters.cc @@ -444,80 +444,46 @@ RuntimeCallStats::RuntimeCallStats() : in_use_(false) { FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER) // #undef CALL_BUILTIN_COUNTER }; - for (int i = 0; i < counters_count; i++) { - this->*(counters[i]) = RuntimeCallCounter(kNames[i]); + for (int i = 0; i < kNumberOfCounters; i++) { + this->counters_[i] = RuntimeCallCounter(kNames[i]); } } -// static -const RuntimeCallStats::CounterId RuntimeCallStats::counters[] = { -#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::GC_##name, - FOR_EACH_GC_COUNTER(CALL_BUILTIN_COUNTER) // -#undef CALL_BUILTIN_COUNTER -#define CALL_RUNTIME_COUNTER(name) &RuntimeCallStats::name, - FOR_EACH_MANUAL_COUNTER(CALL_RUNTIME_COUNTER) // -#undef CALL_RUNTIME_COUNTER -#define CALL_RUNTIME_COUNTER(name, nargs, ressize) \ - &RuntimeCallStats::Runtime_##name, // - FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) // -#undef CALL_RUNTIME_COUNTER -#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::Builtin_##name, - BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) // -#undef CALL_BUILTIN_COUNTER -#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::API_##name, - FOR_EACH_API_COUNTER(CALL_BUILTIN_COUNTER) // -#undef CALL_BUILTIN_COUNTER -#define CALL_BUILTIN_COUNTER(name) &RuntimeCallStats::Handler_##name, - FOR_EACH_HANDLER_COUNTER(CALL_BUILTIN_COUNTER) // -#undef CALL_BUILTIN_COUNTER -}; - -// static -const int RuntimeCallStats::counters_count = - arraysize(RuntimeCallStats::counters); - -// static -void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, - CounterId counter_id) { - DCHECK(stats->IsCalledOnTheSameThread()); - RuntimeCallCounter* counter = &(stats->*counter_id); +void RuntimeCallStats::Enter(RuntimeCallTimer* timer, + RuntimeCallCounterId counter_id) { + DCHECK(IsCalledOnTheSameThread()); + RuntimeCallCounter* counter = GetCounter(counter_id); DCHECK_NOT_NULL(counter->name()); - timer->Start(counter, stats->current_timer()); - stats->current_timer_.SetValue(timer); - stats->current_counter_.SetValue(counter); + timer->Start(counter, current_timer()); + current_timer_.SetValue(timer); + current_counter_.SetValue(counter); } -// static -void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { - DCHECK(stats->IsCalledOnTheSameThread()); - RuntimeCallTimer* stack_top = stats->current_timer(); +void RuntimeCallStats::Leave(RuntimeCallTimer* timer) { + DCHECK(IsCalledOnTheSameThread()); + RuntimeCallTimer* stack_top = current_timer(); if (stack_top == nullptr) return; // Missing timer is a result of Reset(). CHECK(stack_top == timer); - stats->current_timer_.SetValue(timer->Stop()); - RuntimeCallTimer* cur_timer = stats->current_timer(); - stats->current_counter_.SetValue(cur_timer ? cur_timer->counter() : nullptr); + current_timer_.SetValue(timer->Stop()); + RuntimeCallTimer* cur_timer = current_timer(); + current_counter_.SetValue(cur_timer ? cur_timer->counter() : nullptr); } void RuntimeCallStats::Add(RuntimeCallStats* other) { - for (const RuntimeCallStats::CounterId counter_id : - RuntimeCallStats::counters) { - RuntimeCallCounter* counter = &(this->*counter_id); - RuntimeCallCounter* other_counter = &(other->*counter_id); - counter->Add(other_counter); + for (int i = 0; i < kNumberOfCounters; i++) { + GetCounter(i)->Add(other->GetCounter(i)); } } // static -void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, - CounterId counter_id) { - DCHECK(stats->IsCalledOnTheSameThread()); - // When RCS are enabled dynamically there might be no stats or timer set up. - if (stats == nullptr) return; - RuntimeCallTimer* timer = stats->current_timer_.Value(); +void RuntimeCallStats::CorrectCurrentCounterId( + RuntimeCallCounterId counter_id) { + DCHECK(IsCalledOnTheSameThread()); + RuntimeCallTimer* timer = current_timer(); if (timer == nullptr) return; - RuntimeCallCounter* counter = &(stats->*counter_id); + RuntimeCallCounter* counter = GetCounter(counter_id); timer->set_counter(counter); - stats->current_counter_.SetValue(counter); + current_counter_.SetValue(counter); } bool RuntimeCallStats::IsCalledOnTheSameThread() { @@ -537,10 +503,8 @@ void RuntimeCallStats::Print(std::ostream& os) { if (current_timer_.Value() != nullptr) { current_timer_.Value()->Snapshot(); } - for (const RuntimeCallStats::CounterId counter_id : - RuntimeCallStats::counters) { - RuntimeCallCounter* counter = &(this->*counter_id); - entries.Add(counter); + for (int i = 0; i < kNumberOfCounters; i++) { + entries.Add(GetCounter(i)); } entries.Print(os); } @@ -556,22 +520,17 @@ void RuntimeCallStats::Reset() { current_timer_.SetValue(current_timer_.Value()->Stop()); } - for (const RuntimeCallStats::CounterId counter_id : - RuntimeCallStats::counters) { - RuntimeCallCounter* counter = &(this->*counter_id); - counter->Reset(); + for (int i = 0; i < kNumberOfCounters; i++) { + GetCounter(i)->Reset(); } in_use_ = true; } 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); + for (int i = 0; i < kNumberOfCounters; i++) { + if (GetCounter(i)->count() > 0) GetCounter(i)->Dump(value); } - in_use_ = false; } |