Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qv4functiontable_win64.cpp
Go to the documentation of this file.
1
// Copyright (C) 2018 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
include
"qv4functiontable_p.h"
6
7
#
include
<
assembler
/
MacroAssemblerCodeRef
.
h
>
8
9
#
include
<
QtCore
/
qdebug
.
h
>
10
11
#
include
<
qt_windows
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
namespace
QV4
{
16
17
enum
UnwindOpcode
:
UINT8
18
{
19
UWOP_PUSH_NONVOL
= 0,
/* info == register number */
20
UWOP_ALLOC_LARGE
,
/* no info, alloc size in next 2 slots */
21
UWOP_ALLOC_SMALL
,
/* info == size of allocation / 8 - 1 */
22
UWOP_SET_FPREG
,
/* no info, FP = RSP + UNWIND_INFO.FPRegOffset*16 */
23
UWOP_SAVE_NONVOL
,
/* info == register number, offset in next slot */
24
UWOP_SAVE_NONVOL_FAR
,
/* info == register number, offset in next 2 slots */
25
UWOP_SAVE_XMM128
= 8,
/* info == XMM reg number, offset in next slot */
26
UWOP_SAVE_XMM128_FAR
,
/* info == XMM reg number, offset in next 2 slots */
27
UWOP_PUSH_MACHFRAME
/* info == 0: no error-code, 1: error-code */
28
};
29
30
enum
Register
:
UINT8
31
{
32
RAX
= 0,
33
RCX
,
34
RDX
,
35
RBX
,
36
RSP
,
37
RBP
,
38
RSI
,
39
RDI
,
40
NONE
= 15
41
};
42
43
struct
UnwindCode
44
{
45
UnwindCode
(UINT8 offset,
UnwindOpcode
operation,
Register
info)
46
:
offset
(
offset
),
operation
(
operation
),
info
(
info
)
47
{}
48
49
UINT8
offset
;
50
UINT8
operation
: 4;
51
UINT8
info
: 4;
52
};
53
54
struct
UnwindInfo
55
{
56
UINT8
Version
: 3;
57
UINT8
Flags
: 5;
58
UINT8
SizeOfProlog
;
59
UINT8
CountOfUnwindCodes
;
60
UINT8
FrameRegister
: 4;
61
UINT8
FrameRegisterOffset
: 4;
62
UnwindCode
UnwindCodes
[2];
63
};
64
65
struct
ExceptionHandlerRecord
66
{
67
RUNTIME_FUNCTION
handler
;
68
UnwindInfo
info
;
69
};
70
71
void
generateFunctionTable
(Function *, JSC::MacroAssemblerCodeRef *codeRef)
72
{
73
ExceptionHandlerRecord
*record =
reinterpret_cast
<
ExceptionHandlerRecord
*>(
74
codeRef->executableMemory()->exceptionHandlerStart());
75
76
record->info.Version = 1;
77
record->info.Flags = 0;
78
record->info.SizeOfProlog = 4;
79
record->info.CountOfUnwindCodes = 2;
80
record->info.FrameRegister =
RBP
;
81
record->info.FrameRegisterOffset = 0;
82
83
// Push frame pointer
84
record->info.UnwindCodes[1] = UnwindCode(1,
UWOP_PUSH_NONVOL
,
RBP
);
85
// Set frame pointer from stack pointer
86
record->info.UnwindCodes[0] = UnwindCode(4,
UWOP_SET_FPREG
,
NONE
);
87
88
const
quintptr codeStart = quintptr(codeRef->code().executableAddress());
89
const
quintptr codeSize = codeRef->size();
90
91
record->handler.BeginAddress = DWORD(codeStart - quintptr(record));
92
record->handler.EndAddress = DWORD(codeStart + codeSize - quintptr(record));
93
record->handler.UnwindData = offsetof(ExceptionHandlerRecord, info);
94
95
if
(!RtlAddFunctionTable(&record->handler, 1, DWORD64(record))) {
96
const
unsigned
int
errorCode = GetLastError();
97
qWarning() <<
"Failed to install win64 unwind hook. Error code:"
<< errorCode;
98
}
99
}
100
101
void
destroyFunctionTable
(Function *, JSC::MacroAssemblerCodeRef *codeRef)
102
{
103
ExceptionHandlerRecord
*record =
reinterpret_cast
<
ExceptionHandlerRecord
*>(
104
codeRef->executableMemory()->exceptionHandlerStart());
105
if
(!RtlDeleteFunctionTable(&record->handler)) {
106
const
unsigned
int
errorCode = GetLastError();
107
qWarning() <<
"Failed to remove win64 unwind hook. Error code:"
<< errorCode;
108
}
109
}
110
111
size_t
exceptionHandlerSize
()
112
{
113
return
sizeof
(
ExceptionHandlerRecord
);
114
}
115
116
}
// QV4
117
118
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QV4
Definition
qjsvalue.h:24
QV4::UnwindOpcode
UnwindOpcode
Definition
qv4functiontable_win64.cpp:18
QV4::UWOP_SAVE_NONVOL_FAR
@ UWOP_SAVE_NONVOL_FAR
Definition
qv4functiontable_win64.cpp:24
QV4::UWOP_SAVE_XMM128_FAR
@ UWOP_SAVE_XMM128_FAR
Definition
qv4functiontable_win64.cpp:26
QV4::UWOP_ALLOC_LARGE
@ UWOP_ALLOC_LARGE
Definition
qv4functiontable_win64.cpp:20
QV4::UWOP_PUSH_MACHFRAME
@ UWOP_PUSH_MACHFRAME
Definition
qv4functiontable_win64.cpp:27
QV4::UWOP_PUSH_NONVOL
@ UWOP_PUSH_NONVOL
Definition
qv4functiontable_win64.cpp:19
QV4::UWOP_SET_FPREG
@ UWOP_SET_FPREG
Definition
qv4functiontable_win64.cpp:22
QV4::UWOP_SAVE_NONVOL
@ UWOP_SAVE_NONVOL
Definition
qv4functiontable_win64.cpp:23
QV4::UWOP_ALLOC_SMALL
@ UWOP_ALLOC_SMALL
Definition
qv4functiontable_win64.cpp:21
QV4::UWOP_SAVE_XMM128
@ UWOP_SAVE_XMM128
Definition
qv4functiontable_win64.cpp:25
QV4::exceptionHandlerSize
size_t exceptionHandlerSize()
Definition
qv4functiontable_noop.cpp:23
QV4::generateFunctionTable
void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
Definition
qv4functiontable_noop.cpp:11
QV4::destroyFunctionTable
void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
Definition
qv4functiontable_noop.cpp:17
QV4::Register
Register
Definition
qv4functiontable_win64.cpp:31
QV4::RDX
@ RDX
Definition
qv4functiontable_win64.cpp:34
QV4::RBP
@ RBP
Definition
qv4functiontable_win64.cpp:37
QV4::RBX
@ RBX
Definition
qv4functiontable_win64.cpp:35
QV4::NONE
@ NONE
Definition
qv4functiontable_win64.cpp:40
QV4::RSP
@ RSP
Definition
qv4functiontable_win64.cpp:36
QV4::RSI
@ RSI
Definition
qv4functiontable_win64.cpp:38
QV4::RAX
@ RAX
Definition
qv4functiontable_win64.cpp:32
QV4::RDI
@ RDI
Definition
qv4functiontable_win64.cpp:39
QV4::RCX
@ RCX
Definition
qv4functiontable_win64.cpp:33
QV4::ExceptionHandlerRecord
Definition
qv4functiontable_win64.cpp:66
QV4::ExceptionHandlerRecord::handler
RUNTIME_FUNCTION handler
Definition
qv4functiontable_win64.cpp:67
QV4::ExceptionHandlerRecord::info
UnwindInfo info
Definition
qv4functiontable_win64.cpp:68
QV4::UnwindCode
Definition
qv4functiontable_win64.cpp:44
QV4::UnwindCode::info
UINT8 info
Definition
qv4functiontable_win64.cpp:51
QV4::UnwindCode::UnwindCode
UnwindCode(UINT8 offset, UnwindOpcode operation, Register info)
Definition
qv4functiontable_win64.cpp:45
QV4::UnwindCode::operation
UINT8 operation
Definition
qv4functiontable_win64.cpp:50
QV4::UnwindCode::offset
UINT8 offset
Definition
qv4functiontable_win64.cpp:49
QV4::UnwindInfo
Definition
qv4functiontable_win64.cpp:55
QV4::UnwindInfo::Flags
UINT8 Flags
Definition
qv4functiontable_win64.cpp:57
QV4::UnwindInfo::UnwindCodes
UnwindCode UnwindCodes[2]
Definition
qv4functiontable_win64.cpp:62
QV4::UnwindInfo::Version
UINT8 Version
Definition
qv4functiontable_win64.cpp:56
QV4::UnwindInfo::SizeOfProlog
UINT8 SizeOfProlog
Definition
qv4functiontable_win64.cpp:58
QV4::UnwindInfo::FrameRegisterOffset
UINT8 FrameRegisterOffset
Definition
qv4functiontable_win64.cpp:61
QV4::UnwindInfo::FrameRegister
UINT8 FrameRegister
Definition
qv4functiontable_win64.cpp:60
QV4::UnwindInfo::CountOfUnwindCodes
UINT8 CountOfUnwindCodes
Definition
qv4functiontable_win64.cpp:59
qtdeclarative
src
qml
jsruntime
qv4functiontable_win64.cpp
Generated on
for Qt by
1.18.0