Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4global_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #ifndef QV4GLOBAL_H | - | ||||||
41 | #define QV4GLOBAL_H | - | ||||||
42 | - | |||||||
43 | // | - | ||||||
44 | // W A R N I N G | - | ||||||
45 | // ------------- | - | ||||||
46 | // | - | ||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
48 | // implementation detail. This header file may change from version to | - | ||||||
49 | // version without notice, or even be removed. | - | ||||||
50 | // | - | ||||||
51 | // We mean it. | - | ||||||
52 | // | - | ||||||
53 | - | |||||||
54 | #include <QtCore/qglobal.h> | - | ||||||
55 | #include <QString> | - | ||||||
56 | - | |||||||
57 | #ifdef QT_NO_DEBUG | - | ||||||
58 | #define QML_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE | - | ||||||
59 | #else | - | ||||||
60 | #define QML_NEARLY_ALWAYS_INLINE inline | - | ||||||
61 | #endif | - | ||||||
62 | - | |||||||
63 | #include <qtqmlglobal.h> | - | ||||||
64 | #include <private/qtqmlglobal_p.h> | - | ||||||
65 | - | |||||||
66 | #ifdef QT_QML_BOOTSTRAPPED | - | ||||||
67 | #define V4_BOOTSTRAP | - | ||||||
68 | #endif | - | ||||||
69 | - | |||||||
70 | #if defined(Q_CC_MSVC) | - | ||||||
71 | #include <float.h> | - | ||||||
72 | #include <math.h> | - | ||||||
73 | - | |||||||
74 | namespace std { | - | ||||||
75 | - | |||||||
76 | inline bool isinf(double d) { return !_finite(d) && !_isnan(d); } | - | ||||||
77 | inline bool isnan(double d) { return !!_isnan(d); } | - | ||||||
78 | inline bool isfinite(double d) { return _finite(d); } | - | ||||||
79 | - | |||||||
80 | } // namespace std | - | ||||||
81 | - | |||||||
82 | inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } | - | ||||||
83 | #endif | - | ||||||
84 | - | |||||||
85 | // Decide whether to enable or disable the JIT | - | ||||||
86 | - | |||||||
87 | // White list architectures | - | ||||||
88 | // | - | ||||||
89 | // NOTE: This should match the logic in qv4targetplatform_p.h! | - | ||||||
90 | - | |||||||
91 | #if defined(Q_PROCESSOR_X86) && (QT_POINTER_SIZE == 4) \ | - | ||||||
92 | && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD)) | - | ||||||
93 | # define V4_ENABLE_JIT | - | ||||||
94 | #elif defined(Q_PROCESSOR_X86_64) && (QT_POINTER_SIZE == 8) \ | - | ||||||
95 | && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)) | - | ||||||
96 | # define V4_ENABLE_JIT | - | ||||||
97 | #elif defined(Q_PROCESSOR_ARM_32) && (QT_POINTER_SIZE == 4) | - | ||||||
98 | # if defined(thumb2) || defined(__thumb2__) || ((defined(__thumb) || defined(__thumb__)) && __TARGET_ARCH_THUMB-0 == 4) | - | ||||||
99 | # define V4_ENABLE_JIT | - | ||||||
100 | # elif defined(__ARM_ARCH_ISA_THUMB) && __ARM_ARCH_ISA_THUMB == 2 // clang 3.5 and later will set this if the core supports the Thumb-2 ISA. | - | ||||||
101 | # define V4_ENABLE_JIT | - | ||||||
102 | # endif | - | ||||||
103 | #elif defined(Q_PROCESSOR_ARM_64) && (QT_POINTER_SIZE == 8) | - | ||||||
104 | # if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_INTEGRITY) | - | ||||||
105 | # define V4_ENABLE_JIT | - | ||||||
106 | # endif | - | ||||||
107 | //#elif defined(Q_PROCESSOR_MIPS_32) && defined(Q_OS_LINUX) | - | ||||||
108 | //# define V4_ENABLE_JIT | - | ||||||
109 | #endif | - | ||||||
110 | - | |||||||
111 | // check FPU with double precision on ARM platform | - | ||||||
112 | #if (defined(Q_PROCESSOR_ARM_64) || defined(Q_PROCESSOR_ARM_32)) && defined(V4_ENABLE_JIT) && defined(__ARM_FP) && (__ARM_FP <= 0x04) | - | ||||||
113 | # undef V4_ENABLE_JIT | - | ||||||
114 | #endif | - | ||||||
115 | - | |||||||
116 | // Black list some platforms | - | ||||||
117 | #if defined(V4_ENABLE_JIT) | - | ||||||
118 | #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) | - | ||||||
119 | # undef V4_ENABLE_JIT | - | ||||||
120 | #endif | - | ||||||
121 | #endif | - | ||||||
122 | - | |||||||
123 | // For debug purposes: add CONFIG+=force-compile-jit to qmake's command-line to always compile the JIT. | - | ||||||
124 | #if defined(V4_FORCE_COMPILE_JIT) && !defined(V4_ENABLE_JIT) | - | ||||||
125 | # define V4_ENABLE_JIT | - | ||||||
126 | #endif | - | ||||||
127 | - | |||||||
128 | // Do certain things depending on whether the JIT is enabled or disabled | - | ||||||
129 | - | |||||||
130 | #ifdef V4_ENABLE_JIT | - | ||||||
131 | #define ENABLE_YARR_JIT 1 | - | ||||||
132 | #define ENABLE_JIT 1 | - | ||||||
133 | #define ENABLE_ASSEMBLER 1 | - | ||||||
134 | #else | - | ||||||
135 | #define ENABLE_YARR_JIT 0 | - | ||||||
136 | #define ENABLE_ASSEMBLER 0 | - | ||||||
137 | #define ENABLE_JIT 0 | - | ||||||
138 | #endif | - | ||||||
139 | - | |||||||
140 | #if defined(Q_OS_QNX) && defined(_CPPLIB_VER) | - | ||||||
141 | #include <math.h> | - | ||||||
142 | #undef isnan | - | ||||||
143 | #undef isfinite | - | ||||||
144 | #undef isinf | - | ||||||
145 | #undef signbit | - | ||||||
146 | #endif | - | ||||||
147 | - | |||||||
148 | QT_BEGIN_NAMESPACE | - | ||||||
149 | - | |||||||
150 | namespace QV4 { | - | ||||||
151 | - | |||||||
152 | namespace Compiler { | - | ||||||
153 | struct Module; | - | ||||||
154 | struct Context; | - | ||||||
155 | struct JSUnitGenerator; | - | ||||||
156 | class Codegen; | - | ||||||
157 | } | - | ||||||
158 | - | |||||||
159 | namespace Moth { | - | ||||||
160 | class BytecodeGenerator; | - | ||||||
161 | } | - | ||||||
162 | - | |||||||
163 | namespace Heap { | - | ||||||
164 | struct Base; | - | ||||||
165 | struct MemberData; | - | ||||||
166 | struct ArrayData; | - | ||||||
167 | - | |||||||
168 | struct StringOrSymbol; | - | ||||||
169 | struct String; | - | ||||||
170 | struct Symbol; | - | ||||||
171 | struct Object; | - | ||||||
172 | struct ObjectPrototype; | - | ||||||
173 | - | |||||||
174 | struct ExecutionContext; | - | ||||||
175 | struct CallContext; | - | ||||||
176 | struct QmlContext; | - | ||||||
177 | struct ScriptFunction; | - | ||||||
178 | struct InternalClass; | - | ||||||
179 | - | |||||||
180 | struct BooleanObject; | - | ||||||
181 | struct NumberObject; | - | ||||||
182 | struct StringObject; | - | ||||||
183 | struct ArrayObject; | - | ||||||
184 | struct DateObject; | - | ||||||
185 | struct FunctionObject; | - | ||||||
186 | struct ErrorObject; | - | ||||||
187 | struct ArgumentsObject; | - | ||||||
188 | struct QObjectWrapper; | - | ||||||
189 | struct RegExpObject; | - | ||||||
190 | struct RegExp; | - | ||||||
191 | struct EvalFunction; | - | ||||||
192 | - | |||||||
193 | struct ArrayBuffer; | - | ||||||
194 | struct DataView; | - | ||||||
195 | struct TypedArray; | - | ||||||
196 | - | |||||||
197 | template <typename T, size_t> struct Pointer; | - | ||||||
198 | } | - | ||||||
199 | - | |||||||
200 | struct CppStackFrame; | - | ||||||
201 | class MemoryManager; | - | ||||||
202 | class ExecutableAllocator; | - | ||||||
203 | struct PropertyKey; | - | ||||||
204 | struct StringOrSymbol; | - | ||||||
205 | struct String; | - | ||||||
206 | struct Symbol; | - | ||||||
207 | struct Object; | - | ||||||
208 | struct ObjectPrototype; | - | ||||||
209 | struct ObjectIterator; | - | ||||||
210 | struct ExecutionContext; | - | ||||||
211 | struct CallContext; | - | ||||||
212 | struct QmlContext; | - | ||||||
213 | struct ScriptFunction; | - | ||||||
214 | struct InternalClass; | - | ||||||
215 | struct Property; | - | ||||||
216 | struct Value; | - | ||||||
217 | template<size_t> struct HeapValue; | - | ||||||
218 | template<size_t> struct ValueArray; | - | ||||||
219 | struct Lookup; | - | ||||||
220 | struct ArrayData; | - | ||||||
221 | struct VTable; | - | ||||||
222 | struct Function; | - | ||||||
223 | - | |||||||
224 | struct BooleanObject; | - | ||||||
225 | struct NumberObject; | - | ||||||
226 | struct StringObject; | - | ||||||
227 | struct ArrayObject; | - | ||||||
228 | struct DateObject; | - | ||||||
229 | struct FunctionObject; | - | ||||||
230 | struct ErrorObject; | - | ||||||
231 | struct ArgumentsObject; | - | ||||||
232 | struct Managed; | - | ||||||
233 | struct ExecutionEngine; | - | ||||||
234 | struct QObjectWrapper; | - | ||||||
235 | struct RegExpObject; | - | ||||||
236 | struct RegExp; | - | ||||||
237 | struct EvalFunction; | - | ||||||
238 | - | |||||||
239 | struct ArrayBuffer; | - | ||||||
240 | struct DataView; | - | ||||||
241 | struct TypedArray; | - | ||||||
242 | - | |||||||
243 | // ReturnedValue is used to return values from runtime methods | - | ||||||
244 | // the type has to be a primitive type (no struct or union), so that the compiler | - | ||||||
245 | // will return it in a register on all platforms. | - | ||||||
246 | // It will be returned in rax on x64, [eax,edx] on x86 and [r0,r1] on arm | - | ||||||
247 | typedef quint64 ReturnedValue; | - | ||||||
248 | struct CallData; | - | ||||||
249 | struct Scope; | - | ||||||
250 | struct ScopedValue; | - | ||||||
251 | template<typename T> struct Scoped; | - | ||||||
252 | typedef Scoped<String> ScopedString; | - | ||||||
253 | typedef Scoped<StringOrSymbol> ScopedStringOrSymbol; | - | ||||||
254 | typedef Scoped<Object> ScopedObject; | - | ||||||
255 | typedef Scoped<ArrayObject> ScopedArrayObject; | - | ||||||
256 | typedef Scoped<FunctionObject> ScopedFunctionObject; | - | ||||||
257 | typedef Scoped<ExecutionContext> ScopedContext; | - | ||||||
258 | - | |||||||
259 | struct PersistentValueStorage; | - | ||||||
260 | class PersistentValue; | - | ||||||
261 | class WeakValue; | - | ||||||
262 | struct MarkStack; | - | ||||||
263 | - | |||||||
264 | struct IdentifierTable; | - | ||||||
265 | class RegExpCache; | - | ||||||
266 | class MultiplyWrappedQObjectMap; | - | ||||||
267 | - | |||||||
268 | enum PropertyFlag { | - | ||||||
269 | Attr_Data = 0, | - | ||||||
270 | Attr_Accessor = 0x1, | - | ||||||
271 | Attr_NotWritable = 0x2, | - | ||||||
272 | Attr_NotEnumerable = 0x4, | - | ||||||
273 | Attr_NotConfigurable = 0x8, | - | ||||||
274 | Attr_ReadOnly = Attr_NotWritable|Attr_NotEnumerable|Attr_NotConfigurable, | - | ||||||
275 | Attr_ReadOnly_ButConfigurable = Attr_NotWritable|Attr_NotEnumerable, | - | ||||||
276 | Attr_Invalid = 0xff | - | ||||||
277 | }; | - | ||||||
278 | - | |||||||
279 | Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) | - | ||||||
280 | Q_DECLARE_OPERATORS_FOR_FLAGS(PropertyFlags) | - | ||||||
281 | - | |||||||
282 | struct PropertyAttributes | - | ||||||
283 | { | - | ||||||
284 | union { | - | ||||||
285 | uchar m_all; | - | ||||||
286 | struct { | - | ||||||
287 | uchar m_flags : 4; | - | ||||||
288 | uchar m_mask : 4; | - | ||||||
289 | }; | - | ||||||
290 | struct { | - | ||||||
291 | uchar m_type : 1; | - | ||||||
292 | uchar m_writable : 1; | - | ||||||
293 | uchar m_enumerable : 1; | - | ||||||
294 | uchar m_configurable : 1; | - | ||||||
295 | uchar type_set : 1; | - | ||||||
296 | uchar writable_set : 1; | - | ||||||
297 | uchar enumerable_set : 1; | - | ||||||
298 | uchar configurable_set : 1; | - | ||||||
299 | }; | - | ||||||
300 | }; | - | ||||||
301 | - | |||||||
302 | enum Type { | - | ||||||
303 | Data = 0, | - | ||||||
304 | Accessor = 1, | - | ||||||
305 | Generic = 2 | - | ||||||
306 | }; | - | ||||||
307 | - | |||||||
308 | PropertyAttributes() : m_all(0) {} executed 216537762 times by 154 tests: end of block Executed by:
| 216537762 | ||||||
309 | PropertyAttributes(PropertyFlag f) : m_all(0) { | - | ||||||
310 | if (f != Attr_Invalid) {
| 29868773-91659165 | ||||||
311 | setType(f & Attr_Accessor ? Accessor : Data); | - | ||||||
312 | if (!(f & Attr_Accessor))
| 5410-91784497 | ||||||
313 | setWritable(!(f & Attr_NotWritable)); executed 91791982 times by 154 tests: setWritable(!(f & Attr_NotWritable)); Executed by:
| 91791982 | ||||||
314 | setEnumerable(!(f & Attr_NotEnumerable)); | - | ||||||
315 | setConfigurable(!(f & Attr_NotConfigurable)); | - | ||||||
316 | } executed 92135329 times by 154 tests: end of block Executed by:
| 92135329 | ||||||
317 | } executed 121981708 times by 154 tests: end of block Executed by:
| 121981708 | ||||||
318 | PropertyAttributes(PropertyFlags f) : m_all(0) { | - | ||||||
319 | if (f != Attr_Invalid) {
| 0-30032913 | ||||||
320 | setType(f & Attr_Accessor ? Accessor : Data); | - | ||||||
321 | if (!(f & Attr_Accessor))
| 4171205-25895848 | ||||||
322 | setWritable(!(f & Attr_NotWritable)); executed 25894150 times by 154 tests: setWritable(!(f & Attr_NotWritable)); Executed by:
| 25894150 | ||||||
323 | setEnumerable(!(f & Attr_NotEnumerable)); | - | ||||||
324 | setConfigurable(!(f & Attr_NotConfigurable)); | - | ||||||
325 | } executed 30075270 times by 154 tests: end of block Executed by:
| 30075270 | ||||||
326 | } executed 30088098 times by 154 tests: end of block Executed by:
| 30088098 | ||||||
327 | - | |||||||
328 | void setType(Type t) { m_type = t; type_set = true; } executed 121358620 times by 154 tests: end of block Executed by:
| 121358620 | ||||||
329 | Type type() const { return type_set ? (Type)m_type : Generic; } executed 280942054 times by 154 tests: return type_set ? (Type)m_type : Generic; Executed by:
| 280942054 | ||||||
330 | - | |||||||
331 | bool isData() const { return type() == PropertyAttributes::Data || writable_set; } executed 2344143 times by 154 tests: return type() == PropertyAttributes::Data || writable_set; Executed by:
| 2344143 | ||||||
332 | bool isAccessor() const { return type() == PropertyAttributes::Accessor; } executed 277769313 times by 154 tests: return type() == PropertyAttributes::Accessor; Executed by:
| 277769313 | ||||||
333 | bool isGeneric() const { return type() == PropertyAttributes::Generic && !writable_set; } executed 24971 times by 4 tests: return type() == PropertyAttributes::Generic && !writable_set; Executed by:
| 24971 | ||||||
334 | - | |||||||
335 | bool hasType() const { return type_set; } executed 548841 times by 21 tests: return type_set; Executed by:
| 548841 | ||||||
336 | bool hasWritable() const { return writable_set; } executed 7276 times by 3 tests: return writable_set; Executed by:
| 7276 | ||||||
337 | bool hasConfigurable() const { return configurable_set; } executed 7552 times by 3 tests: return configurable_set; Executed by:
| 7552 | ||||||
338 | bool hasEnumerable() const { return enumerable_set; } executed 8992 times by 3 tests: return enumerable_set; Executed by:
| 8992 | ||||||
339 | - | |||||||
340 | void setWritable(bool b) { m_writable = b; writable_set = true; } executed 135079623 times by 154 tests: end of block Executed by:
| 135079623 | ||||||
341 | void setConfigurable(bool b) { m_configurable = b; configurable_set = true; } executed 140043327 times by 154 tests: end of block Executed by:
| 140043327 | ||||||
342 | void setEnumerable(bool b) { m_enumerable = b; enumerable_set = true; } executed 121754876 times by 154 tests: end of block Executed by:
| 121754876 | ||||||
343 | - | |||||||
344 | void resolve() { m_mask = 0xf; if (m_type == Accessor) { m_writable = false; writable_set = false; } } executed 156117376 times by 154 tests: end of block Executed by:
executed 4790447 times by 154 tests: end of block Executed by:
| 4790143-156117376 | ||||||
345 | - | |||||||
346 | bool isWritable() const { return m_type != Data || m_writable; } executed 73551560 times by 154 tests: return m_type != Data || m_writable; Executed by:
| 73551560 | ||||||
347 | bool isEnumerable() const { return m_enumerable; } executed 321361 times by 32 tests: return m_enumerable; Executed by:
| 321361 | ||||||
348 | bool isConfigurable() const { return m_configurable; } executed 50680 times by 6 tests: return m_configurable; Executed by:
| 50680 | ||||||
349 | - | |||||||
350 | void clearType() { m_type = Data; type_set = false; } never executed: end of block | 0 | ||||||
351 | void clearWritable() { m_writable = false; writable_set = false; } executed 11925 times by 3 tests: end of block Executed by:
| 11925 | ||||||
352 | void clearEnumerable() { m_enumerable = false; enumerable_set = false; } never executed: end of block | 0 | ||||||
353 | void clearConfigurable() { m_configurable = false; configurable_set = false; } never executed: end of block | 0 | ||||||
354 | - | |||||||
355 | void clear() { m_all = 0; } executed 21672 times by 3 tests: end of block Executed by:
| 21672 | ||||||
356 | bool isEmpty() const { return !m_all; } executed 18453838 times by 154 tests: return !m_all; Executed by:
| 18453838 | ||||||
357 | - | |||||||
358 | uint flags() const { return m_flags; } executed 150635770 times by 154 tests: return m_flags; Executed by:
| 150635770 | ||||||
359 | - | |||||||
360 | bool operator==(PropertyAttributes other) { | - | ||||||
361 | return m_all == other.m_all; executed 4676385 times by 154 tests: return m_all == other.m_all; Executed by:
| 4676385 | ||||||
362 | } | - | ||||||
363 | bool operator!=(PropertyAttributes other) { | - | ||||||
364 | return m_all != other.m_all; executed 775248 times by 22 tests: return m_all != other.m_all; Executed by:
| 775248 | ||||||
365 | } | - | ||||||
366 | }; | - | ||||||
367 | - | |||||||
368 | struct Q_QML_EXPORT StackFrame { | - | ||||||
369 | QString source; | - | ||||||
370 | QString function; | - | ||||||
371 | int line = -1; | - | ||||||
372 | int column = -1; | - | ||||||
373 | }; | - | ||||||
374 | typedef QVector<StackFrame> StackTrace; | - | ||||||
375 | - | |||||||
376 | enum class ObjectLiteralArgument { | - | ||||||
377 | Value, | - | ||||||
378 | Getter, | - | ||||||
379 | Setter | - | ||||||
380 | }; | - | ||||||
381 | - | |||||||
382 | } | - | ||||||
383 | - | |||||||
384 | Q_DECLARE_TYPEINFO(QV4::PropertyAttributes, Q_PRIMITIVE_TYPE); | - | ||||||
385 | - | |||||||
386 | QT_END_NAMESPACE | - | ||||||
387 | - | |||||||
388 | #endif // QV4GLOBAL_H | - | ||||||
Source code | Switch to Preprocessed file |