5#ifndef V8_DIAGNOSTICS_UNWINDING_INFO_WIN64_H_
6#define V8_DIAGNOSTICS_UNWINDING_INFO_WIN64_H_
14#if defined(V8_OS_WIN64)
20namespace win64_unwindinfo {
22#define CRASH_HANDLER_FUNCTION_NAME CrashForExceptionInNonABICompliantCodeRange
23#define CRASH_HANDLER_FUNCTION_NAME_STRING \
24 "CrashForExceptionInNonABICompliantCodeRange"
26static const int kOSPageSize = 4096;
49 v8::UnhandledExceptionCallback unhandled_exception_callback);
62static const uint32_t kDefaultRuntimeFunctionCount = 1;
64#if defined(V8_OS_WIN_X64)
66static const int kPushRbpInstructionLength = 1;
67static const int kMovRbpRspInstructionLength = 3;
68static const int kRbpPrefixCodes = 2;
69static const int kRbpPrefixLength =
70 kPushRbpInstructionLength + kMovRbpRspInstructionLength;
76std::vector<uint8_t> GetUnwindInfoForBuiltinFunctions();
78class BuiltinUnwindInfo {
80 BuiltinUnwindInfo() : is_leaf_function_(true) {}
81 explicit BuiltinUnwindInfo(
const std::vector<int>& fp_offsets)
82 : is_leaf_function_(false), fp_offsets_(fp_offsets) {}
84 bool is_leaf_function()
const {
return is_leaf_function_; }
85 const std::vector<int>& fp_offsets()
const {
return fp_offsets_; }
88 bool is_leaf_function_;
89 std::vector<int> fp_offsets_;
94 explicit XdataEncoder(
const Assembler& assembler)
95 :
assembler_(assembler), current_frame_code_offset_(-1) {}
100 BuiltinUnwindInfo unwinding_info()
const {
101 return BuiltinUnwindInfo(fp_offsets_);
106 std::vector<int> fp_offsets_;
107 int current_frame_code_offset_;
110#elif defined(V8_OS_WIN_ARM64)
117static const int kMaxFunctionLength = ((1 << 18) - 1) << 2;
121 bool IsDefault()
const;
122 int fp_to_saved_caller_fp;
135std::vector<uint8_t> GetUnwindInfoForBuiltinFunction(
136 uint32_t func_len, FrameOffsets fp_adjustment);
137class BuiltinUnwindInfo {
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) {}
146 const std::vector<FrameOffsets>& fp_adjustments()
const {
147 return fp_adjustments_;
150 bool is_leaf_function()
const {
return is_leaf_function_; }
151 const std::vector<int>& fp_offsets()
const {
return fp_offsets_; }
154 bool is_leaf_function_;
155 std::vector<int> fp_offsets_;
156 std::vector<FrameOffsets> fp_adjustments_;
161 explicit XdataEncoder(
const Assembler& assembler)
162 :
assembler_(assembler), current_frame_code_offset_(-1) {}
165 void onFramePointerAdjustment(
int fp_to_saved_caller_fp,
int fp_to_caller_sp);
167 BuiltinUnwindInfo unwinding_info()
const {
168 return BuiltinUnwindInfo(fp_offsets_, fp_adjustments_);
173 std::vector<int> fp_offsets_;
174 int current_frame_code_offset_;
175 FrameOffsets current_frame_adjustment_;
176 std::vector<FrameOffsets> fp_adjustments_;
BytecodeAssembler & assembler_
bool CanEmitUnwindInfoForBuiltins()
void RegisterNonABICompliantCodeRange(void *start, size_t size_in_bytes)
bool CanRegisterUnwindInfoForNonABICompliantCodeRange()
void UnregisterNonABICompliantCodeRange(void *start)
void SetUnhandledExceptionCallback(v8::UnhandledExceptionCallback unhandled_exception_callback)