Make the QML/VME interpreter threaded
authorKent Hansen <kent.hansen@nokia.com>
Tue, 20 Sep 2011 09:38:26 +0000 (11:38 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 22 Sep 2011 07:42:43 +0000 (09:42 +0200)
This gets rid of the two-level dispatch in the
interpreter loop, which gives a nice performance boost
when many VME instructions must be interpreted
(e.g., 40% faster for 100 StoreInteger instructions).

The threading is implemented in a similar way to the
V4 interpreter.

The way the compiler generates instructions has been
refactored, chiefly to get rid of the
QDeclarativeInstruction::setType() calls (when using
threading, we don't store the instruction type at all,
only the address).

As a nice bonus, the way instructions are defined now
(creating the specific instruction's data type, rather
than a generic (union) type) is more compact and less
error-prone.

Change-Id: If5cbd36b2526fd61b74854712711b06cd7e1ed7d
Reviewed-on: http://codereview.qt-project.org/5246
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/qdeclarativecompileddata.cpp
src/declarative/qml/qdeclarativecompiler.cpp
src/declarative/qml/qdeclarativecompiler_p.h
src/declarative/qml/qdeclarativeinstruction.cpp
src/declarative/qml/qdeclarativeinstruction_p.h
src/declarative/qml/qdeclarativevme.cpp
src/declarative/qml/qdeclarativevme_p.h
tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp

index c59dd78..a1bdca2 100644 (file)
@@ -45,6 +45,9 @@
 #include "private/qdeclarativecomponent_p.h"
 #include "qdeclarativecontext.h"
 #include "private/qdeclarativecontext_p.h"
+#ifdef QML_THREADED_VME_INTERPRETER
+#include "private/qdeclarativevme_p.h"
+#endif
 
 #include <QtCore/qdebug.h>
 
@@ -192,17 +195,22 @@ void QDeclarativeCompiledData::dumpInstructions()
     while (instructionStream < endInstructionStream) {
         QDeclarativeInstruction *instr = (QDeclarativeInstruction *)instructionStream;
         dump(instr, instructionCount);
-        instructionStream += instr->size();
+        instructionStream += QDeclarativeInstruction::size(instructionType(instr));
         instructionCount++;
     }
 
     qWarning().nospace() << "-------------------------------------------------------------------------------";
 }
 
-int QDeclarativeCompiledData::addInstruction(const QDeclarativeInstruction &instr) 
-{ 
+int QDeclarativeCompiledData::addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr)
+{
+#ifdef QML_THREADED_VME_INTERPRETER
+    instr.common.code = QDeclarativeVME::instructionJumpTable()[static_cast<int>(type)];
+#else
+    instr.common.instructionType = type;
+#endif
     int ptrOffset = bytecode.size();
-    int size = instr.size();
+    int size = QDeclarativeInstruction::size(type);
     if (bytecode.capacity() <= bytecode.size() + size)
         bytecode.reserve(bytecode.size() + size + 512);
     bytecode.append(reinterpret_cast<const char *>(&instr), size);
@@ -219,4 +227,23 @@ QDeclarativeInstruction *QDeclarativeCompiledData::instruction(int index)
     return (QDeclarativeInstruction *)(bytecode.constData() + index);
 }
 
+QDeclarativeInstruction::Type QDeclarativeCompiledData::instructionType(const QDeclarativeInstruction *instr)
+{
+#ifdef QML_THREADED_VME_INTERPRETER
+    void **jumpTable = QDeclarativeVME::instructionJumpTable();
+    void *code = instr->common.code;
+
+#  define QML_CHECK_INSTR_CODE(I, FMT) \
+    if (jumpTable[static_cast<int>(QDeclarativeInstruction::I)] == code) \
+        return QDeclarativeInstruction::I;
+
+    FOR_EACH_QML_INSTR(QML_CHECK_INSTR_CODE)
+    Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address");
+    return static_cast<QDeclarativeInstruction::Type>(0);
+#  undef QML_CHECK_INSTR_CODE
+#else
+    return static_cast<QDeclarativeInstruction::Type>(instr->common.instructionType);
+#endif
+}
+
 QT_END_NAMESPACE
index b6c1f47..fe0375f 100644 (file)
@@ -361,16 +361,14 @@ bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeScript::Property *p
 void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *prop,
                                                 QDeclarativeScript::Value *v)
 {
-    QDeclarativeInstruction instr;
-
     if (prop->core.isEnum()) {
         Q_ASSERT(v->value.isNumber());
         // Preresolved value
         int value = (int)v->value.asNumber();
 
-        instr.setType(QDeclarativeInstruction::StoreInteger);
-        instr.storeInteger.propertyIndex = prop->index;
-        instr.storeInteger.value = value;
+        Instruction::StoreInteger instr;
+        instr.propertyIndex = prop->index;
+        instr.value = value;
         output->addInstruction(instr);
         return;
     }
@@ -382,219 +380,243 @@ void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *pr
             if (v->value.isNumber()) {
                 double n = v->value.asNumber();
                 if (double(int(n)) == n) {
-                    instr.setType(QDeclarativeInstruction::StoreVariantInteger);
-                    instr.storeInteger.propertyIndex = prop->index;
-                    instr.storeInteger.value = int(n);
+                    Instruction::StoreVariantInteger instr;
+                    instr.propertyIndex = prop->index;
+                    instr.value = int(n);
+                    output->addInstruction(instr);
                 } else {
-                    instr.setType(QDeclarativeInstruction::StoreVariantDouble);
-                    instr.storeDouble.propertyIndex = prop->index;
-                    instr.storeDouble.value = n;
+                    Instruction::StoreVariantDouble instr;
+                    instr.propertyIndex = prop->index;
+                    instr.value = n;
+                    output->addInstruction(instr);
                 }
             } else if(v->value.isBoolean()) {
-                instr.setType(QDeclarativeInstruction::StoreVariantBool);
-                instr.storeBool.propertyIndex = prop->index;
-                instr.storeBool.value = v->value.asBoolean();
+                Instruction::StoreVariantBool instr;
+                instr.propertyIndex = prop->index;
+                instr.value = v->value.asBoolean();
+                output->addInstruction(instr);
             } else {
-                instr.setType(QDeclarativeInstruction::StoreVariant);
-                instr.storeString.propertyIndex = prop->index;
-                instr.storeString.value = output->indexForString(v->value.asString());
+                Instruction::StoreVariant instr;
+                instr.propertyIndex = prop->index;
+                instr.value = output->indexForString(v->value.asString());
+                output->addInstruction(instr);
             }
             }
             break;
         case QVariant::String:
             {
-            instr.setType(QDeclarativeInstruction::StoreString);
-            instr.storeString.propertyIndex = prop->index;
-            instr.storeString.value = output->indexForString(v->value.asString());
+            Instruction::StoreString instr;
+            instr.propertyIndex = prop->index;
+            instr.value = output->indexForString(v->value.asString());
+            output->addInstruction(instr);
             }
             break;
         case QVariant::ByteArray:
             {
-            instr.setType(QDeclarativeInstruction::StoreByteArray);
-            instr.storeByteArray.propertyIndex = prop->index;
-            instr.storeByteArray.value = output->indexForByteArray(v->value.asString().toLatin1());
+            Instruction::StoreByteArray instr;
+            instr.propertyIndex = prop->index;
+            instr.value = output->indexForByteArray(v->value.asString().toLatin1());
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Url:
             {
-            instr.setType(QDeclarativeInstruction::StoreUrl);
+            Instruction::StoreUrl instr;
             QString string = v->value.asString();
             QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string));
-            instr.storeUrl.propertyIndex = prop->index;
-            instr.storeUrl.value = output->indexForUrl(u);
+            instr.propertyIndex = prop->index;
+            instr.value = output->indexForUrl(u);
+            output->addInstruction(instr);
             }
             break;
         case QVariant::UInt:
             {
-            instr.setType(QDeclarativeInstruction::StoreInteger);
-            instr.storeInteger.propertyIndex = prop->index;
-            instr.storeInteger.value = uint(v->value.asNumber());
+            Instruction::StoreInteger instr;
+            instr.propertyIndex = prop->index;
+            instr.value = uint(v->value.asNumber());
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Int:
             {
-            instr.setType(QDeclarativeInstruction::StoreInteger);
-            instr.storeInteger.propertyIndex = prop->index;
-            instr.storeInteger.value = int(v->value.asNumber());
+            Instruction::StoreInteger instr;
+            instr.propertyIndex = prop->index;
+            instr.value = int(v->value.asNumber());
+            output->addInstruction(instr);
             }
             break;
         case QMetaType::Float:
             {
-            instr.setType(QDeclarativeInstruction::StoreFloat);
-            instr.storeFloat.propertyIndex = prop->index;
-            instr.storeFloat.value = float(v->value.asNumber());
+            Instruction::StoreFloat instr;
+            instr.propertyIndex = prop->index;
+            instr.value = float(v->value.asNumber());
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Double:
             {
-            instr.setType(QDeclarativeInstruction::StoreDouble);
-            instr.storeDouble.propertyIndex = prop->index;
-            instr.storeDouble.value = v->value.asNumber();
+            Instruction::StoreDouble instr;
+            instr.propertyIndex = prop->index;
+            instr.value = v->value.asNumber();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Color:
             {
+            Instruction::StoreColor instr;
             QColor c = QDeclarativeStringConverters::colorFromString(v->value.asString());
-            instr.setType(QDeclarativeInstruction::StoreColor);
-            instr.storeColor.propertyIndex = prop->index;
-            instr.storeColor.value = c.rgba();
+            instr.propertyIndex = prop->index;
+            instr.value = c.rgba();
+            output->addInstruction(instr);
             }
             break;
 #ifndef QT_NO_DATESTRING
         case QVariant::Date:
             {
+            Instruction::StoreDate instr;
             QDate d = QDeclarativeStringConverters::dateFromString(v->value.asString());
-            instr.setType(QDeclarativeInstruction::StoreDate);
-            instr.storeDate.propertyIndex = prop->index;
-            instr.storeDate.value = d.toJulianDay();
+            instr.propertyIndex = prop->index;
+            instr.value = d.toJulianDay();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Time:
             {
+            Instruction::StoreTime instr;
             QTime time = QDeclarativeStringConverters::timeFromString(v->value.asString());
-            instr.setType(QDeclarativeInstruction::StoreTime);
-            instr.storeTime.propertyIndex = prop->index;
-            Q_ASSERT(sizeof(instr.storeTime.time) == sizeof(QTime));
-            ::memcpy(&instr.storeTime.time, &time, sizeof(QTime));
+            instr.propertyIndex = prop->index;
+            Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
+            ::memcpy(&instr.time, &time, sizeof(QTime));
+            output->addInstruction(instr);
             }
             break;
         case QVariant::DateTime:
             {
+            Instruction::StoreDateTime instr;
             QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(v->value.asString());
             QTime time = dateTime.time();
-            instr.setType(QDeclarativeInstruction::StoreDateTime);
-            instr.storeDateTime.propertyIndex = prop->index;
-            instr.storeDateTime.date = dateTime.date().toJulianDay();
-            Q_ASSERT(sizeof(instr.storeDateTime.time) == sizeof(QTime));
-            ::memcpy(&instr.storeDateTime.time, &time, sizeof(QTime));
+            instr.propertyIndex = prop->index;
+            instr.date = dateTime.date().toJulianDay();
+            Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
+            ::memcpy(&instr.time, &time, sizeof(QTime));
+            output->addInstruction(instr);
             }
             break;
 #endif // QT_NO_DATESTRING
         case QVariant::Point:
             {
+            Instruction::StorePoint instr;
             bool ok;
             QPoint point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok).toPoint();
-            instr.setType(QDeclarativeInstruction::StorePoint);
-            instr.storePoint.propertyIndex = prop->index;
-            instr.storePoint.point.xp = point.x();
-            instr.storePoint.point.yp = point.y();
+            instr.propertyIndex = prop->index;
+            instr.point.xp = point.x();
+            instr.point.yp = point.y();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::PointF:
             {
+            Instruction::StorePointF instr;
             bool ok;
             QPointF point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok);
-            instr.setType(QDeclarativeInstruction::StorePointF);
-            instr.storePointF.propertyIndex = prop->index;
-            instr.storePointF.point.xp = point.x();
-            instr.storePointF.point.yp = point.y();
+            instr.propertyIndex = prop->index;
+            instr.point.xp = point.x();
+            instr.point.yp = point.y();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Size:
             {
+            Instruction::StoreSize instr;
             bool ok;
             QSize size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok).toSize();
-            instr.setType(QDeclarativeInstruction::StoreSize);
-            instr.storeSize.propertyIndex = prop->index;
-            instr.storeSize.size.wd = size.width();
-            instr.storeSize.size.ht = size.height();
+            instr.propertyIndex = prop->index;
+            instr.size.wd = size.width();
+            instr.size.ht = size.height();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::SizeF:
             {
+            Instruction::StoreSizeF instr;
             bool ok;
             QSizeF size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok);
-            instr.setType(QDeclarativeInstruction::StoreSizeF);
-            instr.storeSizeF.propertyIndex = prop->index;
-            instr.storeSizeF.size.wd = size.width();
-            instr.storeSizeF.size.ht = size.height();
+            instr.propertyIndex = prop->index;
+            instr.size.wd = size.width();
+            instr.size.ht = size.height();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Rect:
             {
+            Instruction::StoreRect instr;
             bool ok;
             QRect rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok).toRect();
-            instr.setType(QDeclarativeInstruction::StoreRect);
-            instr.storeRect.propertyIndex = prop->index;
-            instr.storeRect.rect.x1 = rect.left();
-            instr.storeRect.rect.y1 = rect.top();
-            instr.storeRect.rect.x2 = rect.right();
-            instr.storeRect.rect.y2 = rect.bottom();
+            instr.propertyIndex = prop->index;
+            instr.rect.x1 = rect.left();
+            instr.rect.y1 = rect.top();
+            instr.rect.x2 = rect.right();
+            instr.rect.y2 = rect.bottom();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::RectF:
             {
+            Instruction::StoreRectF instr;
             bool ok;
             QRectF rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok);
-            instr.setType(QDeclarativeInstruction::StoreRectF);
-            instr.storeRectF.propertyIndex = prop->index;
-            instr.storeRectF.rect.xp = rect.left();
-            instr.storeRectF.rect.yp = rect.top();
-            instr.storeRectF.rect.w = rect.width();
-            instr.storeRectF.rect.h = rect.height();
+            instr.propertyIndex = prop->index;
+            instr.rect.xp = rect.left();
+            instr.rect.yp = rect.top();
+            instr.rect.w = rect.width();
+            instr.rect.h = rect.height();
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Bool:
             {
+            Instruction::StoreBool instr;
             bool b = v->value.asBoolean();
-            instr.setType(QDeclarativeInstruction::StoreBool);
-            instr.storeBool.propertyIndex = prop->index;
-            instr.storeBool.value = b;
+            instr.propertyIndex = prop->index;
+            instr.value = b;
+            output->addInstruction(instr);
             }
             break;
         case QVariant::Vector3D:
             {
+            Instruction::StoreVector3D instr;
             bool ok;
             QVector3D vector = QDeclarativeStringConverters::vector3DFromString(v->value.asString(), &ok);
-            instr.setType(QDeclarativeInstruction::StoreVector3D);
-            instr.storeVector3D.propertyIndex = prop->index;
-            instr.storeVector3D.vector.xp = vector.x();
-            instr.storeVector3D.vector.yp = vector.y();
-            instr.storeVector3D.vector.zp = vector.z();
+            instr.propertyIndex = prop->index;
+            instr.vector.xp = vector.x();
+            instr.vector.yp = vector.y();
+            instr.vector.zp = vector.z();
+            output->addInstruction(instr);
             }
             break;
     case QVariant::Vector4D:
             {
+            Instruction::StoreVector4D instr;
             bool ok;
             QVector4D vector = QDeclarativeStringConverters::vector4DFromString(v->value.asString(), &ok);
-            instr.setType(QDeclarativeInstruction::StoreVector4D);
-            instr.storeVector4D.propertyIndex = prop->index;
-            instr.storeVector4D.vector.xp = vector.x();
-            instr.storeVector4D.vector.yp = vector.y();
-            instr.storeVector4D.vector.zp = vector.z();
-            instr.storeVector4D.vector.wp = vector.w();
+            instr.propertyIndex = prop->index;
+            instr.vector.xp = vector.x();
+            instr.vector.yp = vector.y();
+            instr.vector.zp = vector.z();
+            instr.vector.wp = vector.w();
+            output->addInstruction(instr);
             }
             break;
         default:
             {
-            instr.setType(QDeclarativeInstruction::AssignCustomType);
-            instr.assignCustomType.propertyIndex = prop->index;
-            instr.assignCustomType.primitive = output->indexForString(v->value.asString());
-            instr.assignCustomType.type = type;
+            Instruction::AssignCustomType instr;
+            instr.propertyIndex = prop->index;
+            instr.primitive = output->indexForString(v->value.asString());
+            instr.type = type;
+            output->addInstruction(instr);
             }
             break;
     }
-    output->addInstruction(instr);
 }
 
 /*!
@@ -710,9 +732,8 @@ void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree)
     foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) {
         importedScriptIndexes.append(script.qualifier);
 
-        QDeclarativeInstruction import;
-        import.setType(QDeclarativeInstruction::StoreImportedScript);
-        import.storeScript.value = output->scripts.count();
+        Instruction::StoreImportedScript import;
+        import.value = output->scripts.count();
 
         QDeclarativeScriptData *scriptData = script.script->scriptData();
         scriptData->addref();
@@ -731,34 +752,30 @@ void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree)
     if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
         return;
 
-    QDeclarativeInstruction init;
-    init.setType(QDeclarativeInstruction::Init);
-    init.init.bindingsSize = compileState->bindings.count();
-    init.init.parserStatusSize = compileState->parserStatusCount;
-    init.init.contextCache = genContextCache();
+    Instruction::Init init;
+    init.bindingsSize = compileState->bindings.count();
+    init.parserStatusSize = compileState->parserStatusCount;
+    init.contextCache = genContextCache();
     if (compileState->compiledBindingData.isEmpty())
-        init.init.compiledBinding = -1;
+        init.compiledBinding = -1;
     else
-        init.init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
+        init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
     output->addInstruction(init);
 
     if (!compileState->v8BindingProgram.isEmpty()) {
-        QDeclarativeInstruction bindings;
-        bindings.setType(QDeclarativeInstruction::InitV8Bindings);
-        bindings.initV8Bindings.program = output->indexForString(compileState->v8BindingProgram);
-        bindings.initV8Bindings.programIndex = compileState->v8BindingProgramIndex;
-        bindings.initV8Bindings.line = compileState->v8BindingProgramLine;
+        Instruction::InitV8Bindings bindings;
+        bindings.program = output->indexForString(compileState->v8BindingProgram);
+        bindings.programIndex = compileState->v8BindingProgramIndex;
+        bindings.line = compileState->v8BindingProgramLine;
         output->addInstruction(bindings);
     }
 
     genObject(tree);
 
-    QDeclarativeInstruction def;
-    def.setType(QDeclarativeInstruction::SetDefault);
+    Instruction::SetDefault def;
     output->addInstruction(def);
 
-    QDeclarativeInstruction done;
-    done.setType(QDeclarativeInstruction::Done);
+    Instruction::Done done;
     output->addInstruction(done);
 
     Q_ASSERT(tree->metatype);
@@ -1004,32 +1021,30 @@ void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj)
     if (obj->custom.isEmpty() && output->types.at(obj->type).type &&
         !output->types.at(obj->type).type->isExtendedType() && obj != compileState->root) {
 
-        QDeclarativeInstruction create;
-        create.setType(QDeclarativeInstruction::CreateSimpleObject);
-        create.createSimple.create = output->types.at(obj->type).type->createFunction();
-        create.createSimple.typeSize = output->types.at(obj->type).type->createSize();
-        create.createSimple.type = obj->type;
-        create.createSimple.line = obj->location.start.line;
-        create.createSimple.column = obj->location.start.column;
+        Instruction::CreateSimpleObject create;
+        create.create = output->types.at(obj->type).type->createFunction();
+        create.typeSize = output->types.at(obj->type).type->createSize();
+        create.type = obj->type;
+        create.line = obj->location.start.line;
+        create.column = obj->location.start.column;
         output->addInstruction(create);
 
     } else {
 
-        QDeclarativeInstruction create;
-        create.setType(QDeclarativeInstruction::CreateObject);
-        create.create.line = obj->location.start.line;
-        create.create.column = obj->location.start.column;
-        create.create.data = -1;
+        Instruction::CreateObject create;
+        create.line = obj->location.start.line;
+        create.column = obj->location.start.column;
+        create.data = -1;
         if (!obj->custom.isEmpty())
-            create.create.data = output->indexForByteArray(obj->custom);
-        create.create.type = obj->type;
-        if (!output->types.at(create.create.type).type && 
+            create.data = output->indexForByteArray(obj->custom);
+        create.type = obj->type;
+        if (!output->types.at(create.type).type &&
             !obj->bindingBitmask.isEmpty()) {
             Q_ASSERT(obj->bindingBitmask.size() % 4 == 0);
-            create.create.bindingBits = 
+            create.bindingBits =
                 output->indexForByteArray(obj->bindingBitmask);
         } else {
-            create.create.bindingBits = -1;
+            create.bindingBits = -1;
         }
         output->addInstruction(create);
 
@@ -1037,11 +1052,10 @@ void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj)
 
     // Setup the synthesized meta object if necessary
     if (!obj->metadata.isEmpty()) {
-        QDeclarativeInstruction meta;
-        meta.setType(QDeclarativeInstruction::StoreMetaObject);
-        meta.storeMeta.data = output->indexForByteArray(obj->metadata);
-        meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
-        meta.storeMeta.propertyCache = output->propertyCaches.count();
+        Instruction::StoreMetaObject meta;
+        meta.data = output->indexForByteArray(obj->metadata);
+        meta.aliasData = output->indexForByteArray(obj->synthdata);
+        meta.propertyCache = output->propertyCaches.count();
 
         QDeclarativePropertyCache *propertyCache = obj->synthCache;
         Q_ASSERT(propertyCache);
@@ -1072,18 +1086,16 @@ void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj)
 
     // Set the object id
     if (!obj->id.isEmpty()) {
-        QDeclarativeInstruction id;
-        id.setType(QDeclarativeInstruction::SetId);
-        id.setId.value = output->indexForString(obj->id);
-        id.setId.index = obj->idIndex;
+        Instruction::SetId id;
+        id.value = output->indexForString(obj->id);
+        id.index = obj->idIndex;
         output->addInstruction(id);
     }
 
     // Begin the class
     if (tr.type && obj->parserStatusCast != -1) {
-        QDeclarativeInstruction begin;
-        begin.setType(QDeclarativeInstruction::BeginObject);
-        begin.begin.castValue = obj->parserStatusCast;
+        Instruction::BeginObject begin;
+        begin.castValue = obj->parserStatusCast;
         output->addInstruction(begin);
     }
 
@@ -1095,14 +1107,13 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
     for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
         Q_ASSERT(prop->scriptStringScope != -1);
         const QString &script = prop->values.first()->value.asScript();
-        QDeclarativeInstruction ss;
-        ss.setType(QDeclarativeInstruction::StoreScriptString);
-        ss.storeScriptString.propertyIndex = prop->index;
-        ss.storeScriptString.value = output->indexForString(script);
-        ss.storeScriptString.scope = prop->scriptStringScope;
-//        ss.storeScriptString.bindingId = rewriteBinding(script, prop->name());
-        ss.storeScriptString.bindingId = rewriteBinding(script, QString()); // XXX
-        ss.storeScriptString.line = prop->location.start.line;
+        Instruction::StoreScriptString ss;
+        ss.propertyIndex = prop->index;
+        ss.value = output->indexForString(script);
+        ss.scope = prop->scriptStringScope;
+//        ss.bindingId = rewriteBinding(script, prop->name());
+        ss.bindingId = rewriteBinding(script, QString()); // XXX
+        ss.line = prop->location.start.line;
         output->addInstruction(ss);
     }
 
@@ -1116,18 +1127,16 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
             genValueProperty(prop, obj);
     }
     if (seenDefer) {
-        QDeclarativeInstruction defer;
-        defer.setType(QDeclarativeInstruction::Defer);
-        defer.defer.deferCount = 0;
+        Instruction::Defer defer;
+        defer.deferCount = 0;
         int deferIdx = output->addInstruction(defer);
         int nextInstructionIndex = output->nextInstructionIndex();
 
-        QDeclarativeInstruction init;
-        init.setType(QDeclarativeInstruction::Init);
-        init.init.bindingsSize = compileState->bindings.count(); // XXX - bigger than necessary
-        init.init.parserStatusSize = compileState->parserStatusCount; // XXX - bigger than necessary
-        init.init.contextCache = -1;
-        init.init.compiledBinding = -1;
+        Instruction::Init init;
+        init.bindingsSize = compileState->bindings.count(); // XXX - bigger than necessary
+        init.parserStatusSize = compileState->parserStatusCount; // XXX - bigger than necessary
+        init.contextCache = -1;
+        init.compiledBinding = -1;
         output->addInstruction(init);
 
         for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
@@ -1136,8 +1145,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
             genValueProperty(prop, obj);
         }
 
-        QDeclarativeInstruction done;
-        done.setType(QDeclarativeInstruction::Done);
+        Instruction::Done done;
         output->addInstruction(done);
 
         output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex;
@@ -1151,22 +1159,20 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
 
             genObject(v->object);
 
-            QDeclarativeInstruction assign;
-            assign.setType(QDeclarativeInstruction::AssignSignalObject);
-            assign.assignSignalObject.line = v->location.start.line;
-            assign.assignSignalObject.signal = output->indexForString(prop->name().toString());
+            Instruction::AssignSignalObject assign;
+            assign.line = v->location.start.line;
+            assign.signal = output->indexForString(prop->name().toString());
             output->addInstruction(assign);
 
         } else if (v->type == Value::SignalExpression) {
 
-            QDeclarativeInstruction store;
-            store.setType(QDeclarativeInstruction::StoreSignal);
-            store.storeSignal.signalIndex = prop->index;
-            store.storeSignal.value =
+            Instruction::StoreSignal store;
+            store.signalIndex = prop->index;
+            store.value =
                 output->indexForString(v->value.asScript().trimmed());
-            store.storeSignal.context = v->signalExpressionContextStack;
-            store.storeSignal.name = output->indexForByteArray(prop->name().toUtf8());
-            store.storeSignal.line = v->location.start.line;
+            store.context = v->signalExpressionContextStack;
+            store.name = output->indexForByteArray(prop->name().toUtf8());
+            store.line = v->location.start.line;
             output->addInstruction(store);
 
         }
@@ -1174,39 +1180,34 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
     }
 
     for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
-        QDeclarativeInstruction fetch;
-        fetch.setType(QDeclarativeInstruction::FetchAttached);
-        fetch.fetchAttached.id = prop->index;
-        fetch.fetchAttached.line = prop->location.start.line;
+        Instruction::FetchAttached fetch;
+        fetch.id = prop->index;
+        fetch.line = prop->location.start.line;
         output->addInstruction(fetch);
 
         genObjectBody(prop->value);
 
-        QDeclarativeInstruction pop;
-        pop.setType(QDeclarativeInstruction::PopFetchedObject);
+        Instruction::PopFetchedObject pop;
         output->addInstruction(pop);
     }
 
     for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) {
-        QDeclarativeInstruction fetch;
-        fetch.setType(QDeclarativeInstruction::FetchObject);
-        fetch.fetch.property = prop->index;
-        fetch.fetch.line = prop->location.start.line;
+        Instruction::FetchObject fetch;
+        fetch.property = prop->index;
+        fetch.line = prop->location.start.line;
         output->addInstruction(fetch);
 
         if (!prop->value->metadata.isEmpty()) {
-            QDeclarativeInstruction meta;
-            meta.setType(QDeclarativeInstruction::StoreMetaObject);
-            meta.storeMeta.data = output->indexForByteArray(prop->value->metadata);
-            meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata);
-            meta.storeMeta.propertyCache = -1;
+            Instruction::StoreMetaObject meta;
+            meta.data = output->indexForByteArray(prop->value->metadata);
+            meta.aliasData = output->indexForByteArray(prop->value->synthdata);
+            meta.propertyCache = -1;
             output->addInstruction(meta);
         }
 
         genObjectBody(prop->value);
 
-        QDeclarativeInstruction pop;
-        pop.setType(QDeclarativeInstruction::PopFetchedObject);
+        Instruction::PopFetchedObject pop;
         output->addInstruction(pop);
     }
 
@@ -1230,11 +1231,10 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj)
 
 void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *prop)
 {
-    QDeclarativeInstruction fetch;
-    fetch.setType(QDeclarativeInstruction::FetchValueType);
-    fetch.fetchValue.property = prop->index;
-    fetch.fetchValue.type = prop->type;
-    fetch.fetchValue.bindingSkipList = 0;
+    Instruction::FetchValueType fetch;
+    fetch.property = prop->index;
+    fetch.type = prop->type;
+    fetch.bindingSkipList = 0;
 
     if (obj->type == -1 || output->types.at(obj->type).component) {
         // We only have to do this if this is a composite type.  If it is a builtin
@@ -1242,7 +1242,7 @@ void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,
         for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) {
             if (!vprop->values.isEmpty()) {
                 Q_ASSERT(vprop->index >= 0 && vprop->index < 32);
-                fetch.fetchValue.bindingSkipList |= (1 << vprop->index);
+                fetch.bindingSkipList |= (1 << vprop->index);
             }
         }
     }
@@ -1253,11 +1253,10 @@ void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,
         genPropertyAssignment(vprop, prop->value, prop);
     }
 
-    QDeclarativeInstruction pop;
-    pop.setType(QDeclarativeInstruction::PopValueType);
-    pop.fetchValue.property = prop->index;
-    pop.fetchValue.type = prop->type;
-    pop.fetchValue.bindingSkipList = 0;
+    Instruction::PopValueType pop;
+    pop.property = prop->index;
+    pop.type = prop->type;
+    pop.bindingSkipList = 0;
     output->addInstruction(pop);
 }
 
@@ -1266,45 +1265,40 @@ void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj)
     QDeclarativeScript::Object *root = obj->defaultProperty->values.first()->object;
     Q_ASSERT(root);
 
-    QDeclarativeInstruction create;
-    create.setType(QDeclarativeInstruction::CreateComponent);
-    create.createComponent.line = root->location.start.line;
-    create.createComponent.column = root->location.start.column;
-    create.createComponent.endLine = root->location.end.line;
+    Instruction::CreateComponent create;
+    create.line = root->location.start.line;
+    create.column = root->location.start.column;
+    create.endLine = root->location.end.line;
     int createInstruction = output->addInstruction(create);
     int nextInstructionIndex = output->nextInstructionIndex();
 
     ComponentCompileState *oldCompileState = compileState;
     compileState = componentState(root);
 
-    QDeclarativeInstruction init;
-    init.setType(QDeclarativeInstruction::Init);
-    init.init.bindingsSize = compileState->bindings.count();
-    init.init.parserStatusSize = compileState->parserStatusCount;
-    init.init.contextCache = genContextCache();
+    Instruction::Init init;
+    init.bindingsSize = compileState->bindings.count();
+    init.parserStatusSize = compileState->parserStatusCount;
+    init.contextCache = genContextCache();
     if (compileState->compiledBindingData.isEmpty())
-        init.init.compiledBinding = -1;
+        init.compiledBinding = -1;
     else
-        init.init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
+        init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData);
     output->addInstruction(init);
 
     if (!compileState->v8BindingProgram.isEmpty()) {
-        QDeclarativeInstruction bindings;
-        bindings.setType(QDeclarativeInstruction::InitV8Bindings);
-        bindings.initV8Bindings.program = output->indexForString(compileState->v8BindingProgram);
-        bindings.initV8Bindings.programIndex = compileState->v8BindingProgramIndex;
-        bindings.initV8Bindings.line = compileState->v8BindingProgramLine;
+        Instruction::InitV8Bindings bindings;
+        bindings.program = output->indexForString(compileState->v8BindingProgram);
+        bindings.programIndex = compileState->v8BindingProgramIndex;
+        bindings.line = compileState->v8BindingProgramLine;
         output->addInstruction(bindings);
     }
 
     genObject(root);
 
-    QDeclarativeInstruction def;
-    def.setType(QDeclarativeInstruction::SetDefault);
+    Instruction::SetDefault def;
     output->addInstruction(def);
 
-    QDeclarativeInstruction done;
-    done.setType(QDeclarativeInstruction::Done);
+    Instruction::Done done;
     output->addInstruction(done);
 
     output->instruction(createInstruction)->createComponent.count = 
@@ -1313,10 +1307,9 @@ void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj)
     compileState = oldCompileState;
 
     if (!obj->id.isEmpty()) {
-        QDeclarativeInstruction id;
-        id.setType(QDeclarativeInstruction::SetId);
-        id.setId.value = output->indexForString(obj->id);
-        id.setId.index = obj->idIndex;
+        Instruction::SetId id;
+        id.value = output->indexForString(obj->id);
+        id.index = obj->idIndex;
         output->addInstruction(id);
     }
 
@@ -1711,11 +1704,10 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop,
 {
     int listType = enginePrivate->listType(prop->type);
 
-    QDeclarativeInstruction fetch;
-    fetch.setType(QDeclarativeInstruction::FetchQList);
-    fetch.fetchQmlList.property = prop->index;
+    Instruction::FetchQList fetch;
+    fetch.property = prop->index;
     bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
-    fetch.fetchQmlList.type = listType;
+    fetch.type = listType;
     output->addInstruction(fetch);
 
     for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) {
@@ -1724,13 +1716,11 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop,
 
             genObject(v->object);
             if (listTypeIsInterface) {
-                QDeclarativeInstruction assign;
-                assign.setType(QDeclarativeInstruction::AssignObjectList);
-                assign.assignObjectList.line = prop->location.start.line;
+                Instruction::AssignObjectList assign;
+                assign.line = prop->location.start.line;
                 output->addInstruction(assign);
             } else {
-                QDeclarativeInstruction store;
-                store.setType(QDeclarativeInstruction::StoreObjectQList);
+                Instruction::StoreObjectQList store;
                 output->addInstruction(store);
             }
 
@@ -1742,8 +1732,7 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop,
 
     }
 
-    QDeclarativeInstruction pop;
-    pop.setType(QDeclarativeInstruction::PopQList);
+    Instruction::PopQList pop;
     output->addInstruction(pop);
 }
 
@@ -1763,26 +1752,23 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *p
 
             if (QDeclarativeMetaType::isInterface(prop->type)) {
 
-                QDeclarativeInstruction store;
-                store.setType(QDeclarativeInstruction::StoreInterface);
-                store.storeObject.line = v->object->location.start.line;
-                store.storeObject.propertyIndex = prop->index;
+                Instruction::StoreInterface store;
+                store.line = v->object->location.start.line;
+                store.propertyIndex = prop->index;
                 output->addInstruction(store);
 
             } else if (prop->type == QMetaType::QVariant) {
 
-                QDeclarativeInstruction store;
-                store.setType(QDeclarativeInstruction::StoreVariantObject);
-                store.storeObject.line = v->object->location.start.line;
-                store.storeObject.propertyIndex = prop->index;
+                Instruction::StoreVariantObject store;
+                store.line = v->object->location.start.line;
+                store.propertyIndex = prop->index;
                 output->addInstruction(store);
 
             } else {
 
-                QDeclarativeInstruction store;
-                store.setType(QDeclarativeInstruction::StoreObject);
-                store.storeObject.line = v->object->location.start.line;
-                store.storeObject.propertyIndex = prop->index;
+                Instruction::StoreObject store;
+                store.line = v->object->location.start.line;
+                store.propertyIndex = prop->index;
                 output->addInstruction(store);
 
             }
@@ -1806,33 +1792,31 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *p
         if (v->type == Value::ValueSource) {
             genObject(v->object);
 
-            QDeclarativeInstruction store;
-            store.setType(QDeclarativeInstruction::StoreValueSource);
+            Instruction::StoreValueSource store;
             if (valueTypeProperty) {
-                store.assignValueSource.property = genValueTypeData(prop, valueTypeProperty);
-                store.assignValueSource.owner = 1;
+                store.property = genValueTypeData(prop, valueTypeProperty);
+                store.owner = 1;
             } else {
-                store.assignValueSource.property = genPropertyData(prop);
-                store.assignValueSource.owner = 0;
+                store.property = genPropertyData(prop);
+                store.owner = 0;
             }
             QDeclarativeType *valueType = toQmlType(v->object);
-            store.assignValueSource.castValue = valueType->propertyValueSourceCast();
+            store.castValue = valueType->propertyValueSourceCast();
             output->addInstruction(store);
 
         } else if (v->type == Value::ValueInterceptor) {
             genObject(v->object);
 
-            QDeclarativeInstruction store;
-            store.setType(QDeclarativeInstruction::StoreValueInterceptor);
+            Instruction::StoreValueInterceptor store;
             if (valueTypeProperty) {
-                store.assignValueInterceptor.property = genValueTypeData(prop, valueTypeProperty);
-                store.assignValueInterceptor.owner = 1;
+                store.property = genValueTypeData(prop, valueTypeProperty);
+                store.owner = 1;
             } else {
-                store.assignValueInterceptor.property = genPropertyData(prop);
-                store.assignValueInterceptor.owner = 0;
+                store.property = genPropertyData(prop);
+                store.owner = 0;
             }
             QDeclarativeType *valueType = toQmlType(v->object);
-            store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
+            store.castValue = valueType->propertyValueInterceptorCast();
             output->addInstruction(store);
         }
 
@@ -3076,42 +3060,36 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
 
     const BindingReference &ref = *binding->bindingReference;
     if (ref.dataType == BindingReference::V4) {
-        QDeclarativeInstruction store;
-        store.setType(QDeclarativeInstruction::StoreV4Binding);
-        store.assignBinding.value = ref.compiledIndex;
-        store.assignBinding.context = ref.bindingContext.stack;
-        store.assignBinding.owner = ref.bindingContext.owner;
+        Instruction::StoreV4Binding store;
+        store.value = ref.compiledIndex;
+        store.context = ref.bindingContext.stack;
+        store.owner = ref.bindingContext.owner;
         if (valueTypeProperty) 
-            store.assignBinding.property = (valueTypeProperty->index & 0xFFFF) |
-                                           ((valueTypeProperty->type & 0xFF)) << 16 |
-                                           ((prop->index & 0xFF) << 24);
+            store.property = (valueTypeProperty->index & 0xFFFF) |
+                             ((valueTypeProperty->type & 0xFF)) << 16 |
+                             ((prop->index & 0xFF) << 24);
         else 
-            store.assignBinding.property = prop->index;
-        store.assignBinding.line = binding->location.start.line;
+            store.property = prop->index;
+        store.line = binding->location.start.line;
         output->addInstruction(store);
     } else if (ref.dataType == BindingReference::V8) {
-        QDeclarativeInstruction store;
-        store.setType(QDeclarativeInstruction::StoreV8Binding);
-        store.assignBinding.value = ref.compiledIndex;
-        store.assignBinding.context = ref.bindingContext.stack;
-        store.assignBinding.owner = ref.bindingContext.owner;
-        store.assignBinding.line = binding->location.start.line;
+        Instruction::StoreV8Binding store;
+        store.value = ref.compiledIndex;
+        store.context = ref.bindingContext.stack;
+        store.owner = ref.bindingContext.owner;
+        store.line = binding->location.start.line;
 
         Q_ASSERT(ref.bindingContext.owner == 0 ||
                  (ref.bindingContext.owner != 0 && valueTypeProperty));
         if (ref.bindingContext.owner) {
-            store.assignBinding.property = genValueTypeData(prop, valueTypeProperty);
+            store.property = genValueTypeData(prop, valueTypeProperty);
         } else {
-            store.assignBinding.property = genPropertyData(prop);
+            store.property = genPropertyData(prop);
         }
 
         output->addInstruction(store);
     } else {
         QDeclarativeInstruction store;
-        if (!prop->isAlias)
-            store.setType(QDeclarativeInstruction::StoreBinding);
-        else
-            store.setType(QDeclarativeInstruction::StoreBindingOnAlias);
         store.assignBinding.value = output->indexForString(ref.rewrittenExpression);
         store.assignBinding.context = ref.bindingContext.stack;
         store.assignBinding.owner = ref.bindingContext.owner;
@@ -3124,7 +3102,10 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *bindi
         } else {
             store.assignBinding.property = genPropertyData(prop);
         }
-        output->addInstruction(store);
+        output->addInstructionHelper(
+            !prop->isAlias ? QDeclarativeInstruction::StoreBinding
+                           : QDeclarativeInstruction::StoreBindingOnAlias
+            , store);
     }
 }
 
index 0e159a2..a4def99 100644 (file)
@@ -117,16 +117,32 @@ public:
     QList<QDeclarativeScriptData *> scripts;
     QList<QUrl> urls;
 
+    struct Instruction {
+#define QML_INSTR_DATA_TYPEDEF(I, FMT) typedef QDeclarativeInstructionData<QDeclarativeInstruction::I> I;
+    FOR_EACH_QML_INSTR(QML_INSTR_DATA_TYPEDEF)
+#undef QML_INSTR_DATA_TYPEDEF
+    private:
+        Instruction();
+    };
+
     void dumpInstructions();
 
-    int addInstruction(const QDeclarativeInstruction &instr);
+    template <int Instr>
+    int addInstruction(const QDeclarativeInstructionData<Instr> &data)
+    {
+        QDeclarativeInstruction genericInstr;
+        QDeclarativeInstructionMeta<Instr>::setData(genericInstr, data);
+        return addInstructionHelper(static_cast<QDeclarativeInstruction::Type>(Instr), genericInstr);
+    }
     int nextInstructionIndex();
     QDeclarativeInstruction *instruction(int index);
+    QDeclarativeInstruction::Type instructionType(const QDeclarativeInstruction *instr);
 
 protected:
     virtual void clear(); // From QDeclarativeCleanup
 
 private:
+    int addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr);
     void dump(QDeclarativeInstruction *, int idx = -1);
     QDeclarativeCompiledData(const QDeclarativeCompiledData &other);
     QDeclarativeCompiledData &operator=(const QDeclarativeCompiledData &other);
@@ -238,6 +254,8 @@ public:
     int rewriteBinding(const QString& expression, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
 
 private:
+    typedef QDeclarativeCompiledData::Instruction Instruction;
+
     static void reset(QDeclarativeCompiledData *);
 
     void compileTree(QDeclarativeScript::Object *tree);
index f5bd6e9..3093ddc 100644 (file)
@@ -53,7 +53,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
     Q_UNUSED(instr)
     Q_UNUSED(idx)
 #else
-    switch(instr->type()) {
+    switch (instructionType(instr)) {
     case QDeclarativeInstruction::Init:
         qWarning().nospace() << idx << "\t\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
         break;
@@ -226,16 +226,16 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
         qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
         break;
     default:
-        qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instr->type();
+        qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instructionType(instr);
         break;
     }
 #endif // QT_NO_DEBUG_STREAM
 }
 
-int QDeclarativeInstruction::size() const
+int QDeclarativeInstruction::size(Type type)
 {
 #define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QDeclarativeInstructionMeta<(int)I>::Size;
-    switch (common.instructionType) {
+    switch (type) {
     FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
     default: return 0;
     }
index f980027..35de8b2 100644 (file)
@@ -116,13 +116,22 @@ QT_BEGIN_NAMESPACE
     F(FetchValueType, fetchValue) \
     F(PopValueType, fetchValue) 
 
+#if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200)
+#  define QML_THREADED_VME_INTERPRETER
+#endif
+
 #ifdef Q_ALIGNOF
 #  define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QDeclarativeInstruction) - 1)
 #else
 #  define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
 #endif
 
-#define QML_INSTR_HEADER quint8 instructionType;
+#ifdef QML_THREADED_VME_INTERPRETER
+#  define QML_INSTR_HEADER void *code;
+#else
+#  define QML_INSTR_HEADER quint8 instructionType;
+#endif
+
 #define QML_INSTR_ENUM(I, FMT)  I,
 #define QML_INSTR_SIZE(I, FMT) ((sizeof(QDeclarativeInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
 
@@ -133,9 +142,6 @@ union QDeclarativeInstruction
         FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
     };
 
-    inline void setType(Type type) { common.instructionType = type; }
-    inline Type type() const { return (Type)common.instructionType; }
-
     struct instr_common {
         QML_INSTR_HEADER
     };
@@ -461,7 +467,7 @@ union QDeclarativeInstruction
     instr_defer defer;
     instr_assignObjectList assignObjectList;
 
-    int size() const;
+    static int size(Type type);
 };
 
 template<int N>
@@ -473,10 +479,16 @@ struct QDeclarativeInstructionMeta {
         enum { Size = QML_INSTR_SIZE(I, FMT) }; \
         typedef QDeclarativeInstruction::instr_##FMT DataType; \
         static const DataType &data(const QDeclarativeInstruction &instr) { return instr.FMT; } \
+        static void setData(QDeclarativeInstruction &instr, const DataType &v) { instr.FMT = v; } \
     }; 
 FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
 #undef QML_INSTR_META_TEMPLATE
 
+template<int Instr>
+class QDeclarativeInstructionData : public QDeclarativeInstructionMeta<Instr>::DataType
+{
+};
+
 QT_END_NAMESPACE
 
 #endif // QDECLARATIVEINSTRUCTION_P_H
index 79ff822..4ed7cf4 100644 (file)
@@ -166,22 +166,55 @@ static void removeBindingOnProperty(QObject *o, int index)
     if (binding) binding->destroy();
 }
 
-#define QML_BEGIN_INSTR(I) \
-    case QDeclarativeInstruction::I: { \
-        const QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::DataType &instr = QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::data(genericInstr); \
-        instructionStream += QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::Size; \
-        Q_UNUSED(instr); 
+#define QML_BEGIN_INSTR_COMMON(I) { \
+    const QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::DataType &instr = QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::data(*genericInstr); \
+    instructionStream += QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::Size; \
+    Q_UNUSED(instr);
+
+#ifdef QML_THREADED_VME_INTERPRETER
+#  define QML_BEGIN_INSTR(I) op_##I: \
+    QML_BEGIN_INSTR_COMMON(I)
+
+#  define QML_NEXT_INSTR(I) { \
+    genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(instructionStream); \
+    goto *genericInstr->common.code; \
+    }
+
+#  define QML_END_INSTR(I) } \
+    genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(instructionStream); \
+    goto *genericInstr->common.code;
 
-#define QML_NEXT_INSTR(I) break;
-#define QML_END_INSTR(I) } break;
+#else
+#  define QML_BEGIN_INSTR(I) \
+    case QDeclarativeInstruction::I: \
+    QML_BEGIN_INSTR_COMMON(I)
+
+#  define QML_NEXT_INSTR(I) break;
+#  define QML_END_INSTR(I) } break;
+#endif
 
 #define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index)
 
 QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack, 
                               QDeclarativeContextData *ctxt, 
                               QDeclarativeCompiledData *comp, 
-                              int start, const QBitField &bindingSkipList)
+                              int start, const QBitField &bindingSkipList
+#ifdef QML_THREADED_VME_INTERPRETER
+                              , void ***storeJumpTable
+#endif
+                              )
 {
+#ifdef QML_THREADED_VME_INTERPRETER
+    if (storeJumpTable) {
+#define QML_INSTR_ADDR(I, FMT) &&op_##I,
+        static void *jumpTable[] = {
+            FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
+        };
+#undef QML_INSTR_ADDR
+        *storeJumpTable = jumpTable;
+        return 0;
+    }
+#endif
     Q_ASSERT(comp);
     Q_ASSERT(ctxt);
     const QList<QDeclarativeCompiledData::TypeReference> &types = comp->types;
@@ -205,10 +238,15 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack,
 
     const char *instructionStream = comp->bytecode.constData() + start;
 
+#ifdef QML_THREADED_VME_INTERPRETER
+    const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(instructionStream);
+    goto *genericInstr->common.code;
+#else
     for (;;) {
-        const QDeclarativeInstruction &genericInstr = *((QDeclarativeInstruction *)instructionStream);
+        const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(instructionStream);
 
-        switch(genericInstr.type()) {
+        switch (genericInstr->common.instructionType) {
+#endif
         QML_BEGIN_INSTR(Init)
             if (instr.bindingsSize) 
                 bindValues = QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding>(instr.bindingsSize);
@@ -966,11 +1004,15 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack,
             valueHandler->write(target, instr.property, QDeclarativePropertyPrivate::BypassInterceptor);
         QML_END_INSTR(PopValueType)
 
+#ifdef QML_THREADED_VME_INTERPRETER
+    // nothing to do
+#else
         default:
-            qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", genericInstr.type());
+            qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", genericInstr->common.instructionType);
             break;
         }
     }
+#endif
 
     exceptionExit:
     Q_ASSERT(isError());
@@ -1109,6 +1151,19 @@ v8::Persistent<v8::Object> QDeclarativeVME::run(QDeclarativeContextData *parentC
     return rv;
 }
 
+#ifdef QML_THREADED_VME_INTERPRETER
+void **QDeclarativeVME::instructionJumpTable()
+{
+    static void **jumpTable = 0;
+    if (!jumpTable) {
+        QDeclarativeVME dummy;
+        QDeclarativeVMEObjectStack stack;
+        dummy.run(stack, 0, 0, 0, QBitField(), &jumpTable);
+    }
+    return jumpTable;
+}
+#endif
+
 template<typename T>
 QDeclarativeVMEStack<T>::QDeclarativeVMEStack()
 : _index(-1)
index d0c98d4..a0dae77 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "qdeclarativeerror.h"
 #include "private/qbitfield_p.h"
+#include "private/qdeclarativeinstruction_p.h"
 
 #include <QtCore/QString>
 #include <QtCore/QStack>
@@ -89,8 +90,17 @@ private:
 
     QObject *run(QDeclarativeVMEObjectStack &, 
                  QDeclarativeContextData *, QDeclarativeCompiledData *, 
-                 int start, const QBitField &);
+                 int start, const QBitField &
+#ifdef QML_THREADED_VME_INTERPRETER
+                 , void ***storeJumpTable = 0
+#endif
+                 );
     QList<QDeclarativeError> vmeErrors;
+
+#ifdef QML_THREADED_VME_INTERPRETER
+    static void **instructionJumpTable();
+    friend class QDeclarativeCompiledData;
+#endif
 };
 
 QT_END_NAMESPACE
index f432cbf..98c5f7d 100644 (file)
@@ -77,12 +77,11 @@ void tst_qdeclarativeinstruction::dump()
 {
     QDeclarativeCompiledData *data = new QDeclarativeCompiledData(0);
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::Init);
-        i.init.bindingsSize = 0;
-        i.init.parserStatusSize = 3;
-        i.init.contextCache = -1;
-        i.init.compiledBinding = -1;
+        QDeclarativeCompiledData::Instruction::Init i;
+        i.bindingsSize = 0;
+        i.parserStatusSize = 3;
+        i.contextCache = -1;
+        i.compiledBinding = -1;
         data->addInstruction(i);
     }
 
@@ -91,417 +90,367 @@ void tst_qdeclarativeinstruction::dump()
         ref.className = "Test";
         data->types << ref;
 
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::CreateObject);
-        i.create.type = 0;
-        i.create.data = -1;
-        i.create.bindingBits = -1;
-        i.create.column = 10;
+        QDeclarativeCompiledData::Instruction::CreateObject i;
+        i.type = 0;
+        i.data = -1;
+        i.bindingBits = -1;
+        i.column = 10;
         data->addInstruction(i);
     }
 
     {
         data->primitives << "testId";
 
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::SetId);
-        i.setId.value = data->primitives.count() - 1;
-        i.setId.index = 0;
+        QDeclarativeCompiledData::Instruction::SetId i;
+        i.value = data->primitives.count() - 1;
+        i.index = 0;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::SetDefault);
+        QDeclarativeCompiledData::Instruction::SetDefault i;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::CreateComponent);
-        i.createComponent.count = 3;
-        i.createComponent.column = 4;
-        i.createComponent.endLine = 14;
-        i.createComponent.metaObject = 0;
+        QDeclarativeCompiledData::Instruction::CreateComponent i;
+        i.count = 3;
+        i.column = 4;
+        i.endLine = 14;
+        i.metaObject = 0;
 
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreMetaObject);
-        i.storeMeta.data = 3;
-        i.storeMeta.aliasData = 6;
-        i.storeMeta.propertyCache = 7;
+        QDeclarativeCompiledData::Instruction::StoreMetaObject i;
+        i.data = 3;
+        i.aliasData = 6;
+        i.propertyCache = 7;
 
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreFloat);
-        i.storeFloat.propertyIndex = 3;
-        i.storeFloat.value = 11.3;
+        QDeclarativeCompiledData::Instruction::StoreFloat i;
+        i.propertyIndex = 3;
+        i.value = 11.3;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreDouble);
-        i.storeDouble.propertyIndex = 4;
-        i.storeDouble.value = 14.8;
+        QDeclarativeCompiledData::Instruction::StoreDouble i;
+        i.propertyIndex = 4;
+        i.value = 14.8;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreInteger);
-        i.storeInteger.propertyIndex = 5;
-        i.storeInteger.value = 9;
+        QDeclarativeCompiledData::Instruction::StoreInteger i;
+        i.propertyIndex = 5;
+        i.value = 9;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreBool);
-        i.storeBool.propertyIndex = 6;
-        i.storeBool.value = true;
+        QDeclarativeCompiledData::Instruction::StoreBool i;
+        i.propertyIndex = 6;
+        i.value = true;
 
         data->addInstruction(i);
     }
 
     {
         data->primitives << "Test String";
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreString);
-        i.storeString.propertyIndex = 7;
-        i.storeString.value = data->primitives.count() - 1;
+        QDeclarativeCompiledData::Instruction::StoreString i;
+        i.propertyIndex = 7;
+        i.value = data->primitives.count() - 1;
         data->addInstruction(i);
     }
 
     {
         data->urls << QUrl("http://www.nokia.com");
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreUrl);
-        i.storeUrl.propertyIndex = 8;
-        i.storeUrl.value = data->urls.count() - 1;
+        QDeclarativeCompiledData::Instruction::StoreUrl i;
+        i.propertyIndex = 8;
+        i.value = data->urls.count() - 1;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreColor);
-        i.storeColor.propertyIndex = 9;
-        i.storeColor.value = 0xFF00FF00;
+        QDeclarativeCompiledData::Instruction::StoreColor i;
+        i.propertyIndex = 9;
+        i.value = 0xFF00FF00;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreDate);
-        i.storeDate.propertyIndex = 10;
-        i.storeDate.value = 9;
+        QDeclarativeCompiledData::Instruction::StoreDate i;
+        i.propertyIndex = 10;
+        i.value = 9;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreTime);
-        i.storeTime.propertyIndex = 11;
+        QDeclarativeCompiledData::Instruction::StoreTime i;
+        i.propertyIndex = 11;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreDateTime);
-        i.storeDateTime.propertyIndex = 12;
+        QDeclarativeCompiledData::Instruction::StoreDateTime i;
+        i.propertyIndex = 12;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StorePoint);
-        i.storePoint.propertyIndex = 13;
-        i.storePoint.point.xp = 3;
-        i.storePoint.point.yp = 7;
+        QDeclarativeCompiledData::Instruction::StorePoint i;
+        i.propertyIndex = 13;
+        i.point.xp = 3;
+        i.point.yp = 7;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StorePointF);
-        i.storePointF.propertyIndex = 13;
-        i.storePointF.point.xp = 3;
-        i.storePointF.point.yp = 7;
+        QDeclarativeCompiledData::Instruction::StorePointF i;
+        i.propertyIndex = 13;
+        i.point.xp = 3;
+        i.point.yp = 7;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreSize);
-        i.storeSize.propertyIndex = 15;
-        i.storeSize.size.wd = 8;
-        i.storeSize.size.ht = 11;
+        QDeclarativeCompiledData::Instruction::StoreSize i;
+        i.propertyIndex = 15;
+        i.size.wd = 8;
+        i.size.ht = 11;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreSizeF);
-        i.storeSizeF.propertyIndex = 15;
-        i.storeSizeF.size.wd = 8;
-        i.storeSizeF.size.ht = 11;
+        QDeclarativeCompiledData::Instruction::StoreSizeF i;
+        i.propertyIndex = 15;
+        i.size.wd = 8;
+        i.size.ht = 11;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreRect);
-        i.storeRect.propertyIndex = 17;
-        i.storeRect.rect.x1 = 7;
-        i.storeRect.rect.y1 = 9;
-        i.storeRect.rect.x2 = 11;
-        i.storeRect.rect.y2 = 13;
+        QDeclarativeCompiledData::Instruction::StoreRect i;
+        i.propertyIndex = 17;
+        i.rect.x1 = 7;
+        i.rect.y1 = 9;
+        i.rect.x2 = 11;
+        i.rect.y2 = 13;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreRectF);
-        i.storeRectF.propertyIndex = 18;
-        i.storeRectF.rect.xp = 11.3;
-        i.storeRectF.rect.yp = 9.8;
-        i.storeRectF.rect.w = 3;
-        i.storeRectF.rect.h = 2.1;
+        QDeclarativeCompiledData::Instruction::StoreRectF i;
+        i.propertyIndex = 18;
+        i.rect.xp = 11.3;
+        i.rect.yp = 9.8;
+        i.rect.w = 3;
+        i.rect.h = 2.1;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreVector3D);
-        i.storeVector3D.propertyIndex = 19;
-        i.storeVector3D.vector.xp = 9;
-        i.storeVector3D.vector.yp = 3;
-        i.storeVector3D.vector.zp = 92;
+        QDeclarativeCompiledData::Instruction::StoreVector3D i;
+        i.propertyIndex = 19;
+        i.vector.xp = 9;
+        i.vector.yp = 3;
+        i.vector.zp = 92;
         data->addInstruction(i);
     }
 
     {
         data->primitives << "color(1, 1, 1, 1)";
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreVariant);
-        i.storeString.propertyIndex = 20;
-        i.storeString.value = data->primitives.count() - 1;
+        QDeclarativeCompiledData::Instruction::StoreVariant i;
+        i.propertyIndex = 20;
+        i.value = data->primitives.count() - 1;
 
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreObject);
-        i.storeObject.propertyIndex = 21;
+        QDeclarativeCompiledData::Instruction::StoreObject i;
+        i.propertyIndex = 21;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreVariantObject);
-        i.storeObject.propertyIndex = 22;
+        QDeclarativeCompiledData::Instruction::StoreVariantObject i;
+        i.propertyIndex = 22;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreInterface);
-        i.storeObject.propertyIndex = 23;
+        QDeclarativeCompiledData::Instruction::StoreInterface i;
+        i.propertyIndex = 23;
         data->addInstruction(i);
     }
 
     {
         data->primitives << "console.log(1921)";
 
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreSignal);
-        i.storeSignal.signalIndex = 2;
-        i.storeSignal.value = data->primitives.count() - 1;
+        QDeclarativeCompiledData::Instruction::StoreSignal i;
+        i.signalIndex = 2;
+        i.value = data->primitives.count() - 1;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreScriptString);
-        i.storeScriptString.propertyIndex = 24;
-        i.storeScriptString.value = 3;
-        i.storeScriptString.scope = 1;
-        i.storeScriptString.bindingId = 4;
+        QDeclarativeCompiledData::Instruction::StoreScriptString i;
+        i.propertyIndex = 24;
+        i.value = 3;
+        i.scope = 1;
+        i.bindingId = 4;
         data->addInstruction(i);
     }
 
     {
         data->datas << "mySignal";
 
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::AssignSignalObject);
-        i.assignSignalObject.signal = 0;
+        QDeclarativeCompiledData::Instruction::AssignSignalObject i;
+        i.signal = 0;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::AssignCustomType);
-        i.assignCustomType.propertyIndex = 25;
-        i.assignCustomType.primitive = 6;
-        i.assignCustomType.type = 9;
+        QDeclarativeCompiledData::Instruction::AssignCustomType i;
+        i.propertyIndex = 25;
+        i.primitive = 6;
+        i.type = 9;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreBinding);
-        i.assignBinding.property = 26;
-        i.assignBinding.value = 3;
-        i.assignBinding.context = 2;
-        i.assignBinding.owner = 0;
+        QDeclarativeCompiledData::Instruction::StoreBinding i;
+        i.property = 26;
+        i.value = 3;
+        i.context = 2;
+        i.owner = 0;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreV4Binding);
-        i.assignBinding.property = 27;
-        i.assignBinding.value = 2;
-        i.assignBinding.context = 4;
-        i.assignBinding.owner = 0;
+        QDeclarativeCompiledData::Instruction::StoreV4Binding i;
+        i.property = 27;
+        i.value = 2;
+        i.context = 4;
+        i.owner = 0;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreValueSource);
-        i.assignValueSource.property = 29;
-        i.assignValueSource.owner = 1;
-        i.assignValueSource.castValue = 4;
+        QDeclarativeCompiledData::Instruction::StoreValueSource i;
+        i.property = 29;
+        i.owner = 1;
+        i.castValue = 4;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreValueInterceptor);
-        i.assignValueInterceptor.property = 30;
-        i.assignValueInterceptor.owner = 2;
-        i.assignValueInterceptor.castValue = -4;
+        QDeclarativeCompiledData::Instruction::StoreValueInterceptor i;
+        i.property = 30;
+        i.owner = 2;
+        i.castValue = -4;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::BeginObject);
-        i.begin.castValue = 4;
+        QDeclarativeCompiledData::Instruction::BeginObject i;
+        i.castValue = 4;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreObjectQList);
+        QDeclarativeCompiledData::Instruction::StoreObjectQList i;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::AssignObjectList);
+        QDeclarativeCompiledData::Instruction::AssignObjectList i;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::FetchAttached);
-        i.fetchAttached.id = 23;
+        QDeclarativeCompiledData::Instruction::FetchAttached i;
+        i.id = 23;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::FetchQList);
-        i.fetch.property = 32;
+        QDeclarativeCompiledData::Instruction::FetchQList i;
+        i.property = 32;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::FetchObject);
-        i.fetch.property = 33;
+        QDeclarativeCompiledData::Instruction::FetchObject i;
+        i.property = 33;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::FetchValueType);
-        i.fetchValue.property = 34;
-        i.fetchValue.type = 6;
-        i.fetchValue.bindingSkipList = 7;
+        QDeclarativeCompiledData::Instruction::FetchValueType i;
+        i.property = 34;
+        i.type = 6;
+        i.bindingSkipList = 7;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::PopFetchedObject);
+        QDeclarativeCompiledData::Instruction::PopFetchedObject i;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::PopQList);
+        QDeclarativeCompiledData::Instruction::PopQList i;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::PopValueType);
-        i.fetchValue.property = 35;
-        i.fetchValue.type = 8;
+        QDeclarativeCompiledData::Instruction::PopValueType i;
+        i.property = 35;
+        i.type = 8;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::Defer);
-        i.defer.deferCount = 7;
+        QDeclarativeCompiledData::Instruction::Defer i;
+        i.deferCount = 7;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::Defer);
-        i.defer.deferCount = 7;
+        QDeclarativeCompiledData::Instruction::Defer i;
+        i.deferCount = 7;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreImportedScript);
-        i.storeScript.value = 2;
+        QDeclarativeCompiledData::Instruction::StoreImportedScript i;
+        i.value = 2;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreVariantInteger);
-        i.storeInteger.value = 11;
-        i.storeInteger.propertyIndex = 32;
+        QDeclarativeCompiledData::Instruction::StoreVariantInteger i;
+        i.value = 11;
+        i.propertyIndex = 32;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::StoreVariantDouble);
-        i.storeDouble.value = 33.7;
-        i.storeDouble.propertyIndex = 19;
+        QDeclarativeCompiledData::Instruction::StoreVariantDouble i;
+        i.value = 33.7;
+        i.propertyIndex = 19;
         data->addInstruction(i);
     }
 
     {
-        QDeclarativeInstruction i;
-        i.setType(QDeclarativeInstruction::Done);
+        QDeclarativeCompiledData::Instruction::Done i;
         data->addInstruction(i);
     }