From a3688bf41fd42befe7ab83a633dbbd71eda56cd9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 27 Feb 2014 15:59:39 -0600 Subject: Improve memory usage in QML/V4 engine. * Don't create prototype Object for bindings and signal handlers. It is inaccessible and not required. This saves one Object-sized allocation per binding. * Shrink the size of QQmlContextWrapper by removing the v8 member variable. * Shrink the size of QObjectWrapper by moving the destroy identifier to the engine. Change-Id: I76e84e4c0581e97a19d2e959f814ac84d9c431fa Task-number: QTBUG-37134 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcontextwrapper.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/qml/qml/qqmlcontextwrapper.cpp') diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index d221e072f7..1660e3aeb1 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -63,7 +63,7 @@ DEFINE_OBJECT_VTABLE(QmlContextWrapper); QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext) : Object(QV8Engine::getV4(engine)), - v8(engine), readOnly(true), ownsContext(ownsContext), isNullWrapper(false), + readOnly(true), ownsContext(ownsContext), isNullWrapper(false), context(context), scopeObject(scopeObject), idObjectsWrapper(0) { setVTable(staticVTable()); @@ -181,7 +181,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has // context = context->parent // } - QV8Engine *engine = resource->v8; + QV8Engine *engine = v4->v8Engine; QObject *scopeObject = resource->getScopeObject(); @@ -413,7 +413,7 @@ ReturnedValue QmlContextWrapper::idObjectsArray() return idObjectsWrapper->asReturnedValue(); } -ReturnedValue QmlContextWrapper::qmlSingletonWrapper(const StringRef &name) +ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, const StringRef &name) { if (!context->imports) return Encode::undefined(); @@ -423,6 +423,7 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(const StringRef &name) Q_ASSERT(r.isValid()); Q_ASSERT(r.type); Q_ASSERT(r.type->isSingleton()); + Q_ASSERT(v8); QQmlEngine *e = v8->engine(); QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo(); -- cgit v1.2.3