v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8-unwinder.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 INCLUDE_V8_UNWINDER_H_
6
#define INCLUDE_V8_UNWINDER_H_
7
8
#include <memory>
9
10
#include "
v8-embedder-state-scope.h
"
// NOLINT(build/include_directory)
11
#include "
v8config.h
"
// NOLINT(build/include_directory)
12
13
namespace
v8
{
14
// Holds the callee saved registers needed for the stack unwinder. It is the
15
// empty struct if no registers are required. Implemented in
16
// include/v8-unwinder-state.h.
17
struct
CalleeSavedRegisters;
18
19
// A RegisterState represents the current state of registers used
20
// by the sampling profiler API.
21
struct
V8_EXPORT
RegisterState
{
22
RegisterState
();
23
~RegisterState
();
24
RegisterState
(
const
RegisterState
& other);
25
RegisterState
& operator=(
const
RegisterState
& other);
26
27
void
*
pc
;
// Instruction pointer.
28
void
*
sp
;
// Stack pointer.
29
void
*
fp
;
// Frame pointer.
30
void
*
lr
;
// Link register (or nullptr on platforms without a link register).
31
// Callee saved registers (or null if no callee saved registers were stored)
32
std::unique_ptr<CalleeSavedRegisters>
callee_saved
;
33
};
34
35
// A StateTag represents a possible state of the VM.
36
enum
StateTag
: uint16_t {
37
JS
,
38
GC
,
39
PARSER
,
40
BYTECODE_COMPILER
,
41
COMPILER
,
42
OTHER
,
43
EXTERNAL
,
44
ATOMICS_WAIT
,
45
IDLE
,
46
LOGGING
,
47
};
48
49
// The output structure filled up by GetStackSample API function.
50
struct
SampleInfo
{
51
size_t
frames_count
;
// Number of frames collected.
52
void
*
external_callback_entry
;
// External callback address if VM is
53
// executing an external callback.
54
void
*
context
;
// Incumbent native context address.
55
void
*
embedder_context
;
// Native context address for embedder state
56
StateTag
vm_state
;
// Current VM state.
57
EmbedderStateTag
embedder_state
;
// Current Embedder state
58
};
59
60
struct
MemoryRange
{
61
const
void
*
start
=
nullptr
;
62
size_t
length_in_bytes
= 0;
63
};
64
65
struct
JSEntryStub
{
66
MemoryRange
code
;
67
};
68
69
struct
JSEntryStubs
{
70
JSEntryStub
js_entry_stub
;
71
JSEntryStub
js_construct_entry_stub
;
72
JSEntryStub
js_run_microtasks_entry_stub
;
73
};
74
80
class
V8_EXPORT
Unwinder
{
81
public
:
112
static
bool
TryUnwindV8Frames(
const
JSEntryStubs
& entry_stubs,
113
size_t
code_pages_length,
114
const
MemoryRange
* code_pages,
115
RegisterState
* register_state,
116
const
void
* stack_base);
117
127
static
bool
PCIsInV8(
size_t
code_pages_length,
const
MemoryRange
* code_pages,
128
void
*
pc
);
129
};
130
131
}
// namespace v8
132
133
#endif
// INCLUDE_V8_UNWINDER_H_
v8::Unwinder
Definition
v8-unwinder.h:80
pc
int pc
Definition
experimental-interpreter.cc:554
v8
Definition
api-arguments-inl.h:19
v8::EmbedderStateTag
EmbedderStateTag
Definition
v8-embedder-state-scope.h:22
v8::StateTag
StateTag
Definition
v8-unwinder.h:36
v8::COMPILER
@ COMPILER
Definition
v8-unwinder.h:41
v8::BYTECODE_COMPILER
@ BYTECODE_COMPILER
Definition
v8-unwinder.h:40
v8::EXTERNAL
@ EXTERNAL
Definition
v8-unwinder.h:43
v8::GC
@ GC
Definition
v8-unwinder.h:38
v8::ATOMICS_WAIT
@ ATOMICS_WAIT
Definition
v8-unwinder.h:44
v8::PARSER
@ PARSER
Definition
v8-unwinder.h:39
v8::LOGGING
@ LOGGING
Definition
v8-unwinder.h:46
v8::IDLE
@ IDLE
Definition
v8-unwinder.h:45
v8::JS
@ JS
Definition
v8-unwinder.h:37
v8::OTHER
@ OTHER
Definition
v8-unwinder.h:42
v8::JSEntryStub
Definition
v8-unwinder.h:65
v8::JSEntryStub::code
MemoryRange code
Definition
v8-unwinder.h:66
v8::JSEntryStubs
Definition
v8-unwinder.h:69
v8::JSEntryStubs::js_entry_stub
JSEntryStub js_entry_stub
Definition
v8-unwinder.h:70
v8::JSEntryStubs::js_construct_entry_stub
JSEntryStub js_construct_entry_stub
Definition
v8-unwinder.h:71
v8::JSEntryStubs::js_run_microtasks_entry_stub
JSEntryStub js_run_microtasks_entry_stub
Definition
v8-unwinder.h:72
v8::MemoryRange
Definition
v8-unwinder.h:60
v8::MemoryRange::length_in_bytes
size_t length_in_bytes
Definition
v8-unwinder.h:62
v8::MemoryRange::start
const void * start
Definition
v8-unwinder.h:61
v8::RegisterState
Definition
v8-unwinder.h:21
v8::RegisterState::lr
void * lr
Definition
v8-unwinder.h:30
v8::RegisterState::sp
void * sp
Definition
v8-unwinder.h:28
v8::RegisterState::pc
void * pc
Definition
v8-unwinder.h:27
v8::RegisterState::fp
void * fp
Definition
v8-unwinder.h:29
v8::RegisterState::~RegisterState
~RegisterState()
v8::RegisterState::callee_saved
std::unique_ptr< CalleeSavedRegisters > callee_saved
Definition
v8-unwinder.h:32
v8::SampleInfo
Definition
v8-unwinder.h:50
v8::SampleInfo::context
void * context
Definition
v8-unwinder.h:54
v8::SampleInfo::embedder_state
EmbedderStateTag embedder_state
Definition
v8-unwinder.h:57
v8::SampleInfo::embedder_context
void * embedder_context
Definition
v8-unwinder.h:55
v8::SampleInfo::frames_count
size_t frames_count
Definition
v8-unwinder.h:51
v8::SampleInfo::external_callback_entry
void * external_callback_entry
Definition
v8-unwinder.h:52
v8::SampleInfo::vm_state
StateTag vm_state
Definition
v8-unwinder.h:56
v8-embedder-state-scope.h
v8config.h
V8_EXPORT
#define V8_EXPORT
Definition
v8config.h:800
include
v8-unwinder.h
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0