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/jsapi | |
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/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index ec8cc2a1b3..cff760b49b 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -505,19 +505,20 @@ QJSValue QJSValue::call(const QJSValueList &args) ExecutionEngine *engine = d->engine; assert(engine); - QVarLengthArray<Value, 9> arguments(args.length()); + CALLDATA(args.length()); + d.thisObject = Value::fromObject(engine->globalObject); for (int i = 0; i < args.size(); ++i) { if (!args.at(i).d->checkEngine(engine)) { qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine"); return QJSValue(); } - arguments[i] = args.at(i).d->getValue(engine); + d.args[i] = args.at(i).d->getValue(engine); } Value result; QV4::ExecutionContext *ctx = engine->current; try { - result = f->call(Value::fromObject(engine->globalObject), arguments.data(), arguments.size()); + result = f->call(d); } catch (Exception &e) { e.accept(ctx); result = e.value(); @@ -560,19 +561,20 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList return QJSValue(); } - QVarLengthArray<Value, 9> arguments(args.length()); + CALLDATA(args.size()); + d.thisObject = instance.d->getValue(engine); for (int i = 0; i < args.size(); ++i) { if (!args.at(i).d->checkEngine(engine)) { qWarning("QJSValue::call() failed: cannot call function with argument created in a different engine"); return QJSValue(); } - arguments[i] = args.at(i).d->getValue(engine); + d.args[i] = args.at(i).d->getValue(engine); } Value result; QV4::ExecutionContext *ctx = engine->current; try { - result = f->call(instance.d->getValue(engine), arguments.data(), arguments.size()); + result = f->call(d); } catch (Exception &e) { e.accept(ctx); result = e.value(); @@ -608,19 +610,19 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) ExecutionEngine *engine = d->engine; assert(engine); - QVarLengthArray<Value, 9> arguments(args.length()); + CALLDATA(args.size()); for (int i = 0; i < args.size(); ++i) { if (!args.at(i).d->checkEngine(engine)) { qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); return QJSValue(); } - arguments[i] = args.at(i).d->getValue(engine); + d.args[i] = args.at(i).d->getValue(engine); } Value result; QV4::ExecutionContext *ctx = engine->current; try { - result = f->construct(arguments.data(), arguments.size()); + result = f->construct(d); } catch (Exception &e) { e.accept(ctx); result = e.value(); |