diff options
author | Lars Knoll <[email protected]> | 2017-10-20 16:54:10 +0200 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2017-11-07 09:00:44 +0000 |
commit | bc5ff76e5afe6356bebb344c9a5d8b304e852f3c (patch) | |
tree | 436e4cfdcad3ec2e882c300c85395fdeee3a4d48 | |
parent | 9b25000cb41b97c9c9f49a542c9b82cf25c032db (diff) |
Simplify JSCallData construction
Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3
Reviewed-by: Erik Verbruggen <[email protected]>
31 files changed, 83 insertions, 106 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 4de4a9520f..9d78773fe1 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -414,12 +414,12 @@ static ReturnedValue qmlsqldatabase_changeVersion(const QV4::BuiltinFunction *b, ok = false; db.transaction(); - JSCallData jsCall(scope, callback, 1); - jsCall->thisObject = scope.engine->globalObject; + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; jsCall->args[0] = w; TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); - jsCall.call(); + callback->call(jsCall); rollbackOnException.clear(); if (!db.commit()) { db.rollback(); @@ -464,11 +464,11 @@ static ReturnedValue qmlsqldatabase_transaction_shared(const QV4::BuiltinFunctio db.transaction(); if (callback) { - JSCallData jsCall(scope, callback, 1); - jsCall->thisObject = scope.engine->globalObject; + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; jsCall->args[0] = w; TransactionRollback rollbackOnException(&db, &w->d()->inTransaction); - jsCall.call(); + callback->call(jsCall); rollbackOnException.clear(); if (!db.commit()) @@ -763,10 +763,10 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) *db->d()->version = version; if (created && dbcreationCallback) { - JSCallData jsCall(scope, dbcreationCallback, 1); - jsCall->thisObject = scope.engine->globalObject; + JSCallData jsCall(scope, 1); + *jsCall->thisObject = scope.engine->globalObject; jsCall->args[0] = db; - jsCall.call(); + dbcreationCallback->call(jsCall); } args->setReturnValue(db.asReturnedValue()); diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 77bf587509..654a497950 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -657,7 +657,7 @@ QJSValue QJSValue::call(const QJSValueList &args) Q_ASSERT(engine); Scope scope(engine); - JSCallData jsCallData(scope, f, args.length()); + JSCallData jsCallData(scope, args.length()); jsCallData->thisObject = engine->globalObject; for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { @@ -713,7 +713,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList return QJSValue(); } - JSCallData jsCallData(scope, f, args.size()); + JSCallData jsCallData(scope, args.size()); jsCallData->thisObject = QJSValuePrivate::convertedToValue(engine, instance); for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { @@ -762,7 +762,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) Q_ASSERT(engine); Scope scope(engine); - JSCallData jsCallData(scope, f, args.size()); + JSCallData jsCallData(scope, args.size()); for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 298c674504..db0a7db068 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -139,7 +139,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con if (isMapped && attrs.isData()) { Q_ASSERT(arrayData()); ScopedFunctionObject setter(scope, map->setter()); - JSCallData jsCallData(scope, setter, 1); + JSCallData jsCallData(scope, 1); jsCallData->thisObject = this->asReturnedValue(); jsCallData->args[0] = desc->value; setter->call(jsCallData); diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 3bbec7957a..dd29411b46 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -187,7 +187,7 @@ ReturnedValue ArrayBufferPrototype::method_slice(const BuiltinFunction *b, CallD if (!constructor) return v4->throwTypeError(); - JSCallData jsCallData(scope, constructor, 1); + JSCallData jsCallData(scope, 1); double newLen = qMax(final - first, 0.); jsCallData->args[0] = QV4::Encode(newLen); QV4::Scoped<ArrayBuffer> newBuffer(scope, constructor->callAsConstructor(jsCallData)); diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 8d048ca1d6..b77fab3305 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -677,7 +677,7 @@ bool ArrayElementLessThan::operator()(Value v1, Value v2) const if (o) { Scope scope(o->engine()); ScopedValue result(scope); - JSCallData jsCallData(scope, o, 2); + JSCallData jsCallData(scope, 2); jsCallData->args[0] = v1; jsCallData->args[1] = v2; result = o->call(jsCallData); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 83bfe8e84c..eef9ac0820 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -198,7 +198,7 @@ ReturnedValue ArrayPrototype::method_find(const BuiltinFunction *b, CallData *ca if (!callback) THROW_TYPE_ERROR(); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); ScopedValue v(scope); @@ -234,7 +234,7 @@ ReturnedValue ArrayPrototype::method_findIndex(const BuiltinFunction *b, CallDat if (!callback) THROW_TYPE_ERROR(); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); ScopedValue v(scope); @@ -793,7 +793,7 @@ ReturnedValue ArrayPrototype::method_every(const BuiltinFunction *b, CallData *c ScopedValue r(scope); ScopedValue v(scope); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); bool ok = true; @@ -827,7 +827,7 @@ ReturnedValue ArrayPrototype::method_some(const BuiltinFunction *b, CallData *ca ScopedValue v(scope); ScopedValue result(scope); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { @@ -860,7 +860,7 @@ ReturnedValue ArrayPrototype::method_forEach(const BuiltinFunction *b, CallData THROW_TYPE_ERROR(); ScopedValue v(scope); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { @@ -896,7 +896,7 @@ ReturnedValue ArrayPrototype::method_map(const BuiltinFunction *b, CallData *cal ScopedValue v(scope); ScopedValue mapped(scope); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); for (uint k = 0; k < len; ++k) { @@ -932,7 +932,7 @@ ReturnedValue ArrayPrototype::method_filter(const BuiltinFunction *b, CallData * ScopedValue selected(scope); ScopedValue v(scope); - JSCallData jsCallData(scope, callback, 3); + JSCallData jsCallData(scope, 3); jsCallData->thisObject = callData->argument(1); uint to = 0; @@ -985,7 +985,7 @@ ReturnedValue ArrayPrototype::method_reduce(const BuiltinFunction *b, CallData * THROW_TYPE_ERROR(); } - JSCallData jsCallData(scope, callback, 4); + JSCallData jsCallData(scope, 4); while (k < len) { bool kPresent; @@ -1038,7 +1038,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const BuiltinFunction *b, CallD THROW_TYPE_ERROR(); } - JSCallData jsCallData(scope, callback, 4); + JSCallData jsCallData(scope, 4); jsCallData->thisObject = Primitive::undefinedValue(); while (k > 0) { diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 436950bf28..3397e5418b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1451,7 +1451,7 @@ ReturnedValue DatePrototype::method_toJSON(const BuiltinFunction *b, CallData *c if (!toIso) return v4->throwTypeError(); - JSCallData jsCallData(scope, toIso); + JSCallData jsCallData(scope); jsCallData->thisObject = callData->thisObject; return toIso->call(jsCallData); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 208af838a7..21aacb68d6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -73,13 +73,13 @@ Q_STATIC_ASSERT((Heap::FunctionObject::markTable & Heap::Object::markTable) == H static ReturnedValue jsCallWrapper(const QV4::FunctionObject *f, const Value *thisObject, const Value *argv, int argc) { Scope scope(f->engine()); - JSCallData callData(scope, f->asReturnedValue(), argv, argc, thisObject); + JSCallData callData(scope, argc, argv, thisObject); return f->vtable()->call(f, callData.callData(f)); } ReturnedValue jsConstructWrapper(const QV4::FunctionObject *f, const Value *argv, int argc) { Scope scope(f->engine()); - JSCallData callData(scope, f->asReturnedValue(), argv, argc); + JSCallData callData(scope, argc, argv); return f->vtable()->construct(f, callData.callData(f)); } diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 3c91417b0e..4e96b01185 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -374,7 +374,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const if (function->isStrict() || (ctx->d()->v4Function->isStrict())) { ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function)); - JSCallData jsCallData(scope, e, 0); + JSCallData jsCallData(scope, 0); if (directCall) jsCallData->thisObject = scope.engine->currentStackFrame->thisObject(); else @@ -387,7 +387,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const // set the correct v4 function for the context ctx->d()->v4Function = function; - JSCallData jsCall(scope, nullptr); + JSCallData jsCall(scope); jsCall->thisObject = scope.engine->currentStackFrame->thisObject(); jsCall->context = *ctx; return function->call(jsCall.callData()); diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 7feea14a05..df20b2802d 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -119,7 +119,7 @@ void QV4Include::callback(const QV4::Value &callback, const QV4::Value &status) if (!f) return; - QV4::JSCallData jsCallData(scope, f, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->thisObject = v4->globalObject->asReturnedValue(); jsCallData->args[0] = status; f->call(jsCallData); diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h index 0bb2d840da..0f22aa1aa7 100644 --- a/src/qml/jsruntime/qv4jscall_p.h +++ b/src/qml/jsruntime/qv4jscall_p.h @@ -61,20 +61,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct JSCallData { - JSCallData(const Scope &scope, std::nullptr_t, int argc = 0) - { - int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; - ptr = reinterpret_cast<CallData *>(scope.alloc(size)); - ptr->setArgc(argc); - } - JSCallData(const Scope &scope, const FunctionObject *function, int argc = 0) - { - int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; - ptr = reinterpret_cast<CallData *>(scope.alloc(size)); - ptr->setArgc(argc); - ptr->function = *function; - } - JSCallData(const Scope &scope, Value *argv, int argc, Value *thisObject = 0) + JSCallData(const Scope &scope, int argc = 0, const Value *argv = 0, const Value *thisObject = 0) { int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; ptr = reinterpret_cast<CallData *>(scope.engine->jsStackTop); @@ -84,19 +71,8 @@ struct JSCallData { ptr->accumulator = Encode::undefined(); ptr->thisObject = thisObject ? thisObject->asReturnedValue() : Encode::undefined(); ptr->setArgc(argc); - memcpy(ptr->args, argv, argc*sizeof(Value)); - } - JSCallData(const Scope &scope, ReturnedValue function, const Value *argv, int argc, const Value *thisObject = 0) - { - int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc; - ptr = reinterpret_cast<CallData *>(scope.engine->jsStackTop); - scope.engine->jsStackTop += size; - ptr->function = function; - ptr->context = Encode::undefined(); - ptr->accumulator = Encode::undefined(); - ptr->thisObject = thisObject ? thisObject->asReturnedValue() : Encode::undefined(); - ptr->setArgc(argc); - memcpy(ptr->args, argv, argc*sizeof(Value)); + if (argv) + memcpy(ptr->args, argv, argc*sizeof(Value)); } CallData *operator->() const { diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 7a4ae595ae..16018722cb 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -697,7 +697,7 @@ QString Stringify::Str(const QString &key, const Value &v) ScopedString s(scope, v4->newString(QStringLiteral("toJSON"))); ScopedFunctionObject toJSON(scope, o->get(s)); if (!!toJSON) { - JSCallData jsCallData(scope, toJSON, 1); + JSCallData jsCallData(scope, 1); jsCallData->thisObject = value; jsCallData->args[0] = v4->newString(key); value = toJSON->call(jsCallData); @@ -707,7 +707,7 @@ QString Stringify::Str(const QString &key, const Value &v) if (replacerFunction) { ScopedObject holder(scope, v4->newObject()); holder->put(scope.engine->id_empty(), value); - JSCallData jsCallData(scope, replacerFunction, 2); + JSCallData jsCallData(scope, 2); jsCallData->args[0] = v4->newString(key); jsCallData->args[1] = value; jsCallData->thisObject = holder; diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 17667cbae6..87c396be73 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -400,7 +400,7 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); jsCallData->thisObject = object; return getter->call(jsCallData); } @@ -422,7 +422,7 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); jsCallData->thisObject = object; return getter->call(jsCallData); } @@ -447,7 +447,7 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); jsCallData->thisObject = object; return getter->call(jsCallData); } @@ -502,7 +502,7 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, ExecutionEngine *engin if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); jsCallData->thisObject = object; return getter->call(jsCallData); } @@ -522,7 +522,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, ExecutionEngine *engin if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); jsCallData->thisObject = object; return getter->call(jsCallData); } @@ -641,7 +641,7 @@ ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); return getter->call(jsCallData); } l->globalGetter = globalGetterGeneric; @@ -658,7 +658,7 @@ ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); return getter->call(jsCallData); } l->globalGetter = globalGetterGeneric; @@ -678,7 +678,7 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionEngine *engine) if (!getter) return Encode::undefined(); - JSCallData jsCallData(scope, getter, 0); + JSCallData jsCallData(scope); return getter->call(jsCallData); } } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index c52cad69d1..18a831a4ba 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -107,7 +107,7 @@ ReturnedValue Object::getValue(const Value &thisObject, const Value &v, Property return Encode::undefined(); Scope scope(f->engine()); - JSCallData jsCallData(scope, f); + JSCallData jsCallData(scope); jsCallData->thisObject = thisObject; return f->call(jsCallData); } @@ -125,7 +125,7 @@ bool Object::putValue(uint memberIndex, const Value &value) if (set) { Scope scope(ic->engine); ScopedFunctionObject setter(scope, set); - JSCallData jsCallData(scope, setter, 1); + JSCallData jsCallData(scope, 1); jsCallData->args[0] = value; jsCallData->thisObject = this; setter->call(jsCallData); @@ -764,7 +764,7 @@ bool Object::internalPut(String *name, const Value &value) Scope scope(engine); ScopedFunctionObject setter(scope, *memberIndex); - JSCallData jsCallData(scope, setter, 1); + JSCallData jsCallData(scope, 1); jsCallData->args[0] = value; jsCallData->thisObject = this; setter->call(jsCallData); @@ -829,7 +829,7 @@ bool Object::internalPutIndexed(uint index, const Value &value) Scope scope(engine); ScopedFunctionObject setter(scope, *arrayIndex); - JSCallData jsCallData(scope, setter, 1); + JSCallData jsCallData(scope, 1); jsCallData->args[0] = value; jsCallData->thisObject = this; setter->call(jsCallData); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 198d7d285e..c174cb4dcd 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -479,7 +479,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(const BuiltinFunction *b, C ScopedFunctionObject f(scope, o->get(scope.engine->id_toString())); if (!f) THROW_TYPE_ERROR(); - JSCallData jsCallData(scope, f); + JSCallData jsCallData(scope); jsCallData->thisObject = o; return f->call(jsCallData); } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index a6c0218c2b..febcc22fa3 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -816,7 +816,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase QV4::Scope scope(v4); QV4::ScopedFunctionObject f(scope, This->function.value()); - QV4::JSCallData jsCallData(scope, f, argCount); + QV4::JSCallData jsCallData(scope, argCount); jsCallData->thisObject = This->thisObject.isUndefined() ? v4->globalObject->asReturnedValue() : This->thisObject.value(); for (int ii = 0; ii < argCount; ++ii) { int type = argsTypes[ii + 1]; diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 556a2a5339..1d1a786e61 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -436,7 +436,7 @@ ReturnedValue RegExpPrototype::method_compile(const BuiltinFunction *b, CallData if (!r) return scope.engine->throwTypeError(); - JSCallData jsCallData(scope, scope.engine->regExpCtor(), callData->argc()); + JSCallData jsCallData(scope, callData->argc()); memcpy(jsCallData->args, callData->args, callData->argc()*sizeof(Value)); Scoped<RegExpObject> re(scope, scope.engine->regExpCtor()->callAsConstructor(jsCallData)); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index aecff0f629..00882d699c 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -429,7 +429,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH ScopedValue result(scope); ScopedValue conv(scope, object->get(meth1)); - JSCallData jsCallData(scope, nullptr, 0); + JSCallData jsCallData(scope, 0); jsCallData->thisObject = *object; if (FunctionObject *o = conv->as<FunctionObject>()) { @@ -982,7 +982,7 @@ ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint ind ReturnedValue Runtime::method_callPossiblyDirectEval(ExecutionEngine *engine, Value *argv, int argc) { Scope scope(engine); - JSCallData callData(scope, argv, argc); + JSCallData callData(scope, argc, argv); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); ExecutionContext &ctx = static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context); @@ -1009,7 +1009,7 @@ ReturnedValue Runtime::method_callPossiblyDirectEval(ExecutionEngine *engine, Va ReturnedValue Runtime::method_callName(ExecutionEngine *engine, int nameIndex, Value *argv, int argc) { Scope scope(engine); - JSCallData callData(scope, argv, argc); + JSCallData callData(scope, argc, argv); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); callData->function = engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]; @@ -1036,7 +1036,7 @@ ReturnedValue Runtime::method_callName(ExecutionEngine *engine, int nameIndex, V ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, Value *base, int nameIndex, Value *argv, int argc) { Scope scope(engine); - JSCallData callData(scope, argv, argc, base); + JSCallData callData(scope, argc, argv, base); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); if (!callData->thisObject.isObject()) { @@ -1070,7 +1070,7 @@ ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, Value *base, ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, Value *base, uint index, Value *argv, int argc) { Scope scope(engine); - JSCallData callData(scope, argv, argc, base); + JSCallData callData(scope, argc, argv, base); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); Q_ASSERT(engine->jsStackTop >= callData->args + callData->argc()); @@ -1087,7 +1087,7 @@ ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, Value ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, Value *base, const Value &index, Value *argv, int argc) { Scope scope(engine); - JSCallData callData(scope, argv, argc, base); + JSCallData callData(scope, argc, argv, base); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); callData->thisObject = callData->thisObject.toObject(engine); @@ -1108,10 +1108,10 @@ ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &fu return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); Scope scope(engine); - JSCallData callData(scope, func.asReturnedValue(), argv, argc); + JSCallData callData(scope, argc, argv); Q_ASSERT(callData->args + callData->argc() == engine->jsStackTop); - return static_cast<FunctionObject &>(callData->function).call(&callData->thisObject, callData->args, callData->argc()); + return static_cast<const FunctionObject &>(func).call(&callData->thisObject, callData->args, callData->argc()); } diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index c0a00032dd..8ca4985b32 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -152,13 +152,13 @@ ReturnedValue Script::run() ContextStateSaver stateSaver(valueScope, context); context->d()->v4Function = vmFunction; - QV4::JSCallData jsCall(valueScope, nullptr); + QV4::JSCallData jsCall(valueScope); jsCall->thisObject = engine->globalObject; jsCall->context = *context; return vmFunction->call(jsCall.callData()); } else { Scoped<QmlContext> qml(valueScope, qmlContext.value()); - JSCallData jsCall(valueScope, nullptr); + JSCallData jsCall(valueScope); jsCall->thisObject = Primitive::undefinedValue(); jsCall->context = *qml; return vmFunction->call(jsCall.callData()); diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 818711fc99..4dd71fe582 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -420,7 +420,7 @@ public: ScopedFunctionObject compare(scope, m_compareFn); if (!compare) return m_v4->throwTypeError(); - JSCallData jsCallData(scope, compare, 2); + JSCallData jsCallData(scope, 2); jsCallData->args[0] = convertElementToValue(m_v4, lhs); jsCallData->args[1] = convertElementToValue(m_v4, rhs); jsCallData->thisObject = m_v4->globalObject; diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 11fdcae6f8..d8bd51ac39 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -583,7 +583,7 @@ ReturnedValue StringPrototype::method_replace(const BuiltinFunction *b, CallData if (!!searchCallback) { result.reserve(string.length() + 10*numStringMatches); ScopedValue entry(scope); - JSCallData jsCallData(scope, searchCallback, numCaptures + 2); + JSCallData jsCallData(scope, numCaptures + 2); jsCallData->thisObject = Primitive::undefinedValue(); int lastEnd = 0; for (int i = 0; i < numStringMatches; ++i) { @@ -644,9 +644,9 @@ ReturnedValue StringPrototype::method_search(const BuiltinFunction *b, CallData RegExpObject *regExp = regExpObj->as<RegExpObject>(); if (!regExp) { - JSCallData jsCallDataData(scope, scope.engine->regExpCtor(), 1); - jsCallDataData->args[0] = regExpObj; - regExpObj = scope.engine->regExpCtor()->callAsConstructor(jsCallDataData); + JSCallData jsCallData(scope, 1); + jsCallData->args[0] = regExpObj; + regExpObj = scope.engine->regExpCtor()->callAsConstructor(jsCallData); if (scope.engine->hasException) return QV4::Encode::undefined(); diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 8583d5da06..631fed426a 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -572,7 +572,7 @@ ReturnedValue TypedArrayPrototype::method_subarray(const BuiltinFunction *builti if (!constructor) return scope.engine->throwTypeError(); - JSCallData jsCallData(scope, constructor, 3); + JSCallData jsCallData(scope, 3); jsCallData->args[0] = buffer; jsCallData->args[1] = Encode(a->d()->byteOffset + begin*a->d()->type->bytesPerElement); jsCallData->args[2] = Encode(newLen); diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 65af68621a..1d7a37fc99 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -193,7 +193,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) int *argsTypes = QQmlMetaObject(m_target).methodParameterTypes(methodIndex, &storage, 0); int argCount = argsTypes ? *argsTypes : 0; - QV4::JSCallData jsCall(scope, nullptr, argCount); + QV4::JSCallData jsCall(scope, argCount); for (int ii = 0; ii < argCount; ++ii) { int type = argsTypes[ii + 1]; //### ideally we would use metaTypeToJS, however it currently gives different results @@ -238,7 +238,7 @@ void QQmlBoundSignalExpression::evaluate(const QList<QVariant> &args) ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. - QV4::JSCallData jsCall(scope, nullptr, args.count()); + QV4::JSCallData jsCall(scope, args.count()); for (int ii = 0; ii < args.count(); ++ii) { jsCall->args[ii] = scope.engine->fromVariant(args[ii]); } diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e64d72a5ca..956083238b 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1547,7 +1547,7 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) QV4::ScopedFunctionObject f(scope, d()->statusChanged); if (f) { - QV4::JSCallData jsCallData(scope, f, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->thisObject = this; jsCallData->args[0] = QV4::Primitive::fromUInt32(s); f->call(jsCallData); diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 9d570f18b0..8b01630628 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -67,7 +67,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); Q_ASSERT(callback); const int argCount = array ? array->getLength() : 0; - QV4::JSCallData jsCallData(scope, callback, argCount); + QV4::JSCallData jsCallData(scope, argCount); jsCallData->thisObject = QV4::Encode::undefined(); for (int i = 0; i < argCount; i++) { diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 015471a13d..0208db2d48 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -185,7 +185,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(bool *isUndefined) { QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_context->engine); QV4::Scope scope(v4); - QV4::JSCallData jsCall(scope, nullptr); + QV4::JSCallData jsCall(scope); return evaluate(jsCall.callData(), isUndefined); } diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index efd67bc446..8b5db2f9f1 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -950,7 +950,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * } const unsigned int parameterCount = function->formalParameterCount(); - QV4::JSCallData jsCallData(scope, function, parameterCount); + QV4::JSCallData jsCallData(scope, parameterCount); jsCallData->thisObject = ep->v8engine()->global(); for (uint ii = 0; ii < parameterCount; ++ii) diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 35c6d2f0b7..f9052d249f 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1576,7 +1576,7 @@ void QQmlXMLHttpRequest::dispatchCallback(Object *thisObj, QQmlContextData *cont return; } - QV4::JSCallData jsCallData(scope, callback); + QV4::JSCallData jsCallData(scope); callback->call(jsCallData); if (scope.engine->hasException) { diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 64949ef5ae..6db1372465 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -248,7 +248,7 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QV4::ScopedString name(scope, m_v4Engine->newString(QStringLiteral("sendMessage"))); QV4::ScopedValue function(scope, QV4::BuiltinFunction::create(globalContext, name, QQuickWorkerScriptEnginePrivate::method_sendMessage)); - QV4::JSCallData jsCallData(scope, createsendconstructor, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = function; jsCallData->thisObject = global(); createsend.set(scope.engine, createsendconstructor->call(jsCallData)); @@ -265,7 +265,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i QV4::ScopedFunctionObject f(scope, createsend.value()); QV4::ScopedValue v(scope); - QV4::JSCallData jsCallData(scope, f, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = QV4::Primitive::fromInt32(id); jsCallData->thisObject = global(); v = f->call(jsCallData); @@ -366,7 +366,7 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d QV4::Scoped<QV4::QmlContext> qmlContext(scope, script->qmlContext.value()); Q_ASSERT(!!qmlContext); - QV4::JSCallData jsCallData(scope, f, 2); + QV4::JSCallData jsCallData(scope, 2); jsCallData->thisObject = workerEngine->global(); jsCallData->args[0] = qmlContext->d()->qml(); // ### jsCallData->args[1] = value; diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 5d5d785f7d..f9b5a7af81 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -729,13 +729,14 @@ void QQuickCanvasItem::updatePolish() QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(qmlEngine(this)); QV4::Scope scope(v4); - QV4::JSCallData jsCall(scope, nullptr, 1); + QV4::ScopedFunctionObject function(scope); + QV4::JSCallData jsCall(scope, 1); jsCall->thisObject = QV4::QObjectWrapper::wrap(v4, this); for (auto it = animationCallbacks.cbegin(), end = animationCallbacks.cend(); it != end; ++it) { - jsCall->function = it.value().value(); + function = it.value().value(); jsCall->args[0] = QV4::Primitive::fromUInt32(QDateTime::currentMSecsSinceEpoch() / 1000); - jsCall.call(); + function->call(jsCall); } } else { diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 206d08e4e9..68da4de37a 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2349,7 +2349,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const scope.engine->catchException(); return true; } - QV4::JSCallData jsCallData(scope, function, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = o; jsCallData->thisObject = engine->global(); function->call(jsCallData); @@ -2379,7 +2379,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::Value &o, return false; QV4::ScopedValue value(scope); - QV4::JSCallData jsCallData(scope, function, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = o; jsCallData->thisObject = engine->global(); value = function->call(jsCallData); @@ -2408,7 +2408,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::Value &o } if (!function) return QV4::Encode::undefined(); - QV4::JSCallData jsCallData(scope, function, 1); + QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = o; jsCallData->thisObject = engine->global(); QV4::ScopedValue result(scope, function->call(jsCallData)); |