aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2014-02-27 15:59:39 -0600
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-28 19:01:21 +0100
commita3688bf41fd42befe7ab83a633dbbd71eda56cd9 (patch)
tree042d3b4a4a78f6787a6c641e09ff957b62b40aa5 /src/qml/qml
parent0b2d05093c6fc030d40be8c873ad1e0af9bba8cc (diff)
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp7
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h3
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp2
-rw-r--r--src/qml/qml/qqmlvme.cpp4
4 files changed, 8 insertions, 8 deletions
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();
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 0ecec93652..3facf71aa0 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -97,9 +97,8 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
ReturnedValue idObjectsArray();
- ReturnedValue qmlSingletonWrapper(const StringRef &name);
+ ReturnedValue qmlSingletonWrapper(QV8Engine *e, const StringRef &name);
- QV8Engine *v8; // ### temporary, remove
bool readOnly;
bool ownsContext;
bool isNullWrapper;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 7085915faa..32f3fe73fa 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -743,7 +743,7 @@ bool QQmlObjectCreator::setPropertyBinding(QQmlPropertyData *property, const QV4
QV4::Function *runtimeFunction = compiledData->compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
QV4::Scope scope(_qmlContext);
- QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction));
+ QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::creatScriptFunction(_qmlContext, runtimeFunction, /*createProto*/ false));
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex);
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index ce4997fef9..83c1f6595c 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -800,7 +800,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QV4::Function *runtimeFunction = COMP->compilationUnit->runtimeFunctions[instr.runtimeFunctionIndex];
- tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction);
+ tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false);
QQmlBoundSignal *bs = new QQmlBoundSignal(target, instr.signalIndex, target, engine);
QQmlBoundSignalExpression *expr =
@@ -862,7 +862,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QV4::Function *runtimeFunction = COMP->compilationUnit->runtimeFunctions[instr.functionIndex];
- tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction);
+ tmpValue = QV4::FunctionObject::creatScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false);
QQmlBinding *bind = new QQmlBinding(tmpValue, context, CTXT, COMP->name, instr.line, instr.column);
bindValues.push(bind);