summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-11 23:05:02 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-11 23:05:02 (GMT)
commit5e690831db11d5d84dc98589da01bf953f4fe06e (patch)
treec78c970e1f6914c9d0342c5587df7c0a90f8ae9d /src/declarative/qml
parentda91e9315fb553cb22431a29318f4b006ffb1a42 (diff)
downloadQt-5e690831db11d5d84dc98589da01bf953f4fe06e.zip
Qt-5e690831db11d5d84dc98589da01bf953f4fe06e.tar.gz
Qt-5e690831db11d5d84dc98589da01bf953f4fe06e.tar.bz2
Use sub-component metaobjects to improve performance
This reduces the number of runtime-resolved AssignConstant instructions that need to be generated.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlcompiledcomponent.cpp4
-rw-r--r--src/declarative/qml/qmlcompiler.cpp36
-rw-r--r--src/declarative/qml/qmlcompiler_p.h4
-rw-r--r--src/declarative/qml/qmlinstruction_p.h1
-rw-r--r--src/declarative/qml/qmlvme.cpp4
5 files changed, 33 insertions, 16 deletions
diff --git a/src/declarative/qml/qmlcompiledcomponent.cpp b/src/declarative/qml/qmlcompiledcomponent.cpp
index c69af44..bea736a 100644
--- a/src/declarative/qml/qmlcompiledcomponent.cpp
+++ b/src/declarative/qml/qmlcompiledcomponent.cpp
@@ -56,8 +56,8 @@ QmlCompiledComponent::QmlCompiledComponent()
QmlCompiledComponent::~QmlCompiledComponent()
{
- for (int ii = 0; ii < mos.count(); ++ii)
- qFree(mos.at(ii));
+ for (int ii = 0; ii < synthesizedMetaObjects.count(); ++ii)
+ qFree(synthesizedMetaObjects.at(ii));
}
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index c547d31..8e279a5 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -61,6 +61,7 @@
#include <QtCore/qdebug.h>
#include "private/qmlcustomparser_p_p.h"
#include <private/qmlcontext_p.h>
+#include <private/qmlcomponent_p.h>
#include "qmlscriptparser_p.h"
@@ -431,10 +432,10 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory)
cc->customTypeData.clear();
cc->datas.clear();
if (deleteMemory) {
- for (int ii = 0; ii < cc->mos.count(); ++ii)
- qFree(cc->mos.at(ii));
+ for (int ii = 0; ii < cc->synthesizedMetaObjects.count(); ++ii)
+ qFree(cc->synthesizedMetaObjects.at(ii));
}
- cc->mos.clear();
+ cc->synthesizedMetaObjects.clear();
cc->bytecode.clear();
}
@@ -523,6 +524,11 @@ void QmlCompiler::compileTree(Object *tree)
if (!compileObject(tree, 0)) // Compile failed
return;
+ if (tree->metatype)
+ static_cast<QMetaObject &>(output->root) = *tree->metaObject();
+ else
+ static_cast<QMetaObject &>(output->root) = *output->types.at(tree->type).metaObject();
+
QmlInstruction def;
init.line = 0;
def.type = QmlInstruction::SetDefault;
@@ -533,10 +539,8 @@ void QmlCompiler::compileTree(Object *tree)
bool QmlCompiler::compileObject(Object *obj, int ctxt)
{
- if (obj->type != -1) {
- obj->metatype =
- QmlMetaType::metaObjectForType(output->types.at(obj->type).className);
- }
+ if (obj->type != -1)
+ obj->metatype = output->types.at(obj->type).metaObject();
if (output->types.at(obj->type).className == "Component") {
COMPILE_CHECK(compileComponent(obj, ctxt));
@@ -1064,7 +1068,7 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop,
int ctxt)
{
if (v->object->type != -1)
- v->object->metatype = QmlMetaType::metaObjectForType(output->types.at(v->object->type).className);
+ v->object->metatype = output->types.at(v->object->type).metaObject();
if (v->object->metaObject()) {
@@ -1293,10 +1297,10 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj)
obj->extObjectData = builder.toMetaObject();
static_cast<QMetaObject &>(obj->extObject) = *obj->extObjectData;
- output->mos << obj->extObjectData;
+ output->synthesizedMetaObjects << obj->extObjectData;
QmlInstruction store;
store.type = QmlInstruction::StoreMetaObject;
- store.storeMeta.data = output->mos.count() - 1;
+ store.storeMeta.data = output->synthesizedMetaObjects.count() - 1;
store.storeMeta.slotData = slotStart;
store.line = obj->location.start.line;
output->bytecode << store;
@@ -1474,12 +1478,13 @@ QmlCompiledData::~QmlCompiledData()
QmlCompiledData &QmlCompiledData::operator=(const QmlCompiledData &other)
{
types = other.types;
+ root = other.root;
primitives = other.primitives;
floatData = other.floatData;
intData = other.intData;
customTypeData = other.customTypeData;
datas = other.datas;
- mos = other.mos;
+ synthesizedMetaObjects = other.synthesizedMetaObjects;
bytecode = other.bytecode;
return *this;
}
@@ -1503,5 +1508,14 @@ QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const
}
}
+const QMetaObject *QmlCompiledData::TypeReference::metaObject() const
+{
+ if (type)
+ return type->metaObject();
+ else if (component)
+ return &static_cast<QmlComponentPrivate *>(QObjectPrivate::get(component))->cc->root;
+ else
+ return 0;
+}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index b122650..9d2f8f7 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -81,6 +81,7 @@ public:
QmlRefCount *ref;
QObject *createInstance(QmlContext *) const;
+ const QMetaObject *metaObject() const;
};
QList<TypeReference> types;
struct CustomTypeData
@@ -88,12 +89,13 @@ public:
int index;
int type;
};
+ QAbstractDynamicMetaObject root;
QList<QString> primitives;
QList<float> floatData;
QList<int> intData;
QList<CustomTypeData> customTypeData;
QList<QByteArray> datas;
- QList<QMetaObject *> mos;
+ QList<QMetaObject *> synthesizedMetaObjects;
QList<QmlParser::Location> locations;
QList<QmlInstruction> bytecode;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 86bddf8..f465e9f 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -281,6 +281,7 @@ public:
struct {
int count;
int endLine;
+ int metaObject;
} createComponent;
struct {
int id;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index e42b2fc..5e0f257 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -215,7 +215,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
const QList<QmlCompiledComponent::TypeReference> &types = comp->types;
const QList<QString> &primitives = comp->primitives;
const QList<QByteArray> &datas = comp->datas;
- const QList<QMetaObject *> &mos = comp->mos;
+ const QList<QMetaObject *> &synthesizedMetaObjects = comp->synthesizedMetaObjects;;
const QList<QmlCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -334,7 +334,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QFxCompilerTimer<QFxCompiler::InstrStoreMetaObject> cc;
#endif
QObject *target = stack.top();
- new QmlVMEMetaObject(target, mos.at(instr.storeMeta.data), &comp->primitives, instr.storeMeta.slotData, comp);
+ new QmlVMEMetaObject(target, synthesizedMetaObjects.at(instr.storeMeta.data), &comp->primitives, instr.storeMeta.slotData, comp);
}
break;