diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-10 05:37:19 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-08-10 08:01:37 (GMT) |
commit | 8c3405bbf65826f0ab0be0bd090d723f8efaa3af (patch) | |
tree | f6886a2b8a86f567b98728bba9cdc3d1be780dcf /src/declarative/qml/qmlcompiler.cpp | |
parent | 12ffa33ddc725cd94662a383af6e1793049c807c (diff) | |
download | Qt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.zip Qt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.tar.gz Qt-8c3405bbf65826f0ab0be0bd090d723f8efaa3af.tar.bz2 |
Abstract expression and binding APIs
By splitting the interface through which the system interacts with bindings
away from a specific implementation, we can introduce highly specialized
implementations for specific optimizations.
This commit also includes a sample optimization for object properties being
assigned directly from a local id.
Diffstat (limited to 'src/declarative/qml/qmlcompiler.cpp')
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 1c535d4..7c0964b 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -1394,6 +1394,7 @@ void QmlCompiler::addId(const QString &id, QmlParser::Object *obj) Q_ASSERT(obj->id == id); obj->idIndex = compileState.ids.count(); compileState.ids.insert(id, obj); + compileState.idIndexes.insert(obj->idIndex, obj); } void QmlCompiler::addBindingReference(const BindingReference &ref) @@ -2064,6 +2065,22 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding, const BindingReference &ref = compileState.bindings.value(binding); QmlInstruction store; + + QmlBasicScript bs; + if (ref.isBasicScript) + bs.load(ref.compiledData.constData() + sizeof(quint32)); + if (bs.isSingleIdFetch()) { + int idIndex = bs.singleIdFetchIndex(); + QmlParser::Object *idObj = compileState.idIndexes.value(idIndex); + if (canCoerce(prop->type, idObj)) { + store.type = QmlInstruction::StoreIdOptBinding; + store.assignIdOptBinding.id = idIndex; + store.assignIdOptBinding.property = prop->index; + output->bytecode << store; + return; + } + } + store.type = QmlInstruction::StoreCompiledBinding; store.assignBinding.value = output->indexForByteArray(ref.compiledData); store.assignBinding.context = ref.bindingContext.stack; @@ -2109,6 +2126,7 @@ bool QmlCompiler::completeComponentBuild() binding.compiledData = QByteArray(bs.compileData(), bs.compileDataSize()); type = QmlExpressionPrivate::BasicScriptEngineData; + binding.isBasicScript = true; } else { type = QmlExpressionPrivate::PreTransformedQtScriptData; @@ -2122,6 +2140,7 @@ bool QmlCompiler::completeComponentBuild() QByteArray((const char *)&length, sizeof(quint32)) + QByteArray((const char *)expression.constData(), expression.length() * sizeof(QChar)); + binding.isBasicScript = false; } binding.compiledData.prepend(QByteArray((const char *)&type, sizeof(quint32))); |