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,
DCHECK(counter->name() != nullptr);
timer->Start(counter, stats->current_timer_.Value());
stats->current_timer_.SetValue(timer);
stats->current_counter_.SetValue(counter);
}
// static
......@@ -431,6 +432,15 @@ void RuntimeCallStats::Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer) {
if (next == nullptr) return;
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) {
......@@ -448,7 +458,9 @@ 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->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) {
......
......@@ -859,11 +859,14 @@ class RuntimeCallStats final : public ZoneObject {
V8_NOINLINE void Dump(v8::tracing::TracedValue* value);
RuntimeCallTimer* current_timer() { return current_timer_.Value(); }
RuntimeCallCounter* current_counter() { return current_counter_.Value(); }
bool InUse() { return in_use_; }
private:
// Counter to track recursive time events.
// Top of a stack of active timers.
base::AtomicValue<RuntimeCallTimer*> current_timer_;
// Active counter object associated with current timer.
base::AtomicValue<RuntimeCallCounter*> current_counter_;
// Used to track nested tracing scopes.
bool in_use_;
};
......
......@@ -1295,9 +1295,7 @@ void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) {
void Logger::RuntimeCallTimerEvent() {
RuntimeCallStats* stats = isolate_->counters()->runtime_call_stats();
RuntimeCallTimer* timer = stats->current_timer();
if (timer == nullptr) return;
RuntimeCallCounter* counter = timer->counter();
RuntimeCallCounter* counter = stats->current_counter();
if (counter == nullptr) return;
Log::MessageBuilder msg(log_);
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