v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
code-trace-context.h
Go to the documentation of this file.
1// Copyright 2024 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_TRACING_CODE_TRACE_CONTEXT_H_
6#define V8_TRACING_CODE_TRACE_CONTEXT_H_
7
8#include <string>
9
10#include "protos/perfetto/trace/chrome/v8.pbzero.h"
12#include "src/objects/tagged.h"
14
15namespace v8 {
16namespace internal {
17
18class Isolate;
19class Script;
20class SharedFunctionInfo;
21
22#if V8_ENABLE_WEBASSEMBLY
23namespace wasm {
24class NativeModule;
25}
26#endif // V8_ENABLE_WEBASSEMBLY
27
28// Helper class to write V8 related trace packets.
29// Used to intern various types and to set common trace proto fields.
31 public:
32 CodeTraceContext(CodeDataSource::TraceContext::TracePacketHandle trace_packet,
33 CodeDataSourceIncrementalState* incremental_state)
34 : trace_packet_(std::move(trace_packet)),
35 incremental_state_(*incremental_state) {}
36
38
41 incremental_state_.FlushInternedData(trace_packet_);
42 }
43 }
44
45 uint64_t InternIsolate(Isolate& isolate) {
46 return incremental_state_.InternIsolate(isolate);
47 }
48
49 uint64_t InternJsScript(Isolate& isolate, Tagged<Script> script) {
50 return incremental_state_.InternJsScript(isolate, script);
51 }
52
53 uint64_t InternJsFunction(Isolate& isolate,
55 uint64_t v8_js_script_iid, int line_num,
56 int column_num) {
57 return incremental_state_.InternJsFunction(isolate, info, v8_js_script_iid,
58 line_num, column_num);
59 }
60
61#if V8_ENABLE_WEBASSEMBLY
62 uint64_t InternWasmScript(Isolate& isolate, int script_id,
63 const std::string& url,
64 wasm::NativeModule* native_module) {
65 return incremental_state_.InternWasmScript(isolate, script_id, url,
66 native_module);
67 }
68#endif // V8_ENABLE_WEBASSEMBLY
69
70 perfetto::protos::pbzero::V8JsCode* set_v8_js_code() {
71 return trace_packet_->set_v8_js_code();
72 }
73
74 perfetto::protos::pbzero::V8InternalCode* set_v8_internal_code() {
75 return trace_packet_->set_v8_internal_code();
76 }
77
78 perfetto::protos::pbzero::V8WasmCode* set_v8_wasm_code() {
79 return trace_packet_->set_v8_wasm_code();
80 }
81
82 perfetto::protos::pbzero::V8RegExpCode* set_v8_reg_exp_code() {
83 return trace_packet_->set_v8_reg_exp_code();
84 }
85
86 perfetto::protos::pbzero::V8CodeMove* set_code_move() {
87 return trace_packet_->set_v8_code_move();
88 }
89
93
94 bool log_instructions() const {
96 }
97
98 private:
99 CodeDataSource::TraceContext::TracePacketHandle trace_packet_;
101};
102
103} // namespace internal
104} // namespace v8
105
106#endif // V8_TRACING_CODE_TRACE_CONTEXT_H_
uint64_t InternJsScript(Isolate &isolate, Tagged< Script > script)
uint64_t InternJsFunction(Isolate &isolate, DirectHandle< SharedFunctionInfo > info, uint64_t v8_js_script_iid, int line_num, int column_num)
CodeTraceContext(CodeTraceContext &&) V8_NOEXCEPT=default
perfetto::protos::pbzero::V8JsCode * set_v8_js_code()
uint64_t InternJsScript(Isolate &isolate, Tagged< Script > script)
CodeTraceContext(CodeDataSource::TraceContext::TracePacketHandle trace_packet, CodeDataSourceIncrementalState *incremental_state)
perfetto::protos::pbzero::V8CodeMove * set_code_move()
perfetto::protos::pbzero::V8WasmCode * set_v8_wasm_code()
CodeDataSourceIncrementalState & incremental_state_
perfetto::protos::pbzero::V8RegExpCode * set_v8_reg_exp_code()
uint64_t InternIsolate(Isolate &isolate)
perfetto::protos::pbzero::V8InternalCode * set_v8_internal_code()
CodeDataSource::TraceContext::TracePacketHandle trace_packet_
uint64_t InternJsFunction(Isolate &isolate, DirectHandle< SharedFunctionInfo > info, uint64_t v8_js_script_iid, int line_num, int column_num)
STL namespace.
Definition c-api.cc:87
#define V8_NOEXCEPT
#define V8_UNLIKELY(condition)
Definition v8config.h:660