Commit e7fa71dc authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[runtime-call-stats] Make sure GCTracer::Scope makes paired Enter/Leave calls

Ensure that RuntimeCallStats::Enter is paired with Leave when
FLAG_runtime_stats changes in flight.

BUG=chromium:669329

Change-Id: I4da7edf88990fdebd7d05325a09cfca0702cfe5a
Reviewed-on: https://chromium-review.googlesource.com/643472Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47749}
parent 72c9ab34
...@@ -32,21 +32,18 @@ GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) ...@@ -32,21 +32,18 @@ GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
: tracer_(tracer), scope_(scope) { : tracer_(tracer), scope_(scope) {
start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs();
// TODO(cbruni): remove once we fully moved to a trace-based system. // TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) { if (V8_LIKELY(!FLAG_runtime_stats)) return;
RuntimeCallStats::Enter( runtime_stats_ = tracer_->heap_->isolate()->counters()->runtime_call_stats();
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_, RuntimeCallStats::Enter(runtime_stats_, &timer_,
GCTracer::RCSCounterFromScope(scope)); GCTracer::RCSCounterFromScope(scope));
}
} }
GCTracer::Scope::~Scope() { GCTracer::Scope::~Scope() {
tracer_->AddScopeSample( tracer_->AddScopeSample(
scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_);
// TODO(cbruni): remove once we fully moved to a trace-based system. // TODO(cbruni): remove once we fully moved to a trace-based system.
if (V8_UNLIKELY(FLAG_runtime_stats)) { if (V8_LIKELY(runtime_stats_ == nullptr)) return;
RuntimeCallStats::Leave( RuntimeCallStats::Leave(runtime_stats_, &timer_);
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_);
}
} }
const char* GCTracer::Scope::Name(ScopeId id) { const char* GCTracer::Scope::Name(ScopeId id) {
......
...@@ -81,6 +81,7 @@ class V8_EXPORT_PRIVATE GCTracer { ...@@ -81,6 +81,7 @@ class V8_EXPORT_PRIVATE GCTracer {
ScopeId scope_; ScopeId scope_;
double start_time_; double start_time_;
RuntimeCallTimer timer_; RuntimeCallTimer timer_;
RuntimeCallStats* runtime_stats_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(Scope); DISALLOW_COPY_AND_ASSIGN(Scope);
}; };
......
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