From ffebff97a9eee8aacce059a2a671ee634d11064c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 19 Jul 2016 11:19:49 +0200 Subject: Simplify reference management in QV4::Script There's no apparent need to store the refptr to the compilation unit in a persistent value, when the persistent's life time is bound to the life time of the V4::Script. Change-Id: Ib4f3008f45c17a680dbe12ca1f80522fd7f6fdfc Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4script.cpp | 30 ++---------------------------- src/qml/jsruntime/qv4script_p.h | 2 +- 2 files changed, 3 insertions(+), 29 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index e8d562cf4c..97f5cbb786 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -64,30 +64,12 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace Heap { -struct CompilationUnitHolder : Object { - inline CompilationUnitHolder(CompiledData::CompilationUnit *unit); - - QQmlRefPointer unit; -}; - struct QmlBindingWrapper : FunctionObject { QmlBindingWrapper(QV4::QmlContext *scope, Function *f); }; } -struct CompilationUnitHolder : public Object -{ - V4_OBJECT2(CompilationUnitHolder, Object) - V4_NEEDS_DESTROY -}; - -inline -Heap::CompilationUnitHolder::CompilationUnitHolder(CompiledData::CompilationUnit *unit) - : unit(unit) -{ -} - struct QmlBindingWrapper : FunctionObject { V4_OBJECT2(QmlBindingWrapper, FunctionObject) @@ -101,7 +83,6 @@ QT_END_NAMESPACE using namespace QV4; DEFINE_OBJECT_VTABLE(QmlBindingWrapper); -DEFINE_OBJECT_VTABLE(CompilationUnitHolder); Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::QmlContext *scope, Function *f) : Heap::FunctionObject(scope, scope->d()->engine->id_eval(), /*createProto = */ false) @@ -139,7 +120,7 @@ void QmlBindingWrapper::call(const Managed *that, Scope &scope, CallData *callDa Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) - , vmFunction(0), parseAsBinding(true) + , compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true) { if (qml) qmlContext.set(v4, *qml); @@ -147,11 +128,6 @@ Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUn parsed = true; vmFunction = compilationUnit ? compilationUnit->linkToEngine(v4) : 0; - if (vmFunction) { - Scope valueScope(v4); - ScopedObject holder(valueScope, v4->memoryManager->allocObject(compilationUnit)); - compilationUnitHolder.set(v4, holder); - } } Script::~Script() @@ -218,10 +194,8 @@ void Script::parse() QScopedPointer isel(v4->iselFactory->create(QQmlEnginePrivate::get(v4), v4->executableAllocator, &module, &jsGenerator)); if (inheritContext) isel->setUseFastLookups(false); - QQmlRefPointer compilationUnit = isel->compile(); + compilationUnit = isel->compile(); vmFunction = compilationUnit->linkToEngine(v4); - ScopedObject holder(valueScope, v4->memoryManager->allocObject(compilationUnit)); - compilationUnitHolder.set(v4, holder); } if (!vmFunction) { diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index e13388393b..e81bc3049c 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -126,7 +126,7 @@ struct Q_QML_EXPORT Script { bool inheritContext; bool parsed; QV4::PersistentValue qmlContext; - QV4::PersistentValue compilationUnitHolder; + QQmlRefPointer compilationUnit; Function *vmFunction; bool parseAsBinding; -- cgit v1.2.3