v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
tick-sample.h
Go to the documentation of this file.
1// Copyright 2013 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_PROFILER_TICK_SAMPLE_H_
6#define V8_PROFILER_TICK_SAMPLE_H_
7
10#include "src/common/globals.h"
11
12namespace v8 {
13namespace internal {
14
15class Isolate;
16
17// TickSample captures the information collected for each sample.
19 // Internal profiling (with --prof + tools/$OS-tick-processor) wants to
20 // include the runtime function we're calling. Externally exposed tick
21 // samples don't care.
22 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
23
25
38 void Init(Isolate* isolate, const v8::RegisterState& state,
39 RecordCEntryFrame record_c_entry_frame, bool update_stats,
40 bool use_simulator_reg_state = true,
41 base::TimeDelta sampling_interval = base::TimeDelta(),
42 const std::optional<uint64_t> trace_id = std::nullopt);
70 static bool GetStackSample(Isolate* isolate, v8::RegisterState* state,
71 RecordCEntryFrame record_c_entry_frame,
72 void** frames, size_t frames_limit,
73 v8::SampleInfo* sample_info,
74 StateTag* out_state = nullptr,
75 bool use_simulator_reg_state = true);
76
77 void print() const;
78
79 static constexpr unsigned kMaxFramesCountLog2 = 8;
80 static constexpr unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
81
82 void* pc = nullptr; // Instruction pointer.
83 union {
84 void* tos; // Top stack value (*sp).
85 void* external_callback_entry = nullptr;
86 };
87 void* context = nullptr; // Address of the incumbent native context.
88 void* embedder_context = nullptr; // Address of the embedder native context.
89
91 base::TimeDelta sampling_interval_; // Sampling interval used to capture.
92
93 StateTag state = OTHER; // The state of the VM.
94 EmbedderStateTag embedder_state = EmbedderStateTag::EMPTY;
95
96 uint16_t frames_count = 0; // Number of captured frames.
97 static_assert(sizeof(frames_count) * kBitsPerByte >= kMaxFramesCountLog2);
98 bool has_external_callback = false;
99 // Whether the sample should update aggregated stats.
100 bool update_stats_ = true;
101 // An identifier to associate the sample with a trace event.
102 std::optional<uint64_t> trace_id_;
103
104 void* stack[kMaxFramesCount]; // Call stack.
105};
106
107} // namespace internal
108} // namespace v8
109
110#endif // V8_PROFILER_TICK_SAMPLE_H_
constexpr int kBitsPerByte
Definition globals.h:682
StateTag
Definition v8-unwinder.h:36
@ OTHER
Definition v8-unwinder.h:42
std::optional< uint64_t > trace_id_
base::TimeDelta sampling_interval_
Definition tick-sample.h:91
base::TimeTicks timestamp
Definition tick-sample.h:90
#define V8_EXPORT
Definition v8config.h:800