diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-11-14 14:53:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-22 14:54:33 +0100 |
commit | bf173fe5da381c88343296ca33ef6b06389c6d20 (patch) | |
tree | ddcf0b304fea1c4ac76ab0762eb263a27fd6f7f0 /src/qml/jsruntime/qv4script.cpp | |
parent | 855784e5a72cb1a1309bcc832f84e4d0989bfba6 (diff) |
Turn execution contexts into Managed objects
This finally gives proper memory management for ExecutionContexts.
So far they had been garbage collected but where still allocated
using standard malloc/free(). This allows us to collect the
contexts faster and speed up context creation.
Change-Id: I02e642391d55eaa59ab3f4c2720a2ac71259caf4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 25791cff61..2f015ac83a 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -62,11 +62,18 @@ using namespace QV4; QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml) : FunctionObject(scope, scope->engine->id_eval) , qml(qml) + , qmlContext(0) { + Q_ASSERT(scope->inUse); + vtbl = &static_vtbl; function = f; function->compilationUnit->ref(); needsActivation = function->needsActivation(); + + Scope s(scope); + ScopedValue protectThis(s, this); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); qmlContext = scope->engine->current->newQmlContext(this, qml); @@ -76,10 +83,17 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml) : FunctionObject(scope, scope->engine->id_eval) , qml(qml) + , qmlContext(0) { + Q_ASSERT(scope->inUse); + vtbl = &static_vtbl; function = 0; needsActivation = false; + + Scope s(scope); + ScopedValue protectThis(s, this); + defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); qmlContext = scope->engine->current->newQmlContext(this, qml); @@ -110,7 +124,8 @@ void QmlBindingWrapper::markObjects(Managed *m, ExecutionEngine *e) if (wrapper->qml) wrapper->qml->mark(e); FunctionObject::markObjects(m, e); - wrapper->qmlContext->mark(); + if (wrapper->qmlContext) + wrapper->qmlContext->mark(e); } DEFINE_MANAGED_VTABLE(QmlBindingWrapper); |