From 3aff93a5bba79bdf45f13e4c9f8c66c9a9ed47b4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 26 May 2009 15:31:09 +1000 Subject: Remove Try*Object instructions --- src/declarative/qml/qmlcompiler.cpp | 60 +++++++++++++++------------------- src/declarative/qml/qmlinstruction.cpp | 6 ---- src/declarative/qml/qmlinstruction_p.h | 2 -- src/declarative/qml/qmlvme.cpp | 42 ------------------------ 4 files changed, 27 insertions(+), 83 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index a247f8b..73c50e8 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -561,23 +561,28 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) COMPILE_CHECK(compileDynamicMeta(obj)); + int parserStatusCast = -1; if (obj->type != -1) { - if (output->types.at(obj->type).component) { - QmlInstruction begin; - begin.type = QmlInstruction::TryBeginObject; - begin.line = obj->location.start.line; - output->bytecode << begin; - } else { - int cast = QmlMetaType::qmlParserStatusCast(QmlMetaType::type(output->types.at(obj->type).className)); - if (cast != -1) { - QmlInstruction begin; - begin.type = QmlInstruction::BeginObject; - begin.begin.castValue = cast; - begin.line = obj->location.start.line; - output->bytecode << begin; - } + // ### Optimize + const QMetaObject *mo = obj->metatype; + QmlType *type = 0; + while (!type && mo) { + type = QmlMetaType::qmlType(mo); + mo = mo->superClass(); } - } + + Q_ASSERT(type); + + parserStatusCast = type->parserStatusCast(); + } + + if (parserStatusCast != -1) { + QmlInstruction begin; + begin.type = QmlInstruction::BeginObject; + begin.begin.castValue = parserStatusCast; + begin.line = obj->location.start.line; + output->bytecode << begin; + } bool isCustomParser = output->types.at(obj->type).type && output->types.at(obj->type).type->customParser() != 0; @@ -620,22 +625,12 @@ bool QmlCompiler::compileObject(Object *obj, int ctxt) output->indexForByteArray(customData); } - if (obj->type != -1) { - if (output->types.at(obj->type).component) { - QmlInstruction complete; - complete.type = QmlInstruction::TryCompleteObject; - complete.line = obj->location.start.line; - output->bytecode << complete; - } else { - int cast = QmlMetaType::qmlParserStatusCast(QmlMetaType::type(output->types.at(obj->type).className)); - if (cast != -1) { - QmlInstruction complete; - complete.type = QmlInstruction::CompleteObject; - complete.complete.castValue = cast; - complete.line = obj->location.start.line; - output->bytecode << complete; - } - } + if (parserStatusCast != -1) { + QmlInstruction complete; + complete.type = QmlInstruction::CompleteObject; + complete.complete.castValue = parserStatusCast; + complete.line = obj->location.start.line; + output->bytecode << complete; } return true; @@ -1419,8 +1414,7 @@ int QmlCompiler::optimizeExpressions(int start, int end, int patch) if (instr.type == QmlInstruction::StoreBinding || instr.type == QmlInstruction::StoreCompiledBinding) { ++bindingsCount; - } else if (instr.type == QmlInstruction::TryBeginObject || - instr.type == QmlInstruction::BeginObject) { + } else if (instr.type == QmlInstruction::BeginObject) { ++parserStatusCount; } diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index 923d36f..143dc9b 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -139,15 +139,9 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) case QmlInstruction::StoreValueSource: qWarning() << idx << "\t" << line << "\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property; break; - case QmlInstruction::TryBeginObject: - qWarning() << idx << "\t" << line << "\t" << "TRY_BEGIN"; - break; case QmlInstruction::BeginObject: qWarning() << idx << "\t" << line << "\t" << "BEGIN\t\t\t" << instr->begin.castValue; break; - case QmlInstruction::TryCompleteObject: - qWarning() << idx << "\t" << line << "\t" << "TRY_COMPLETE"; - break; case QmlInstruction::CompleteObject: qWarning() << idx << "\t" << line << "\t" << "COMPLETE\t\t" << instr->complete.castValue; break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index a21ccee..a2f7ede 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -118,9 +118,7 @@ public: StoreCompiledBinding, /* assignBinding */ StoreValueSource, /* assignValueSource */ - TryBeginObject, BeginObject, /* begin */ - TryCompleteObject, CompleteObject, /* complete */ AssignObject, /* assignObject */ diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index a5cc649..2a5a042 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -92,9 +92,7 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) { Q_DECLARE_PERFORMANCE_METRIC(InstrStoreBinding); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreCompiledBinding); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreValueSource); - Q_DECLARE_PERFORMANCE_METRIC(InstrTryBeginObject); Q_DECLARE_PERFORMANCE_METRIC(InstrBeginObject); - Q_DECLARE_PERFORMANCE_METRIC(InstrTryCompleteObject); Q_DECLARE_PERFORMANCE_METRIC(InstrCompleteObject); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignObject); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignObjectList); @@ -138,9 +136,7 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") { Q_DEFINE_PERFORMANCE_METRIC(InstrStoreBinding, "StoreBinding"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreCompiledBinding, "StoreCompiledBinding"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreValueSource, "StoreValueSource"); - Q_DEFINE_PERFORMANCE_METRIC(InstrTryBeginObject, "TryBeginObject"); Q_DEFINE_PERFORMANCE_METRIC(InstrBeginObject, "BeginObject"); - Q_DEFINE_PERFORMANCE_METRIC(InstrTryCompleteObject, "TryCompleteObject"); Q_DEFINE_PERFORMANCE_METRIC(InstrCompleteObject, "CompleteObject"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignObject, "AssignObject"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignObjectList, "AssignObjectList"); @@ -403,25 +399,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; - case QmlInstruction::TryBeginObject: - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxCompilerTimer cc; -#endif - QObject *target = stack.top(); - QmlParserStatus *status = - qobject_cast(target); - - if (status) { - instr.type = QmlInstruction::BeginObject; - instr.begin.castValue = int(reinterpret_cast(status) - reinterpret_cast(target)); - --ii; - } else { - instr.type = QmlInstruction::NoOp; - } - } - break; - case QmlInstruction::BeginObject: { #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -436,25 +413,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; - case QmlInstruction::TryCompleteObject: - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxCompilerTimer cc; -#endif - QObject *target = stack.top(); - QmlParserStatus *status = - qobject_cast(target); - - if (status) { - instr.type = QmlInstruction::CompleteObject; - instr.complete.castValue = int(reinterpret_cast(status) - reinterpret_cast(target)); - --ii; - } else { - instr.type = QmlInstruction::NoOp; - } - } - break; - case QmlInstruction::CompleteObject: { #ifdef Q_ENABLE_PERFORMANCE_LOG -- cgit v0.12