Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/assembler/LinkBuffer.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | namespace JSC { | - | ||||||
5 | - | |||||||
6 | class JSGlobalData; | - | ||||||
7 | - | |||||||
8 | template <typename T> | - | ||||||
9 | struct DefaultExecutableOffsetCalculator { | - | ||||||
10 | template <typename Assembler> | - | ||||||
11 | static T applyOffset(Assembler *, T src) { return executed 1224 times by 10 tests: src;return src; Executed by:
executed 1224 times by 10 tests: }return src; Executed by:
| 1224 | ||||||
12 | }; | - | ||||||
13 | template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator> | - | ||||||
14 | class LinkBufferBase { | - | ||||||
15 | LinkBufferBase(const LinkBufferBase &) = delete; LinkBufferBase &operator=(const LinkBufferBase &) = delete;; | - | ||||||
16 | typedef MacroAssemblerCodeRef CodeRef; | - | ||||||
17 | typedef MacroAssemblerCodePtr CodePtr; | - | ||||||
18 | typedef typename MacroAssembler::Label Label; | - | ||||||
19 | typedef typename MacroAssembler::Jump Jump; | - | ||||||
20 | typedef typename MacroAssembler::PatchableJump PatchableJump; | - | ||||||
21 | typedef typename MacroAssembler::JumpList JumpList; | - | ||||||
22 | typedef typename MacroAssembler::Call Call; | - | ||||||
23 | typedef typename MacroAssembler::DataLabelCompact DataLabelCompact; | - | ||||||
24 | typedef typename MacroAssembler::DataLabel32 DataLabel32; | - | ||||||
25 | typedef typename MacroAssembler::DataLabelPtr DataLabelPtr; | - | ||||||
26 | typedef typename MacroAssembler::ConvertibleLoadLabel ConvertibleLoadLabel; | - | ||||||
27 | - | |||||||
28 | public: | - | ||||||
29 | LinkBufferBase(JSGlobalData& globalData, MacroAssembler* masm, JITCompilationEffort effort = JITCompilationMustSucceed) | - | ||||||
30 | : m_size(0) | - | ||||||
31 | , m_code(0) | - | ||||||
32 | , m_assembler(masm) | - | ||||||
33 | , m_globalData(&globalData) | - | ||||||
34 | - | |||||||
35 | , m_completed(false) | - | ||||||
36 | , m_effort(effort) | - | ||||||
37 | - | |||||||
38 | { | - | ||||||
39 | - | |||||||
40 | - | |||||||
41 | - | |||||||
42 | - | |||||||
43 | } executed 1161222 times by 153 tests: end of block Executed by:
| 1161222 | ||||||
44 | - | |||||||
45 | ~LinkBufferBase() | - | ||||||
46 | { | - | ||||||
47 | (!(m_completed || (!m_executableMemory && m_effort == JITCompilationCanFail)) ? (qmlWTFReportAssertionFailure(__FILE__, 101, __PRETTY_FUNCTION__, "m_completed || (!m_executableMemory && m_effort == JITCompilationCanFail)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
48 | } executed 1164529 times by 153 tests: end of block Executed by:
| 1164529 | ||||||
49 | - | |||||||
50 | bool didFailToAllocate() const | - | ||||||
51 | { | - | ||||||
52 | return executed 1163931 times by 153 tests: !m_executableMemory;return !m_executableMemory; Executed by:
executed 1163931 times by 153 tests: return !m_executableMemory; Executed by:
| 1163931 | ||||||
53 | } | - | ||||||
54 | - | |||||||
55 | bool isValid() const | - | ||||||
56 | { | - | ||||||
57 | return executed 1163921 times by 153 tests: !didFailToAllocate();return !didFailToAllocate(); Executed by:
executed 1163921 times by 153 tests: return !didFailToAllocate(); Executed by:
| 1163921 | ||||||
58 | } | - | ||||||
59 | - | |||||||
60 | - | |||||||
61 | - | |||||||
62 | void link(Call call, FunctionPtr function) | - | ||||||
63 | { | - | ||||||
64 | (!(call.isFlagSet(Call::Linkable)) ? (qmlWTFReportAssertionFailure(__FILE__, 118, __PRETTY_FUNCTION__, "call.isFlagSet(Call::Linkable)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
65 | call.m_label = applyOffset(call.m_label); | - | ||||||
66 | MacroAssembler::linkCall(code(), call, function); | - | ||||||
67 | } never executed: end of block | 0 | ||||||
68 | - | |||||||
69 | void link(Jump jump, CodeLocationLabel label) | - | ||||||
70 | { | - | ||||||
71 | jump.m_label = applyOffset(jump.m_label); | - | ||||||
72 | MacroAssembler::linkJump(code(), jump, label); | - | ||||||
73 | } never executed: end of block | 0 | ||||||
74 | - | |||||||
75 | void link(JumpList list, CodeLocationLabel label) | - | ||||||
76 | { | - | ||||||
77 | for (unsigned i = 0; i < list.m_jumps.size()
| 0 | ||||||
78 | link(list.m_jumps[i], label); never executed: link(list.m_jumps[i], label); | 0 | ||||||
79 | } never executed: end of block | 0 | ||||||
80 | - | |||||||
81 | void patch(DataLabelPtr label, void* value) | - | ||||||
82 | { | - | ||||||
83 | AssemblerLabel target = applyOffset(label.m_label); | - | ||||||
84 | MacroAssembler::linkPointer(code(), target, value); | - | ||||||
85 | } never executed: end of block | 0 | ||||||
86 | - | |||||||
87 | void patch(DataLabelPtr label, CodeLocationLabel value) | - | ||||||
88 | { | - | ||||||
89 | AssemblerLabel target = applyOffset(label.m_label); | - | ||||||
90 | MacroAssembler::linkPointer(code(), target, value.executableAddress()); | - | ||||||
91 | } executed 612 times by 10 tests: end of block Executed by:
| 612 | ||||||
92 | - | |||||||
93 | - | |||||||
94 | - | |||||||
95 | CodeLocationCall locationOf(Call call) | - | ||||||
96 | { | - | ||||||
97 | (!(call.isFlagSet(Call::Linkable)) ? (qmlWTFReportAssertionFailure(__FILE__, 151, __PRETTY_FUNCTION__, "call.isFlagSet(Call::Linkable)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
98 | (!(!call.isFlagSet(Call::Near)) ? (qmlWTFReportAssertionFailure(__FILE__, 152, __PRETTY_FUNCTION__, "!call.isFlagSet(Call::Near)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
99 | return never executed: CodeLocationCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label)));return CodeLocationCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label))); never executed: return CodeLocationCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label))); | 0 | ||||||
100 | } | - | ||||||
101 | - | |||||||
102 | CodeLocationNearCall locationOfNearCall(Call call) | - | ||||||
103 | { | - | ||||||
104 | (!(call.isFlagSet(Call::Linkable)) ? (qmlWTFReportAssertionFailure(__FILE__, 158, __PRETTY_FUNCTION__, "call.isFlagSet(Call::Linkable)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
105 | (!(call.isFlagSet(Call::Near)) ? (qmlWTFReportAssertionFailure(__FILE__, 159, __PRETTY_FUNCTION__, "call.isFlagSet(Call::Near)"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
106 | return never executed: CodeLocationNearCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label)));return CodeLocationNearCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label))); never executed: return CodeLocationNearCall(MacroAssembler::getLinkerAddress(code(), applyOffset(call.m_label))); | 0 | ||||||
107 | } | - | ||||||
108 | - | |||||||
109 | CodeLocationLabel locationOf(PatchableJump jump) | - | ||||||
110 | { | - | ||||||
111 | return never executed: CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(jump.m_jump.m_label)));return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(jump.m_jump.m_label))); never executed: return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(jump.m_jump.m_label))); | 0 | ||||||
112 | } | - | ||||||
113 | - | |||||||
114 | CodeLocationLabel locationOf(Label label) | - | ||||||
115 | { | - | ||||||
116 | return executed 612 times by 10 tests: CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label)));return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); Executed by:
executed 612 times by 10 tests: return CodeLocationLabel(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); Executed by:
| 612 | ||||||
117 | } | - | ||||||
118 | - | |||||||
119 | CodeLocationDataLabelPtr locationOf(DataLabelPtr label) | - | ||||||
120 | { | - | ||||||
121 | return never executed: CodeLocationDataLabelPtr(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label)));return CodeLocationDataLabelPtr(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); never executed: return CodeLocationDataLabelPtr(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); | 0 | ||||||
122 | } | - | ||||||
123 | - | |||||||
124 | CodeLocationDataLabel32 locationOf(DataLabel32 label) | - | ||||||
125 | { | - | ||||||
126 | return never executed: CodeLocationDataLabel32(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label)));return CodeLocationDataLabel32(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); never executed: return CodeLocationDataLabel32(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); | 0 | ||||||
127 | } | - | ||||||
128 | - | |||||||
129 | CodeLocationDataLabelCompact locationOf(DataLabelCompact label) | - | ||||||
130 | { | - | ||||||
131 | return never executed: CodeLocationDataLabelCompact(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label)));return CodeLocationDataLabelCompact(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); never executed: return CodeLocationDataLabelCompact(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); | 0 | ||||||
132 | } | - | ||||||
133 | - | |||||||
134 | CodeLocationConvertibleLoad locationOf(ConvertibleLoadLabel label) | - | ||||||
135 | { | - | ||||||
136 | return never executed: CodeLocationConvertibleLoad(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label)));return CodeLocationConvertibleLoad(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); never executed: return CodeLocationConvertibleLoad(MacroAssembler::getLinkerAddress(code(), applyOffset(label.m_label))); | 0 | ||||||
137 | } | - | ||||||
138 | - | |||||||
139 | - | |||||||
140 | - | |||||||
141 | unsigned returnAddressOffset(Call call) | - | ||||||
142 | { | - | ||||||
143 | call.m_label = applyOffset(call.m_label); | - | ||||||
144 | return never executed: MacroAssembler::getLinkerCallReturnOffset(call);return MacroAssembler::getLinkerCallReturnOffset(call); never executed: return MacroAssembler::getLinkerCallReturnOffset(call); | 0 | ||||||
145 | } | - | ||||||
146 | - | |||||||
147 | uint32_t offsetOf(Label label) | - | ||||||
148 | { | - | ||||||
149 | return never executed: applyOffset(label.m_label).m_offset;return applyOffset(label.m_label).m_offset; never executed: return applyOffset(label.m_label).m_offset; | 0 | ||||||
150 | } | - | ||||||
151 | - | |||||||
152 | - | |||||||
153 | - | |||||||
154 | - | |||||||
155 | - | |||||||
156 | - | |||||||
157 | inline CodeRef finalizeCodeWithoutDisassembly(); | - | ||||||
158 | inline CodeRef finalizeCodeWithDisassembly(const char* format, ...) __attribute__((__format__(printf, 2, 3))); | - | ||||||
159 | - | |||||||
160 | CodePtr trampolineAt(Label label) | - | ||||||
161 | { | - | ||||||
162 | return never executed: CodePtr(MacroAssembler::AssemblerType_T::getRelocatedAddress(code(), applyOffset(label.m_label)));return CodePtr(MacroAssembler::AssemblerType_T::getRelocatedAddress(code(), applyOffset(label.m_label))); never executed: return CodePtr(MacroAssembler::AssemblerType_T::getRelocatedAddress(code(), applyOffset(label.m_label))); | 0 | ||||||
163 | } | - | ||||||
164 | - | |||||||
165 | void* debugAddress() | - | ||||||
166 | { | - | ||||||
167 | return never executed: m_code;return m_code; never executed: return m_code; | 0 | ||||||
168 | } | - | ||||||
169 | - | |||||||
170 | size_t debugSize() | - | ||||||
171 | { | - | ||||||
172 | return never executed: m_size;return m_size; never executed: return m_size; | 0 | ||||||
173 | } | - | ||||||
174 | - | |||||||
175 | private: | - | ||||||
176 | template <typename T> T applyOffset(T src) | - | ||||||
177 | { | - | ||||||
178 | return executed 1224 times by 10 tests: ExecutableOffsetCalculator<T>::applyOffset(m_assembler, src);return ExecutableOffsetCalculator<T>::applyOffset(m_assembler, src); Executed by:
executed 1224 times by 10 tests: return ExecutableOffsetCalculator<T>::applyOffset(m_assembler, src); Executed by:
| 1224 | ||||||
179 | } | - | ||||||
180 | - | |||||||
181 | protected: | - | ||||||
182 | - | |||||||
183 | void* code() | - | ||||||
184 | { | - | ||||||
185 | return executed 2329074 times by 153 tests: m_code;return m_code; Executed by:
executed 2329074 times by 153 tests: return m_code; Executed by:
| 2329074 | ||||||
186 | } | - | ||||||
187 | - | |||||||
188 | inline void linkCode(void* ownerUID, JITCompilationEffort); | - | ||||||
189 | - | |||||||
190 | inline void performFinalization(); | - | ||||||
191 | RefPtr<ExecutableMemoryHandle> m_executableMemory; | - | ||||||
192 | size_t m_size; | - | ||||||
193 | void* m_code; | - | ||||||
194 | MacroAssembler* m_assembler; | - | ||||||
195 | JSGlobalData* m_globalData; | - | ||||||
196 | protected: | - | ||||||
197 | - | |||||||
198 | bool m_completed; | - | ||||||
199 | JITCompilationEffort m_effort; | - | ||||||
200 | - | |||||||
201 | }; | - | ||||||
202 | template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator> | - | ||||||
203 | inline typename LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::CodeRef LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::finalizeCodeWithoutDisassembly() | - | ||||||
204 | { | - | ||||||
205 | performFinalization(); | - | ||||||
206 | - | |||||||
207 | return executed 1164557 times by 153 tests: CodeRef(m_executableMemory);return CodeRef(m_executableMemory); Executed by:
executed 1164557 times by 153 tests: return CodeRef(m_executableMemory); Executed by:
| 1164557 | ||||||
208 | } | - | ||||||
209 | - | |||||||
210 | template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator> | - | ||||||
211 | inline typename LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::CodeRef LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::finalizeCodeWithDisassembly(const char* format, ...) | - | ||||||
212 | { | - | ||||||
213 | (!(Options::showDisassembly() || Options::showDFGDisassembly()) ? (qmlWTFReportAssertionFailure(__FILE__, 305, __PRETTY_FUNCTION__, "Options::showDisassembly() || Options::showDFGDisassembly()"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
214 | - | |||||||
215 | CodeRef result = finalizeCodeWithoutDisassembly(); | - | ||||||
216 | - | |||||||
217 | dataLogF("Generated JIT code for "); | - | ||||||
218 | va_list argList; | - | ||||||
219 | - | |||||||
220 | __builtin_va_start( | - | ||||||
221 | argList | - | ||||||
222 | , | - | ||||||
223 | format | - | ||||||
224 | ) | - | ||||||
225 | ; | - | ||||||
226 | WTF::dataLogFV(format, argList); | - | ||||||
227 | - | |||||||
228 | __builtin_va_end( | - | ||||||
229 | argList | - | ||||||
230 | ) | - | ||||||
231 | ; | - | ||||||
232 | dataLogF(":\n"); | - | ||||||
233 | - | |||||||
234 | dataLogF( | - | ||||||
235 | - | |||||||
236 | - | |||||||
237 | - | |||||||
238 | " Code at [%p, %p):\n", | - | ||||||
239 | - | |||||||
240 | result.code().executableAddress(), static_cast<char*>(result.code().executableAddress()) + result.size()); | - | ||||||
241 | disassemble(result.code(), m_size, " ", WTF::dataFile()); | - | ||||||
242 | - | |||||||
243 | return never executed: result;return result; never executed: return result; | 0 | ||||||
244 | } | - | ||||||
245 | - | |||||||
246 | template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator> | - | ||||||
247 | inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::linkCode(void* ownerUID, JITCompilationEffort effort) | - | ||||||
248 | { | - | ||||||
249 | (void)ownerUID; | - | ||||||
250 | (void)effort; | - | ||||||
251 | (!(!m_code) ? (qmlWTFReportAssertionFailure(__FILE__, 333, __PRETTY_FUNCTION__, "!m_code"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
252 | m_executableMemory = m_assembler->m_assembler.executableCopy(*m_globalData, ownerUID, effort); | - | ||||||
253 | if (!m_executableMemory
| 0-1163911 | ||||||
254 | return; never executed: return; | 0 | ||||||
255 | m_code = m_executableMemory->start(); | - | ||||||
256 | m_size = m_assembler->m_assembler.codeSize(); | - | ||||||
257 | (!(m_code) ? (qmlWTFReportAssertionFailure(__FILE__, 339, __PRETTY_FUNCTION__, "m_code"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
258 | } executed 1163909 times by 153 tests: end of block Executed by:
| 1163909 | ||||||
259 | - | |||||||
260 | template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator> | - | ||||||
261 | inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::performFinalization() | - | ||||||
262 | { | - | ||||||
263 | - | |||||||
264 | - | |||||||
265 | (!(!m_completed) ? (qmlWTFReportAssertionFailure(__FILE__, 347, __PRETTY_FUNCTION__, "!m_completed"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
266 | (!(isValid()) ? (qmlWTFReportAssertionFailure(__FILE__, 348, __PRETTY_FUNCTION__, "isValid()"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
267 | m_completed = true; | - | ||||||
268 | - | |||||||
269 | - | |||||||
270 | (!(m_size <= 0x7fffffff) ? (qmlWTFReportAssertionFailure(__FILE__, 352, __PRETTY_FUNCTION__, "m_size <= INT_MAX"), (qmlWTFReportBacktrace(), qmlWTFInvokeCrashHook(), (*(int *)(uintptr_t)0xbbadbeef = 0), __builtin_trap())) : (void)0); | - | ||||||
271 | MacroAssembler::cacheFlush(code(), m_size); | - | ||||||
272 | ExecutableAllocator::makeExecutable(code(), static_cast<int>(m_size)); | - | ||||||
273 | } executed 1164580 times by 153 tests: end of block Executed by:
| 1164580 | ||||||
274 | - | |||||||
275 | template <typename MacroAssembler> | - | ||||||
276 | class LinkBuffer : public LinkBufferBase<MacroAssembler, DefaultExecutableOffsetCalculator> | - | ||||||
277 | { | - | ||||||
278 | public: | - | ||||||
279 | LinkBuffer(JSGlobalData& globalData, MacroAssembler* masm, void* ownerUID, JITCompilationEffort effort = JITCompilationMustSucceed) | - | ||||||
280 | : LinkBufferBase<MacroAssembler, DefaultExecutableOffsetCalculator>(globalData, masm, effort) | - | ||||||
281 | { | - | ||||||
282 | this->linkCode(ownerUID, effort); | - | ||||||
283 | } executed 1163976 times by 153 tests: end of block Executed by:
| 1163976 | ||||||
284 | }; | - | ||||||
285 | } | - | ||||||
Switch to Source code | Preprocessed file |