summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 08:13:44 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 08:13:44 (GMT)
commita06c0fe5a2c9eebf5e7cceb06f64e725b42715bd (patch)
tree93d61bae106349e90959b2e5db3d1f636ad8ccfb /src/declarative
parente7c9b51fecc78d8b2f592013513e07a8c0047a2e (diff)
downloadQt-a06c0fe5a2c9eebf5e7cceb06f64e725b42715bd.zip
Qt-a06c0fe5a2c9eebf5e7cceb06f64e725b42715bd.tar.gz
Qt-a06c0fe5a2c9eebf5e7cceb06f64e725b42715bd.tar.bz2
Remove AssignStackObject instruction
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp26
-rw-r--r--src/declarative/qml/qmlcompiler_p.h2
-rw-r--r--src/declarative/qml/qmlinstruction.cpp3
-rw-r--r--src/declarative/qml/qmlinstruction_p.h2
-rw-r--r--src/declarative/qml/qmlvme.cpp33
5 files changed, 27 insertions, 39 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index ae915db..89a1774 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -675,6 +675,9 @@ bool QmlCompiler::compileComponent(Object *obj, int ctxt)
id.line = idProp->location.start.line;
id.setId.value = pref;
id.setId.save = -1;
+
+ savedTypes.insert(output->bytecode.count(), -1);
+
output->bytecode << id;
}
@@ -936,6 +939,7 @@ bool QmlCompiler::compileIdProperty(QmlParser::Property *prop,
id.line = prop->values.at(0)->location.start.line;
id.setId.value = pref;
id.setId.save = -1;
+ savedTypes.insert(output->bytecode.count(), obj->type);
output->bytecode << id;
obj->id = val.toLatin1();
@@ -1369,6 +1373,7 @@ bool QmlCompiler::compileBinding(const QString &bind, QmlParser::Property *prop,
assign.assignBinding.category = QmlMetaProperty::propertyCategory(mp);
}
+ savedTypes.insert(output->bytecode.count(), prop->type);
output->bytecode << assign;
} else {
@@ -1427,6 +1432,25 @@ int QmlCompiler::optimizeExpressions(int start, int end, int patch)
if (ids.contains(slt) &&
instr.assignBinding.category == QmlMetaProperty::Object) {
int id = ids[slt];
+
+ int idType = savedTypes.value(id);
+ int storeType = savedTypes.value(ii);
+
+ const QMetaObject *idMo = (idType == -1)?&QmlComponent::staticMetaObject:output->types.at(idType).metaObject();
+ const QMetaObject *storeMo =
+ QmlMetaType::rawMetaObjectForType(storeType);
+
+ bool canAssign = false;
+ while (!canAssign && idMo) {
+ if (idMo == storeMo)
+ canAssign = true;
+ else
+ idMo = idMo->superClass();
+ }
+
+ if (!canAssign)
+ continue;
+
int saveId = -1;
if (output->bytecode.at(id).setId.save != -1) {
@@ -1444,7 +1468,7 @@ int QmlCompiler::optimizeExpressions(int start, int end, int patch)
rwinstr.pushProperty.property = prop;
QmlInstruction instr;
- instr.type = QmlInstruction::AssignStackObject;
+ instr.type = QmlInstruction::StoreStackObject;
instr.line = 0;
instr.assignStackObject.property = newInstrs;
instr.assignStackObject.object = saveId;
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index 5ada98a..3280866 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -173,6 +173,8 @@ private:
QList<QmlError> exceptions;
QmlCompiledData *output;
+
+ QHash<int, int> savedTypes;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index 31bd2f5..bb40063 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -166,9 +166,6 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::PushProperty:
qWarning() << idx << "\t" << line << "\t" << "PUSH_PROPERTY" << "\t\t" << instr->pushProperty.property;
break;
- case QmlInstruction::AssignStackObject:
- qWarning() << idx << "\t" << line << "\t" << "ASSIGN_STACK_OBJ" << "\t" << instr->assignStackObject.property << "\t" << instr->assignStackObject.object;
- break;
case QmlInstruction::StoreStackObject:
qWarning() << idx << "\t" << line << "\t" << "STORE_STACK_OBJ" << "\t" << instr->assignStackObject.property << "\t" << instr->assignStackObject.object;
break;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 47a8d76..abefd6c 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -139,10 +139,8 @@ public:
// Expression optimizations
//
// PushProperty - Save the property for later use
- // AssignStackObject - Assign the stack object
// StoreStackObject - Assign the stack object (no checks)
PushProperty, /* pushProperty */
- AssignStackObject, /* assignStackObject */
StoreStackObject /* assignStackObject */
};
QmlInstruction()
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index e2441c6..991c7ad 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -101,7 +101,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) {
Q_DECLARE_PERFORMANCE_METRIC(InstrPopFetchedObject);
Q_DECLARE_PERFORMANCE_METRIC(InstrPopQList);
Q_DECLARE_PERFORMANCE_METRIC(InstrPushProperty);
- Q_DECLARE_PERFORMANCE_METRIC(InstrAssignStackObject);
Q_DECLARE_PERFORMANCE_METRIC(InstrStoreStackObject);
Q_DECLARE_PERFORMANCE_METRIC(Dummy);
}
@@ -141,7 +140,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") {
Q_DEFINE_PERFORMANCE_METRIC(InstrPopFetchedObject, "PopFetchedObject");
Q_DEFINE_PERFORMANCE_METRIC(InstrPopQList, "PopQList");
Q_DEFINE_PERFORMANCE_METRIC(InstrPushProperty, "PushProperty");
- Q_DEFINE_PERFORMANCE_METRIC(InstrAssignStackObject, "AssignStackObject");
Q_DEFINE_PERFORMANCE_METRIC(InstrStoreStackObject, "StoreStackObject");
Q_DEFINE_PERFORMANCE_METRIC(Dummy, "Dummy");
}
@@ -934,37 +932,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
- case QmlInstruction::AssignStackObject:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrAssignStackObject> cc;
-#endif
-
- QObject *obj = savedObjects[instr.assignStackObject.object];
- const QmlMetaProperty &prop =
- pushedProperties.at(instr.assignStackObject.property);
-
-
- const QMetaObject *mo =
- QmlMetaType::rawMetaObjectForType(prop.propertyType());
- const QMetaObject *assignMo = obj->metaObject();
-
- bool found = false;
- while(!found && assignMo) {
- if (assignMo == mo)
- found = true;
- else
- assignMo = assignMo->superClass();
- }
-
- if (!found)
- VME_EXCEPTION("Unable to assign object");
-
- instr.type = QmlInstruction::StoreStackObject;
- --ii;
- }
- break;
-
case QmlInstruction::StoreStackObject:
{
#ifdef Q_ENABLE_PERFORMANCE_LOG