Commit ceb3f4b1 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[RCS] Make runtime call stats work with --prof.

... by avoiding reads through timer objects allocated on stack of another thread and
explicitly maintaining current RuntimeCallCounter object in RuntimeCallStats instead.

Change-Id: I54eaf078dc1e77dc47ded963903d54ffb583f377
Reviewed-on: https://chromium-review.googlesource.com/471667Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44491}
parent 9ddfeafe
...@@ -416,6 +416,7 @@ void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer, ...@@ -416,6 +416,7 @@ void RuntimeCallStats::Enter(RuntimeCallStats* stats, RuntimeCallTimer* timer,
DCHECK(counter->name() != nullptr); DCHECK(counter->name() != nullptr);
timer->Start(counter, stats->current_timer_.Value()); timer->Start(counter, stats->current_timer_.Value());
stats->current_timer_.SetValue(timer); stats->current_timer_.SetValue(timer);
stats->current_counter_.SetValue(counter);
} }
// static // static
...@@ -431,6 +432,15 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) { ...@@ -431,6 +432,15 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
if (next == nullptr) return; if (next == nullptr) return;
next->set_parent(timer->Stop()); next->set_parent(timer->Stop());
} }
{
RuntimeCallTimer* cur_timer = stats->current_timer_.Value();
if (cur_timer == nullptr) {
stats->current_counter_.SetValue(nullptr);
} else {
stats->current_counter_.SetValue(cur_timer->counter());
}
}
} }
void RuntimeCallStats::Add(RuntimeCallStats* other) { void RuntimeCallStats::Add(RuntimeCallStats* other) {
...@@ -448,7 +458,9 @@ void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats, ...@@ -448,7 +458,9 @@ void RuntimeCallStats::CorrectCurrentCounterId(RuntimeCallStats* stats,
RuntimeCallTimer* timer = stats->current_timer_.Value(); RuntimeCallTimer* timer = stats->current_timer_.Value();
// When RCS are enabled dynamically there might be no current timer set up. // When RCS are enabled dynamically there might be no current timer set up.
if (timer == nullptr) return; if (timer == nullptr) return;
timer->set_counter(&(stats->*counter_id)); RuntimeCallCounter* counter = &(stats->*counter_id);
timer->set_counter(counter);
stats->current_counter_.SetValue(counter);
} }
void RuntimeCallStats::Print(std::ostream& os) { void RuntimeCallStats::Print(std::ostream& os) {
......
...@@ -859,11 +859,14 @@ class RuntimeCallStats final : public ZoneObject { ...@@ -859,11 +859,14 @@ class RuntimeCallStats final : public ZoneObject {
V8_NOINLINE void Dump(v8::tracing::TracedValue* value); V8_NOINLINE void Dump(v8::tracing::TracedValue* value);
RuntimeCallTimer* current_timer() { return current_timer_.Value(); } RuntimeCallTimer* current_timer() { return current_timer_.Value(); }
RuntimeCallCounter* current_counter() { return current_counter_.Value(); }
bool InUse() { return in_use_; } bool InUse() { return in_use_; }
private: private:
// Counter to track recursive time events. // Top of a stack of active timers.
base::AtomicValue<RuntimeCallTimer*> current_timer_; base::AtomicValue<RuntimeCallTimer*> current_timer_;
// Active counter object associated with current timer.
base::AtomicValue<RuntimeCallCounter*> current_counter_;
// Used to track nested tracing scopes. // Used to track nested tracing scopes.
bool in_use_; bool in_use_;
}; };
......
...@@ -1295,9 +1295,7 @@ void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) { ...@@ -1295,9 +1295,7 @@ void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) {
void Logger::RuntimeCallTimerEvent() { void Logger::RuntimeCallTimerEvent() {
RuntimeCallStats* stats = isolate_->counters()->runtime_call_stats(); RuntimeCallStats* stats = isolate_->counters()->runtime_call_stats();
RuntimeCallTimer* timer = stats->current_timer(); RuntimeCallCounter* counter = stats->current_counter();
if (timer == nullptr) return;
RuntimeCallCounter* counter = timer->counter();
if (counter == nullptr) return; if (counter == nullptr) return;
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("active-runtime-timer,"); msg.Append("active-runtime-timer,");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment