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
13namespace 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.
17struct CalleeSavedRegisters;
18
19// A RegisterState represents the current state of registers used
20// by the sampling profiler API.
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// LINT.IfChange
37enum StateTag : uint16_t {
49};
50// LINT.ThenChange(../tools/profile.mjs, ../tools/tickprocessor.mjs)
51
52constexpr bool IsExternal(StateTag state) {
53 return state == EXTERNAL || state == IDLE_EXTERNAL;
54}
55
56constexpr bool IsIdle(StateTag state) {
57 return state == IDLE || state == IDLE_EXTERNAL;
58}
59
60// The output structure filled up by GetStackSample API function.
61struct SampleInfo {
62 size_t frames_count; // Number of frames collected.
63 void* external_callback_entry; // External callback address if VM is
64 // executing an external callback.
65 void* context; // Incumbent native context address.
66 void* embedder_context; // Native context address for embedder state
67 StateTag vm_state; // Current VM state.
68 EmbedderStateTag embedder_state; // Current Embedder state
69};
70
72 const void* start = nullptr;
73 size_t length_in_bytes = 0;
74};
75
78};
79
84};
85
92 public:
123 static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
124 size_t code_pages_length,
125 const MemoryRange* code_pages,
126 RegisterState* register_state,
127 const void* stack_base);
128
138 static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
139 void* pc);
140};
141
142} // namespace v8
143
144#endif // INCLUDE_V8_UNWINDER_H_
Definition: v8-unwinder.h:91
static bool PCIsInV8(size_t code_pages_length, const MemoryRange *code_pages, void *pc)
static bool TryUnwindV8Frames(const JSEntryStubs &entry_stubs, size_t code_pages_length, const MemoryRange *code_pages, RegisterState *register_state, const void *stack_base)
Definition: libplatform.h:15
EmbedderStateTag
Definition: v8-embedder-state-scope.h:22
constexpr bool IsExternal(StateTag state)
Definition: v8-unwinder.h:52
constexpr bool IsIdle(StateTag state)
Definition: v8-unwinder.h:56
StateTag
Definition: v8-unwinder.h:37
@ IDLE_EXTERNAL
Definition: v8-unwinder.h:47
@ COMPILER
Definition: v8-unwinder.h:42
@ BYTECODE_COMPILER
Definition: v8-unwinder.h:41
@ EXTERNAL
Definition: v8-unwinder.h:44
@ GC
Definition: v8-unwinder.h:39
@ ATOMICS_WAIT
Definition: v8-unwinder.h:45
@ PARSER
Definition: v8-unwinder.h:40
@ LOGGING
Definition: v8-unwinder.h:48
@ IDLE
Definition: v8-unwinder.h:46
@ JS
Definition: v8-unwinder.h:38
@ OTHER
Definition: v8-unwinder.h:43
Definition: v8-unwinder.h:76
MemoryRange code
Definition: v8-unwinder.h:77
Definition: v8-unwinder.h:80
JSEntryStub js_entry_stub
Definition: v8-unwinder.h:81
JSEntryStub js_construct_entry_stub
Definition: v8-unwinder.h:82
JSEntryStub js_run_microtasks_entry_stub
Definition: v8-unwinder.h:83
Definition: v8-unwinder.h:71
size_t length_in_bytes
Definition: v8-unwinder.h:73
const void * start
Definition: v8-unwinder.h:72
Definition: v8-unwinder.h:21
RegisterState(const RegisterState &other)
void * lr
Definition: v8-unwinder.h:30
RegisterState & operator=(const RegisterState &other)
void * sp
Definition: v8-unwinder.h:28
void * pc
Definition: v8-unwinder.h:27
void * fp
Definition: v8-unwinder.h:29
std::unique_ptr< CalleeSavedRegisters > callee_saved
Definition: v8-unwinder.h:32
Definition: v8-unwinder.h:61
void * context
Definition: v8-unwinder.h:65
EmbedderStateTag embedder_state
Definition: v8-unwinder.h:68
void * embedder_context
Definition: v8-unwinder.h:66
size_t frames_count
Definition: v8-unwinder.h:62
void * external_callback_entry
Definition: v8-unwinder.h:63
StateTag vm_state
Definition: v8-unwinder.h:67
#define V8_EXPORT
Definition: v8config.h:860