Skip to content

Commit e7fa71d

Browse files
a1phCommit Bot
authored andcommitted
[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/643472 Reviewed-by: Camillo Bruni <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Commit-Queue: Alexei Filippov <[email protected]> Cr-Commit-Position: refs/heads/master@{#47749}
1 parent 72c9ab3 commit e7fa71d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/heap/gc-tracer.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,18 @@ GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
3232
: tracer_(tracer), scope_(scope) {
3333
start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs();
3434
// TODO(cbruni): remove once we fully moved to a trace-based system.
35-
if (V8_UNLIKELY(FLAG_runtime_stats)) {
36-
RuntimeCallStats::Enter(
37-
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_,
38-
GCTracer::RCSCounterFromScope(scope));
39-
}
35+
if (V8_LIKELY(!FLAG_runtime_stats)) return;
36+
runtime_stats_ = tracer_->heap_->isolate()->counters()->runtime_call_stats();
37+
RuntimeCallStats::Enter(runtime_stats_, &timer_,
38+
GCTracer::RCSCounterFromScope(scope));
4039
}
4140

4241
GCTracer::Scope::~Scope() {
4342
tracer_->AddScopeSample(
4443
scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_);
4544
// TODO(cbruni): remove once we fully moved to a trace-based system.
46-
if (V8_UNLIKELY(FLAG_runtime_stats)) {
47-
RuntimeCallStats::Leave(
48-
tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_);
49-
}
45+
if (V8_LIKELY(runtime_stats_ == nullptr)) return;
46+
RuntimeCallStats::Leave(runtime_stats_, &timer_);
5047
}
5148

5249
const char* GCTracer::Scope::Name(ScopeId id) {

src/heap/gc-tracer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class V8_EXPORT_PRIVATE GCTracer {
8181
ScopeId scope_;
8282
double start_time_;
8383
RuntimeCallTimer timer_;
84+
RuntimeCallStats* runtime_stats_ = nullptr;
8485

8586
DISALLOW_COPY_AND_ASSIGN(Scope);
8687
};

0 commit comments

Comments
 (0)