diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-21 17:31:22 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | 6f472680ebecb3a4d700eedcf62cb423b05c4fd1 (patch) | |
tree | bc732911a9c353dbac232ebda5a94468e3e261fe /src/qml/types | |
parent | da2f24d8e5c32fe4ed45dcb89aa357465f85fc1e (diff) |
change calling convention for JS function calls
This allows faster pass through of the data if we have
nested calls.
Also make sure we always reserve at least
QV4::Global::ReservedArgumentCount Values on the
stack to avoid stack corruption.
Change-Id: I42976460f1ef11a333d4adda70fba8daac66acf3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 8 | ||||
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 20 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 40e33ceef8..91b20e6d81 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -75,20 +75,20 @@ struct DelegateModelGroupFunction: QV4::FunctionObject isBuiltinFunction = true; } - static QV4::Value construct(QV4::Managed *m, QV4::Value *, int) + static QV4::Value construct(QV4::Managed *m, const QV4::CallData &) { m->engine()->current->throwTypeError(); return QV4::Value::undefinedValue(); } - static QV4::Value call(QV4::Managed *that, const QV4::Value &thisObject, QV4::Value *args, int argc) + static QV4::Value call(QV4::Managed *that, const QV4::CallData &d) { DelegateModelGroupFunction *f = static_cast<DelegateModelGroupFunction *>(that); - QQmlDelegateModelItemObject *o = thisObject.as<QQmlDelegateModelItemObject>(); + QQmlDelegateModelItemObject *o = d.thisObject.as<QQmlDelegateModelItemObject>(); if (!o) that->engine()->current->throwTypeError(QStringLiteral("Not a valid VisualData object")); - QV4::Value v = argc ? args[0] : QV4::Value::undefinedValue(); + QV4::Value v = d.argc ? d.args[0] : QV4::Value::undefinedValue(); return f->code(o->item, f->flag, v); } }; diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 1ec6a45fe0..8822eaecd0 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -233,19 +233,23 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QV4::Value function = QV4::Value::fromObject(m_v4Engine->newBuiltinFunction(m_v4Engine->rootContext, m_v4Engine->newString(QStringLiteral("sendMessage")), QQuickWorkerScriptEnginePrivate::sendMessage)); - QV4::Value args[] = { function }; - createsend = createsendconstructor->call(global(), args, 1); + CALLDATA(1); + d.args[0] = function; + d.thisObject = global(); + createsend = createsendconstructor->call(d); } // Requires handle and context scope QV4::Value QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(int id) { - QV4::Value args[] = { QV4::Value::fromInt32(id) }; QV4::FunctionObject *f = createsend.value().asFunctionObject(); QV4::Value v = QV4::Value::undefinedValue(); QV4::ExecutionContext *ctx = f->internalClass->engine->current; try { - v = f->call(global(), args, 1); + CALLDATA(1); + d.args[0] = QV4::Value::fromInt32(id); + d.thisObject = global(); + v = f->call(d); } catch (QV4::Exception &e) { e.accept(ctx); v = e.value(); @@ -343,11 +347,15 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d QV4::Value value = QV4::Serialize::deserialize(data, workerEngine); - QV4::Value args[] = { script->object.value(), value }; QV4::FunctionObject *f = workerEngine->onmessage.value().asFunctionObject(); QV4::ExecutionContext *ctx = f->internalClass->engine->current; + try { - workerEngine->onmessage.value().asFunctionObject()->call(workerEngine->global(), args, 2); + CALLDATA(2); + d.thisObject = workerEngine->global(); + d.args[0] = script->object.value(); + d.args[1] = value; + f->call(d); } catch (QV4::Exception &e) { e.accept(ctx); QQmlError error; |