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/qquickworkerscript.cpp | |
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/qquickworkerscript.cpp')
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
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; |