summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 06:48:12 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-26 06:48:12 (GMT)
commit34163a31908ac00cf20ba3c8c885e767bdfbc0e0 (patch)
treef2a26e7162f5f369a5d6f7588e3d17484c19847e /src
parent6fb3a8884701b3a08607d0d8ec2e67fabf56d468 (diff)
downloadQt-34163a31908ac00cf20ba3c8c885e767bdfbc0e0.zip
Qt-34163a31908ac00cf20ba3c8c885e767bdfbc0e0.tar.gz
Qt-34163a31908ac00cf20ba3c8c885e767bdfbc0e0.tar.bz2
Unify the store instructions into the main VME switch
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qmlinstruction_p.h2
-rw-r--r--src/declarative/qml/qmlvme.cpp517
-rw-r--r--src/declarative/qml/qmlvme_p.h3
3 files changed, 249 insertions, 273 deletions
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 8959794..190cab5 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -83,7 +83,6 @@ public:
// StoreObject - Pop the object on the top of the object stack and
// store it in a core property
StoreReal, /* storeReal */
- StoreInstructionsStart = StoreReal,
StoreInteger, /* storeInteger */
StoreBool, /* storeBool */
StoreString, /* storeString */
@@ -99,7 +98,6 @@ public:
StoreRectF, /* storeRect */
StoreVariant, /* storeString */
StoreObject, /* storeObject */
- StoreInstructionsEnd = StoreObject,
StoreVariantObject, /* storeObject */
StoreInterface, /* storeObject */
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 299b969..e9649c5 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -204,6 +204,9 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
const QList<QByteArray> &datas = comp->datas;
const QList<QMetaObject *> &synthesizedMetaObjects = comp->synthesizedMetaObjects;;
const QList<QmlCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
+ const QList<int> &intData = comp->intData;
+ const QList<float> &floatData = comp->floatData;
+
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::CompileRun> cr;
@@ -225,13 +228,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
for (int ii = start; !isError() && ii < (start + count); ++ii) {
QmlInstruction &instr = comp->bytecode[ii];
- if (instr.type >= QmlInstruction::StoreInstructionsStart &&
- instr.type <= QmlInstruction::StoreInstructionsEnd) {
-
- runStoreInstruction(stack, instr, comp);
-
- } else {
-
switch(instr.type) {
case QmlInstruction::Init:
{
@@ -321,6 +317,252 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
+ case QmlInstruction::StoreVariant:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreVariant> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ // XXX - can be more efficient
+ QVariant v = QmlStringConverters::variantFromString(primitives.at(instr.storeString.value));
+ a[0] = (void *)&v;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreString:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreString> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ a[0] = (void *)&primitives.at(instr.storeString.value);
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreReal:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreReal> cc;
+#endif
+ QObject *target = stack.top();
+ //### moc treats qreal properties as having type double
+ double r = static_cast<double>(instr.storeReal.value);
+ void *a[1];
+ a[0] = &r;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeReal.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreBool:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreBool> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ a[0] = (void *)&instr.storeBool.value;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeBool.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreInteger:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreInteger> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ a[0] = (void *)&instr.storeInteger.value;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeReal.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreColor:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreColor> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QColor c = QColor::fromRgba(instr.storeColor.value);
+ a[0] = (void *)&c;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeColor.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreDate:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreDate> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QDate d = QDate::fromJulianDay(instr.storeDate.value);
+ a[0] = (void *)&d;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDate.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreTime:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ //QFxCompilerTimer<QFxCompiler::InstrStoreTime> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QTime t;
+ t.setHMS(intData.at(instr.storeTime.valueIndex),
+ intData.at(instr.storeTime.valueIndex+1),
+ intData.at(instr.storeTime.valueIndex+2),
+ intData.at(instr.storeTime.valueIndex+3));
+ a[0] = (void *)&t;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeTime.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreDateTime:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ //QFxCompilerTimer<QFxCompiler::InstrStoreDateTime> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QTime t;
+ t.setHMS(intData.at(instr.storeDateTime.valueIndex+1),
+ intData.at(instr.storeDateTime.valueIndex+2),
+ intData.at(instr.storeDateTime.valueIndex+3),
+ intData.at(instr.storeDateTime.valueIndex+4));
+ QDateTime dt(QDate::fromJulianDay(intData.at(instr.storeDateTime.valueIndex)), t);
+ a[0] = (void *)&dt;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDateTime.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StorePoint:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStorePoint> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1)).toPoint();
+ a[0] = (void *)&p;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StorePointF:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStorePoint> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QPointF p(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1));
+ a[0] = (void *)&p;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreSize:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreSize> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1)).toSize();
+ a[0] = (void *)&p;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreSizeF:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreSize> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QSizeF s(floatData.at(instr.storeRealPair.valueIndex),
+ floatData.at(instr.storeRealPair.valueIndex+1));
+ a[0] = (void *)&s;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRealPair.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreRect:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ //QFxCompilerTimer<QFxCompiler::InstrStoreRect> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QRect r = QRectF(floatData.at(instr.storeRect.valueIndex),
+ floatData.at(instr.storeRect.valueIndex+1),
+ floatData.at(instr.storeRect.valueIndex+2),
+ floatData.at(instr.storeRect.valueIndex+3)).toRect();
+ a[0] = (void *)&r;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRect.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreRectF:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ //QFxCompilerTimer<QFxCompiler::InstrStoreRect> cc;
+#endif
+ QObject *target = stack.top();
+ void *a[1];
+ QRectF r(floatData.at(instr.storeRect.valueIndex),
+ floatData.at(instr.storeRect.valueIndex+1),
+ floatData.at(instr.storeRect.valueIndex+2),
+ floatData.at(instr.storeRect.valueIndex+3));
+ a[0] = (void *)&r;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeRect.propertyIndex, a);
+ }
+ break;
+
+ case QmlInstruction::StoreObject:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreObject> cc;
+#endif
+ QObject *assignObj = stack.pop();
+ QObject *target = stack.top();
+
+ void *a[1];
+ void *obj = (void *)(((char *)assignObj) + instr.storeObject.cast);
+ a[0] = (void *)&obj;
+
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeObject.propertyIndex, a);
+ }
+ break;
+
+
case QmlInstruction::AssignCustomType:
{
QObject *target = stack.top();
@@ -817,7 +1059,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
qFatal("QmlCompiledComponent: Internal error - unknown instruction %d", instr.type);
break;
}
- }
}
if (isError()) {
@@ -858,264 +1099,4 @@ QList<QmlError> QmlVME::errors() const
return vmeErrors;
}
-void QmlVME::runStoreInstruction(QStack<QObject *> &stack,
- QmlInstruction &instr,
- QmlCompiledData *comp)
-{
- const QList<QString> &primitives = comp->primitives;
- const QList<int> &intData = comp->intData;
- const QList<float> &floatData = comp->floatData;
-
- switch(instr.type) {
- case QmlInstruction::StoreVariant:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreVariant> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- // XXX - can be more efficient
- QVariant v = QmlStringConverters::variantFromString(primitives.at(instr.storeString.value));
- a[0] = (void *)&v;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeString.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreString:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreString> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- a[0] = (void *)&primitives.at(instr.storeString.value);
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeString.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreReal:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreReal> cc;
-#endif
- QObject *target = stack.top();
- //### moc treats qreal properties as having type double
- double r = static_cast<double>(instr.storeReal.value);
- void *a[1];
- a[0] = &r;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeReal.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreBool:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreBool> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- a[0] = (void *)&instr.storeBool.value;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeBool.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreInteger:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreInteger> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- a[0] = (void *)&instr.storeInteger.value;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeReal.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreColor:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreColor> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QColor c = QColor::fromRgba(instr.storeColor.value);
- a[0] = (void *)&c;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeColor.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreDate:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreDate> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QDate d = QDate::fromJulianDay(instr.storeDate.value);
- a[0] = (void *)&d;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeDate.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreTime:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- //QFxCompilerTimer<QFxCompiler::InstrStoreTime> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QTime t;
- t.setHMS(intData.at(instr.storeTime.valueIndex),
- intData.at(instr.storeTime.valueIndex+1),
- intData.at(instr.storeTime.valueIndex+2),
- intData.at(instr.storeTime.valueIndex+3));
- a[0] = (void *)&t;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeTime.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreDateTime:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- //QFxCompilerTimer<QFxCompiler::InstrStoreDateTime> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QTime t;
- t.setHMS(intData.at(instr.storeDateTime.valueIndex+1),
- intData.at(instr.storeDateTime.valueIndex+2),
- intData.at(instr.storeDateTime.valueIndex+3),
- intData.at(instr.storeDateTime.valueIndex+4));
- QDateTime dt(QDate::fromJulianDay(intData.at(instr.storeDateTime.valueIndex)), t);
- a[0] = (void *)&dt;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeDateTime.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StorePoint:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStorePoint> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex),
- floatData.at(instr.storeRealPair.valueIndex+1)).toPoint();
- a[0] = (void *)&p;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRealPair.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StorePointF:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStorePoint> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QPointF p(floatData.at(instr.storeRealPair.valueIndex),
- floatData.at(instr.storeRealPair.valueIndex+1));
- a[0] = (void *)&p;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRealPair.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreSize:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreSize> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex),
- floatData.at(instr.storeRealPair.valueIndex+1)).toSize();
- a[0] = (void *)&p;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRealPair.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreSizeF:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreSize> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QSizeF s(floatData.at(instr.storeRealPair.valueIndex),
- floatData.at(instr.storeRealPair.valueIndex+1));
- a[0] = (void *)&s;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRealPair.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreRect:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- //QFxCompilerTimer<QFxCompiler::InstrStoreRect> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QRect r = QRectF(floatData.at(instr.storeRect.valueIndex),
- floatData.at(instr.storeRect.valueIndex+1),
- floatData.at(instr.storeRect.valueIndex+2),
- floatData.at(instr.storeRect.valueIndex+3)).toRect();
- a[0] = (void *)&r;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRect.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreRectF:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- //QFxCompilerTimer<QFxCompiler::InstrStoreRect> cc;
-#endif
- QObject *target = stack.top();
- void *a[1];
- QRectF r(floatData.at(instr.storeRect.valueIndex),
- floatData.at(instr.storeRect.valueIndex+1),
- floatData.at(instr.storeRect.valueIndex+2),
- floatData.at(instr.storeRect.valueIndex+3));
- a[0] = (void *)&r;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeRect.propertyIndex, a);
- }
- break;
-
- case QmlInstruction::StoreObject:
- {
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxCompilerTimer<QFxCompiler::InstrStoreObject> cc;
-#endif
- QObject *assignObj = stack.pop();
- QObject *target = stack.top();
-
- void *a[1];
- void *obj = (void *)(((char *)assignObj) + instr.storeObject.cast);
- a[0] = (void *)&obj;
-
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeObject.propertyIndex, a);
- }
- break;
- default:
- qFatal("QmlCompiledComponent: Internal error - unknown instruction %d", instr.type);
- break;
- }
-
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
index 4e5c6c1..f2ed576 100644
--- a/src/declarative/qml/qmlvme_p.h
+++ b/src/declarative/qml/qmlvme_p.h
@@ -64,9 +64,6 @@ public:
QList<QmlError> errors() const;
private:
- void runStoreInstruction(QStack<QObject *> &stack,
- QmlInstruction &, QmlCompiledData *);
-
QList<QmlError> vmeErrors;
};