| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | #ifndef QV4RUNTIMEAPI_P_H | - |
| 40 | #define QV4RUNTIMEAPI_P_H | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | #include <private/qv4global_p.h> | - |
| 54 | | - |
| 55 | QT_BEGIN_NAMESPACE | - |
| 56 | | - |
| 57 | namespace QV4 { | - |
| 58 | | - |
| 59 | typedef uint Bool; | - |
| 60 | struct NoThrowEngine; | - |
| 61 | namespace { | - |
| 62 | template <typename T> | - |
| 63 | struct ExceptionCheck { | - |
| 64 | enum { NeedsCheck = 1 }; | - |
| 65 | }; | - |
| 66 | | - |
| 67 | template <> | - |
| 68 | struct ExceptionCheck<void (*)(QV4::NoThrowEngine *)> { | - |
| 69 | enum { NeedsCheck = 0 }; | - |
| 70 | }; | - |
| 71 | template <typename A> | - |
| 72 | struct ExceptionCheck<void (*)(A, QV4::NoThrowEngine)> { | - |
| 73 | enum { NeedsCheck = 0 }; | - |
| 74 | }; | - |
| 75 | template <> | - |
| 76 | struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *)> { | - |
| 77 | enum { NeedsCheck = 0 }; | - |
| 78 | }; | - |
| 79 | template <typename A> | - |
| 80 | struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *, A)> { | - |
| 81 | enum { NeedsCheck = 0 }; | - |
| 82 | }; | - |
| 83 | template <typename A, typename B> | - |
| 84 | struct ExceptionCheck<QV4::ReturnedValue (*)(QV4::NoThrowEngine *, A, B)> { | - |
| 85 | enum { NeedsCheck = 0 }; | - |
| 86 | }; | - |
| 87 | template <typename A, typename B, typename C> | - |
| 88 | struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> { | - |
| 89 | enum { NeedsCheck = 0 }; | - |
| 90 | }; | - |
| 91 | } | - |
| 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 | | - |
| 206 | struct 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 | | - |
| 234 | static_assert(std::is_standard_layout<Runtime>::value, "Runtime needs to be standard layout in order for us to be able to use offsetof"); | - |
| 235 | static_assert(offsetof(Runtime, runtimeMethods) == 0, "JIT expects this to be the first member"); | - |
| 236 | static_assert(sizeof(Runtime::BinaryOperation) == sizeof(void*), "JIT expects a function pointer to fit into a regular pointer, for cross-compilation offset translation"); | - |
| 237 | | - |
| 238 | } | - |
| 239 | | - |
| 240 | QT_END_NAMESPACE | - |
| 241 | | - |
| 242 | #endif // QV4RUNTIMEAPI_P_H | - |
| | |