v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-call-stats-scope.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_LOGGING_RUNTIME_CALL_STATS_SCOPE_H_
6#define V8_LOGGING_RUNTIME_CALL_STATS_SCOPE_H_
7
8#include <memory>
9
15
16namespace v8 {
17namespace internal {
18
19#ifdef V8_RUNTIME_CALL_STATS
20
21// Make the line number part of the scope's name to avoid -Wshadow warnings.
22#define RCS_SCOPE(...) \
23 v8::internal::RuntimeCallTimerScope CONCAT(rcs_timer_scope, \
24 __LINE__)(__VA_ARGS__)
25
26RuntimeCallTimerScope::RuntimeCallTimerScope(Isolate* isolate,
27 RuntimeCallCounterId counter_id) {
28 if (V8_LIKELY(!TracingFlags::is_runtime_stats_enabled())) return;
29 stats_ = isolate->counters()->runtime_call_stats();
30 stats_->Enter(&timer_, counter_id);
31}
32
33RuntimeCallTimerScope::RuntimeCallTimerScope(
34 LocalIsolate* isolate, RuntimeCallCounterId counter_id,
35 RuntimeCallStats::CounterMode mode) {
36 if (V8_LIKELY(!TracingFlags::is_runtime_stats_enabled())) return;
37 DCHECK_NOT_NULL(isolate->runtime_call_stats());
38 stats_ = isolate->runtime_call_stats();
39 if (mode == RuntimeCallStats::CounterMode::kThreadSpecific) {
40 counter_id = stats_->CounterIdForThread(counter_id);
41 }
42
43 DCHECK(stats_->IsCounterAppropriateForThread(counter_id));
44 stats_->Enter(&timer_, counter_id);
45}
46
47#else // RUNTIME_CALL_STATS
48
49#define RCS_SCOPE(...)
50
51#endif // defined(V8_RUNTIME_CALL_STATS)
52
53} // namespace internal
54} // namespace v8
55
56#endif // V8_LOGGING_RUNTIME_CALL_STATS_SCOPE_H_
base::ElapsedTimer timer_
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK(condition)
Definition logging.h:482
#define V8_LIKELY(condition)
Definition v8config.h:661