aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v4
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-06-25 11:00:31 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-28 14:55:44 +0200
commit04add96a8675ec11cd1d0247c26032f467cb2cc1 (patch)
tree7cfb6d60e4a9b0080993b8ffcb35e575d6066041 /src/qml/qml/v4
parent9b72f5780d2a034fc5a7d103b948b29af2714b9c (diff)
Some optimisations for QV4::Script
Change-Id: I468288a537a1a2fa4c38eb188c7b026a390fe13d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r--src/qml/qml/v4/qv4script.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/qml/qml/v4/qv4script.cpp b/src/qml/qml/v4/qv4script.cpp
index a2277a2903..8c60194af4 100644
--- a/src/qml/qml/v4/qv4script.cpp
+++ b/src/qml/qml/v4/qv4script.cpp
@@ -69,6 +69,9 @@ struct QmlBindingWrapper : FunctionObject
usesArgumentsObject = function->usesArgumentsObject;
needsActivation = function->needsActivation();
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1));
+
+ qmlContext = scope->engine->newQmlContext(this, qml);
+ scope->engine->popContext();
}
static Value call(Managed *that, const Value &, Value *, int);
@@ -78,6 +81,7 @@ struct QmlBindingWrapper : FunctionObject
if (wrapper->qml)
wrapper->qml->mark();
FunctionObject::markObjects(m);
+ wrapper->qmlContext->mark();
}
protected:
@@ -85,6 +89,8 @@ protected:
private:
Object *qml;
+ CallContext *qmlContext;
+
};
DEFINE_MANAGED_VTABLE(QmlBindingWrapper);
@@ -94,10 +100,10 @@ Value QmlBindingWrapper::call(Managed *that, const Value &, Value *, int)
ExecutionEngine *engine = that->engine();
QmlBindingWrapper *This = static_cast<QmlBindingWrapper *>(that);
- ExecutionContext *qmlScope = engine->newQmlContext(This, This->qml);
-
- Value result = This->function->code(qmlScope, This->function->codeData);
-
+ CallContext *ctx = This->qmlContext;
+ std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Value::undefinedValue());
+ engine->pushContext(ctx);
+ Value result = This->function->code(ctx, This->function->codeData);
engine->popContext();
return result;
@@ -107,6 +113,9 @@ Value QmlBindingWrapper::call(Managed *that, const Value &, Value *, int)
void Script::parse()
{
+ if (parsed)
+ return;
+
using namespace QQmlJS;
parsed = true;