diff options
Diffstat (limited to 'deps/v8/src/counters.cc')
-rw-r--r-- | deps/v8/src/counters.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/deps/v8/src/counters.cc b/deps/v8/src/counters.cc index a5709dbec9..c754e6fdef 100644 --- a/deps/v8/src/counters.cc +++ b/deps/v8/src/counters.cc @@ -16,9 +16,9 @@ namespace v8 { namespace internal { StatsTable::StatsTable(Counters* counters) - : lookup_function_(NULL), - create_histogram_function_(NULL), - add_histogram_sample_function_(NULL) {} + : lookup_function_(nullptr), + create_histogram_function_(nullptr), + add_histogram_sample_function_(nullptr) {} void StatsTable::SetCounterFunction(CounterLookupCallback f) { lookup_function_ = f; @@ -313,6 +313,9 @@ void Counters::ResetCreateHistogramFunction(CreateHistogramCallback f) { #undef HM } +base::TimeTicks (*RuntimeCallTimer::Now)() = + &base::TimeTicks::HighResolutionNow; + class RuntimeCallStatEntries { public: void Print(std::ostream& os) { @@ -478,8 +481,8 @@ void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, CounterId counter_id) { DCHECK(stats->IsCalledOnTheSameThread()); RuntimeCallCounter* counter = &(stats->*counter_id); - DCHECK(counter->name() != nullptr); - timer->Start(counter, stats->current_timer_.Value()); + DCHECK_NOT_NULL(counter->name()); + timer->Start(counter, stats->current_timer()); stats->current_timer_.SetValue(timer); stats->current_counter_.SetValue(counter); } @@ -487,17 +490,11 @@ void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, // static void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { DCHECK(stats->IsCalledOnTheSameThread()); - if (stats->current_timer_.Value() != timer) { - // The branch is added to catch a crash crbug.com/760649 - RuntimeCallTimer* stack_top = stats->current_timer_.Value(); - EmbeddedVector<char, 200> text; - SNPrintF(text, "ERROR: Leaving counter '%s', stack top '%s'.\n", - timer->name(), stack_top ? stack_top->name() : "(null)"); - USE(text); - CHECK(false); - } + RuntimeCallTimer* stack_top = stats->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_.Value(); + RuntimeCallTimer* cur_timer = stats->current_timer(); stats->current_counter_.SetValue(cur_timer ? cur_timer->counter() : nullptr); } @@ -513,8 +510,10 @@ void RuntimeCallStats::Add(RuntimeCallStats* other) { // 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(); - // When RCS are enabled dynamically there might be no current timer set up. if (timer == nullptr) return; RuntimeCallCounter* counter = &(stats->*counter_id); timer->set_counter(counter); @@ -528,6 +527,11 @@ bool RuntimeCallStats::IsCalledOnTheSameThread() { return true; } +void RuntimeCallStats::Print() { + OFStream os(stdout); + Print(os); +} + void RuntimeCallStats::Print(std::ostream& os) { RuntimeCallStatEntries entries; if (current_timer_.Value() != nullptr) { |