OpenCoverage

qv4runtimeapi_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4runtimeapi_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
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#ifndef QV4RUNTIMEAPI_P_H-
40#define QV4RUNTIMEAPI_P_H-
41-
42//-
43// W A R N I N G-
44// --------------
45//-
46// This file is not part of the Qt API. It exists purely as an-
47// implementation detail. This header file may change from version to-
48// version without notice, or even be removed.-
49//-
50// We mean it.-
51//-
52-
53#include <private/qv4global_p.h>-
54-
55QT_BEGIN_NAMESPACE-
56-
57namespace QV4 {-
58-
59typedef uint Bool;-
60struct NoThrowEngine;-
61namespace {-
62template <typename T>-
63struct ExceptionCheck {-
64 enum { NeedsCheck = 1 };-
65};-
66// push_catch and pop context methods shouldn't check for exceptions-
67template <>-
68struct ExceptionCheck<void (*)(QV4::NoThrowEngine *)> {-
69 enum { NeedsCheck = 0 };-
70};-
71template <typename A>-
72struct ExceptionCheck<void (*)(A, QV4::NoThrowEngine)> {-
73 enum { NeedsCheck = 0 };-
74};-
75template <>-
76struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *)> {-
77 enum { NeedsCheck = 0 };-
78};-
79template <typename A>-
80struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *, A)> {-
81 enum { NeedsCheck = 0 };-
82};-
83template <typename A, typename B>-
84struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *, A, B)> {-
85 enum { NeedsCheck = 0 };-
86};-
87template <typename A, typename B, typename C>-
88struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> {-
89 enum { NeedsCheck = 0 };-
90};-
91} // anonymous namespace-
92-
93#define FOR_EACH_RUNTIME_METHOD(F) \-
94 /* call */ \-
95 F(ReturnedValue, callGlobalLookup, (ExecutionEngine *engine, uint index, Value *argv, int argc)) \-
96 F(ReturnedValue, callName, (ExecutionEngine *engine, int nameIndex, Value *argv, int argc)) \-
97 F(ReturnedValue, callProperty, (ExecutionEngine *engine, Value *base, int nameIndex, Value *argv, int argc)) \-
98 F(ReturnedValue, callPropertyLookup, (ExecutionEngine *engine, Value *base, uint index, Value *argv, int argc)) \-
99 F(ReturnedValue, callElement, (ExecutionEngine *engine, Value *base, const Value &index, Value *argv, int argc)) \-
100 F(ReturnedValue, callValue, (ExecutionEngine *engine, const Value &func, Value *argv, int argc)) \-
101 F(ReturnedValue, callPossiblyDirectEval, (ExecutionEngine *engine, Value *argv, int argc)) \-
102 F(ReturnedValue, callWithSpread, (ExecutionEngine *engine, const Value &func, const Value &thisObject, Value *argv, int argc)) \-
103 \-
104 /* construct */ \-
105 F(ReturnedValue, construct, (ExecutionEngine *engine, const Value &func, const Value &newTarget, Value *argv, int argc)) \-
106 F(ReturnedValue, constructWithSpread, (ExecutionEngine *engine, const Value &func, const Value &newTarget, Value *argv, int argc)) \-
107 \-
108 /* load & store */ \-
109 F(void, storeNameStrict, (ExecutionEngine *engine, int nameIndex, const Value &value)) \-
110 F(void, storeNameSloppy, (ExecutionEngine *engine, int nameIndex, const Value &value)) \-
111 F(void, storeProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)) \-
112 F(void, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \-
113 F(ReturnedValue, loadProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)) \-
114 F(ReturnedValue, loadName, (ExecutionEngine *engine, int nameIndex)) \-
115 F(ReturnedValue, loadElement, (ExecutionEngine *engine, const Value &object, const Value &index)) \-
116 F(ReturnedValue, loadSuperProperty, (ExecutionEngine *engine, const Value &property)) \-
117 F(void, storeSuperProperty, (ExecutionEngine *engine, const Value &property, const Value &value)) \-
118 \-
119 /* typeof */ \-
120 F(ReturnedValue, typeofValue, (ExecutionEngine *engine, const Value &val)) \-
121 F(ReturnedValue, typeofName, (ExecutionEngine *engine, int nameIndex)) \-
122 \-
123 /* delete */ \-
124 F(bool, deleteProperty, (ExecutionEngine *engine, const Value &base, const Value &index)) \-
125 F(bool, deleteName, (ExecutionEngine *engine, int nameIndex)) \-
126 \-
127 /* exceptions & scopes */ \-
128 F(void, throwException, (ExecutionEngine *engine, const Value &value)) \-
129 F(ReturnedValue, createWithContext, (ExecutionEngine *, Value *jsStackFrame)) \-
130 F(ReturnedValue, createCatchContext, (ExecutionContext *parent, int blockIndex, int exceptionVarNameIndex)) \-
131 F(ReturnedValue, createBlockContext, (ExecutionContext *parent, int index)) \-
132 F(ReturnedValue, createScriptContext, (ExecutionEngine *engine, int index)) \-
133 F(ReturnedValue, cloneBlockContext, (ExecutionContext *previous)) \-
134 F(ReturnedValue, popScriptContext, (ExecutionEngine *engine)) \-
135 \-
136 /* closures */ \-
137 F(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)) \-
138 \-
139 /* function header */ \-
140 F(void, declareVar, (ExecutionEngine *engine, bool deletable, int nameIndex)) \-
141 F(ReturnedValue, createMappedArgumentsObject, (ExecutionEngine *engine)) \-
142 F(ReturnedValue, createUnmappedArgumentsObject, (ExecutionEngine *engine)) \-
143 F(ReturnedValue, createRestParameter, (ExecutionEngine *engine, int argIndex)) \-
144 \-
145 /* literals */ \-
146 F(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)) \-
147 F(ReturnedValue, objectLiteral, (ExecutionEngine *engine, int classId, int argc, const Value *args)) \-
148 F(ReturnedValue, createClass, (ExecutionEngine *engine, int classIndex, const Value &heritage, const Value *computedNames)) \-
149 \-
150 /* for-in, for-of and array destructuring */ \-
151 F(ReturnedValue, getIterator, (ExecutionEngine *engine, const Value &in, int iterator)) \-
152 F(ReturnedValue, iteratorNext, (ExecutionEngine *engine, const Value &iterator, Value *value)) \-
153 F(ReturnedValue, iteratorClose, (ExecutionEngine *engine, const Value &iterator, const Value &done)) \-
154 F(ReturnedValue, destructureRestElement, (ExecutionEngine *engine, const Value &iterator)) \-
155 \-
156 /* unary operators */ \-
157 F(ReturnedValue, uMinus, (const Value &value)) \-
158 \-
159 /* binary operators */ \-
160 F(ReturnedValue, instanceof, (ExecutionEngine *engine, const Value &left, const Value &right)) \-
161 F(ReturnedValue, in, (ExecutionEngine *engine, const Value &left, const Value &right)) \-
162 F(ReturnedValue, add, (ExecutionEngine *engine, const Value &left, const Value &right)) \-
163 F(ReturnedValue, sub, (const Value &left, const Value &right)) \-
164 F(ReturnedValue, mul, (const Value &left, const Value &right)) \-
165 F(ReturnedValue, div, (const Value &left, const Value &right)) \-
166 F(ReturnedValue, mod, (const Value &left, const Value &right)) \-
167 F(ReturnedValue, shl, (const Value &left, const Value &right)) \-
168 F(ReturnedValue, shr, (const Value &left, const Value &right)) \-
169 F(ReturnedValue, ushr, (const Value &left, const Value &right)) \-
170 F(ReturnedValue, greaterThan, (const Value &left, const Value &right)) \-
171 F(ReturnedValue, lessThan, (const Value &left, const Value &right)) \-
172 F(ReturnedValue, greaterEqual, (const Value &left, const Value &right)) \-
173 F(ReturnedValue, lessEqual, (const Value &left, const Value &right)) \-
174 F(ReturnedValue, equal, (const Value &left, const Value &right)) \-
175 F(ReturnedValue, notEqual, (const Value &left, const Value &right)) \-
176 F(ReturnedValue, strictEqual, (const Value &left, const Value &right)) \-
177 F(ReturnedValue, strictNotEqual, (const Value &left, const Value &right)) \-
178 \-
179 /* comparisons */ \-
180 F(Bool, compareGreaterThan, (const Value &l, const Value &r)) \-
181 F(Bool, compareLessThan, (const Value &l, const Value &r)) \-
182 F(Bool, compareGreaterEqual, (const Value &l, const Value &r)) \-
183 F(Bool, compareLessEqual, (const Value &l, const Value &r)) \-
184 F(Bool, compareEqual, (const Value &left, const Value &right)) \-
185 F(Bool, compareNotEqual, (const Value &left, const Value &right)) \-
186 F(Bool, compareStrictEqual, (const Value &left, const Value &right)) \-
187 F(Bool, compareStrictNotEqual, (const Value &left, const Value &right)) \-
188 \-
189 F(Bool, compareInstanceof, (ExecutionEngine *engine, const Value &left, const Value &right)) \-
190 F(Bool, compareIn, (ExecutionEngine *engine, const Value &left, const Value &right)) \-
191 \-
192 F(ReturnedValue, regexpLiteral, (ExecutionEngine *engine, int id)) \-
193 \-
194 /* qml */ \-
195 F(ReturnedValue, loadQmlContext, (NoThrowEngine *engine)) \-
196 F(ReturnedValue, loadQmlImportedScripts, (NoThrowEngine *engine)) \-
197 F(ReturnedValue, loadQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, bool captureRequired)) \-
198 F(ReturnedValue, loadQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, bool captureRequired)) \-
199 F(ReturnedValue, loadQmlIdObject, (ExecutionEngine *engine, const Value &context, uint index)) \-
200 F(ReturnedValue, callQmlScopeObjectProperty, (ExecutionEngine *engine, Value *base, int propertyIndex, Value *argv, int argc)) \-
201 F(ReturnedValue, callQmlContextObjectProperty, (ExecutionEngine *engine, Value *base, int propertyIndex, Value *argv, int argc)) \-
202 \-
203 F(void, storeQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)) \-
204 F(void, storeQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)) \-
205-
206struct Q_QML_PRIVATE_EXPORT Runtime {-
207 Runtime();-
208-
209 typedef ReturnedValue (*UnaryOperation)(const Value &value);-
210 typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right);-
211 typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right);-
212-
213#define DEFINE_RUNTIME_METHOD_ENUM(returnvalue, name, args) name,-
214 enum RuntimeMethods {-
215 FOR_EACH_RUNTIME_METHOD(DEFINE_RUNTIME_METHOD_ENUM)-
216 RuntimeMethodCount,-
217 InvalidRuntimeMethod = RuntimeMethodCount-
218 };-
219#undef DEFINE_RUNTIME_METHOD_ENUM-
220-
221 void *runtimeMethods[RuntimeMethodCount];-
222-
223 static uint runtimeMethodOffset(RuntimeMethods method) { return method*QT_POINTER_SIZE; }
never executed: return method*8;
0
224-
225#define RUNTIME_METHOD(returnvalue, name, args) \-
226 typedef returnvalue (*Method_##name)args; \-
227 enum { Method_##name##_NeedsExceptionCheck = ExceptionCheck<Method_##name>::NeedsCheck }; \-
228 static returnvalue method_##name args;-
229 FOR_EACH_RUNTIME_METHOD(RUNTIME_METHOD)-
230#undef RUNTIME_METHOD-
231-
232};-
233-
234static_assert(std::is_standard_layout<Runtime>::value, "Runtime needs to be standard layout in order for us to be able to use offsetof");-
235static_assert(offsetof(Runtime, runtimeMethods) == 0, "JIT expects this to be the first member");-
236static_assert(sizeof(Runtime::BinaryOperation) == sizeof(void*), "JIT expects a function pointer to fit into a regular pointer, for cross-compilation offset translation");-
237-
238} // namespace QV4-
239-
240QT_END_NAMESPACE-
241-
242#endif // QV4RUNTIMEAPI_P_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0