v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
unwinding-info-win64.h
Go to the documentation of this file.
1// Copyright 2019 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_DIAGNOSTICS_UNWINDING_INFO_WIN64_H_
6#define V8_DIAGNOSTICS_UNWINDING_INFO_WIN64_H_
7
8#include <vector>
9
11#include "include/v8config.h"
12#include "src/common/globals.h"
13
14#if defined(V8_OS_WIN64)
16
17namespace v8 {
18namespace internal {
19
20namespace win64_unwindinfo {
21
22#define CRASH_HANDLER_FUNCTION_NAME CrashForExceptionInNonABICompliantCodeRange
23#define CRASH_HANDLER_FUNCTION_NAME_STRING \
24 "CrashForExceptionInNonABICompliantCodeRange"
25
26static const int kOSPageSize = 4096;
27
34
44
49 v8::UnhandledExceptionCallback unhandled_exception_callback);
50
51void RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes);
53
62static const uint32_t kDefaultRuntimeFunctionCount = 1;
63
64#if defined(V8_OS_WIN_X64)
65
66static const int kPushRbpInstructionLength = 1;
67static const int kMovRbpRspInstructionLength = 3;
68static const int kRbpPrefixCodes = 2;
69static const int kRbpPrefixLength =
70 kPushRbpInstructionLength + kMovRbpRspInstructionLength;
71
76std::vector<uint8_t> GetUnwindInfoForBuiltinFunctions();
77
78class BuiltinUnwindInfo {
79 public:
80 BuiltinUnwindInfo() : is_leaf_function_(true) {}
81 explicit BuiltinUnwindInfo(const std::vector<int>& fp_offsets)
82 : is_leaf_function_(false), fp_offsets_(fp_offsets) {}
83
84 bool is_leaf_function() const { return is_leaf_function_; }
85 const std::vector<int>& fp_offsets() const { return fp_offsets_; }
86
87 private:
88 bool is_leaf_function_;
89 std::vector<int> fp_offsets_;
90};
91
92class XdataEncoder {
93 public:
94 explicit XdataEncoder(const Assembler& assembler)
95 : assembler_(assembler), current_frame_code_offset_(-1) {}
96
97 void onPushRbp();
98 void onMovRbpRsp();
99
100 BuiltinUnwindInfo unwinding_info() const {
101 return BuiltinUnwindInfo(fp_offsets_);
102 }
103
104 private:
105 const Assembler& assembler_;
106 std::vector<int> fp_offsets_;
107 int current_frame_code_offset_;
108};
109
110#elif defined(V8_OS_WIN_ARM64)
111
117static const int kMaxFunctionLength = ((1 << 18) - 1) << 2;
118
119struct FrameOffsets {
120 FrameOffsets();
121 bool IsDefault() const;
122 int fp_to_saved_caller_fp;
123 int fp_to_caller_sp;
124};
125
135std::vector<uint8_t> GetUnwindInfoForBuiltinFunction(
136 uint32_t func_len, FrameOffsets fp_adjustment);
137class BuiltinUnwindInfo {
138 public:
139 BuiltinUnwindInfo() : is_leaf_function_(true) {}
140 explicit BuiltinUnwindInfo(const std::vector<int>& fp_offsets,
141 const std::vector<FrameOffsets>& fp_adjustments)
142 : is_leaf_function_(false),
143 fp_offsets_(fp_offsets),
144 fp_adjustments_(fp_adjustments) {}
145
146 const std::vector<FrameOffsets>& fp_adjustments() const {
147 return fp_adjustments_;
148 }
149
150 bool is_leaf_function() const { return is_leaf_function_; }
151 const std::vector<int>& fp_offsets() const { return fp_offsets_; }
152
153 private:
154 bool is_leaf_function_;
155 std::vector<int> fp_offsets_;
156 std::vector<FrameOffsets> fp_adjustments_;
157};
158
159class XdataEncoder {
160 public:
161 explicit XdataEncoder(const Assembler& assembler)
162 : assembler_(assembler), current_frame_code_offset_(-1) {}
163
164 void onSaveFpLr();
165 void onFramePointerAdjustment(int fp_to_saved_caller_fp, int fp_to_caller_sp);
166
167 BuiltinUnwindInfo unwinding_info() const {
168 return BuiltinUnwindInfo(fp_offsets_, fp_adjustments_);
169 }
170
171 private:
172 const Assembler& assembler_;
173 std::vector<int> fp_offsets_;
174 int current_frame_code_offset_;
175 FrameOffsets current_frame_adjustment_;
176 std::vector<FrameOffsets> fp_adjustments_;
177};
178
179#endif
180
181} // namespace win64_unwindinfo
182} // namespace internal
183} // namespace v8
184
185#endif // V8_OS_WIN64
186
187#endif // V8_DIAGNOSTICS_UNWINDING_INFO_WIN64_H_
int start
BytecodeAssembler & assembler_
void RegisterNonABICompliantCodeRange(void *start, size_t size_in_bytes)
void UnregisterNonABICompliantCodeRange(void *start)
void SetUnhandledExceptionCallback(v8::UnhandledExceptionCallback unhandled_exception_callback)