diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-06 13:43:47 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-30 13:18:28 +0200 |
commit | 809ee66b67ce70dba89a04b92daccc9445af2e75 (patch) | |
tree | 84c6d4023312d72583ccfcd2ad79df4fdf714527 /src/declarative/qml/v4 | |
parent | f8f9db6cc74a34d3648ac693196c0f5d4bda9c50 (diff) |
More efficient type name cache
Instead of creating completely separate hashes for all the types used
by every QML file, we simply link to the QDeclarativeTypeModule. This
uses much less memory, and is faster to construct at startup.
Change-Id: I28bc2807074f9c6f38096d6e4ce8be744159d023
Reviewed-on: http://codereview.qt.nokia.com/3741
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/v4')
-rw-r--r-- | src/declarative/qml/v4/qdeclarativev4irbuilder.cpp | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp index bddfca18b4..6a6f4f0baf 100644 --- a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp +++ b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp @@ -444,64 +444,63 @@ bool QDeclarativeV4IRBuilder::visit(AST::IdentifierExpression *ast) if (obj == m_expression->component) code->storage = IR::Name::RootStorage; _expr.code = code; - } else if (QDeclarativeTypeNameCache::Data *typeNameData = m_expression->importCache->data(name)) { - if (typeNameData->importedScriptIndex != -1) { - // We don't support invoking imported scripts - } else if (typeNameData->type) { - _expr.code = _block->ATTACH_TYPE(name, typeNameData->type, IR::Name::ScopeStorage, line, column); - } else if (typeNameData->typeNamespace) { - // We don't support namespaces - } else { - Q_ASSERT(!"Unreachable"); - } } else { - bool found = false; - if (m_expression->context != m_expression->component) { - // RootStorage is more efficient than ScopeStorage, so prefer that if they are the same - QDeclarativePropertyCache *cache = m_expression->context->synthCache; - const QMetaObject *metaObject = m_expression->context->metaObject(); - if (!cache) cache = m_engine->cache(metaObject); + QDeclarativeTypeNameCache::Result r = m_expression->importCache->query(name); + if (r.isValid()) { + if (r.type) { + _expr.code = _block->ATTACH_TYPE(name, r.type, IR::Name::ScopeStorage, line, column); + } + // We don't support anything else + } else { + bool found = false; + + if (m_expression->context != m_expression->component) { + // RootStorage is more efficient than ScopeStorage, so prefer that if they are the same + QDeclarativePropertyCache *cache = m_expression->context->synthCache; + const QMetaObject *metaObject = m_expression->context->metaObject(); + if (!cache) cache = m_engine->cache(metaObject); - QDeclarativePropertyCache::Data *data = cache->property(name); + QDeclarativePropertyCache::Data *data = cache->property(name); + + if (data && data->revision != 0) { + if (qmlVerboseCompiler()) + qWarning() << "*** versioned symbol:" << name; + discard(); + return false; + } - if (data && data->revision != 0) { - if (qmlVerboseCompiler()) - qWarning() << "*** versioned symbol:" << name; - discard(); - return false; + if (data && !data->isFunction()) { + IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); + _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::ScopeStorage, line, column); + found = true; + } } - if (data && !data->isFunction()) { - IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); - _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::ScopeStorage, line, column); - found = true; - } - } + if (!found) { + QDeclarativePropertyCache *cache = m_expression->component->synthCache; + const QMetaObject *metaObject = m_expression->component->metaObject(); + if (!cache) cache = m_engine->cache(metaObject); - if (!found) { - QDeclarativePropertyCache *cache = m_expression->component->synthCache; - const QMetaObject *metaObject = m_expression->component->metaObject(); - if (!cache) cache = m_engine->cache(metaObject); + QDeclarativePropertyCache::Data *data = cache->property(name); - QDeclarativePropertyCache::Data *data = cache->property(name); + if (data && data->revision != 0) { + if (qmlVerboseCompiler()) + qWarning() << "*** versioned symbol:" << name; + discard(); + return false; + } - if (data && data->revision != 0) { - if (qmlVerboseCompiler()) - qWarning() << "*** versioned symbol:" << name; - discard(); - return false; + if (data && !data->isFunction()) { + IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); + _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::RootStorage, line, column); + found = true; + } } - if (data && !data->isFunction()) { - IR::Type irType = irTypeFromVariantType(data->propType, m_engine, metaObject); - _expr.code = _block->SYMBOL(irType, name, metaObject, data->coreIndex, IR::Name::RootStorage, line, column); - found = true; - } + if (!found && qmlVerboseCompiler()) + qWarning() << "*** unknown symbol:" << name; } - - if (!found && qmlVerboseCompiler()) - qWarning() << "*** unknown symbol:" << name; } if (_expr.code && _expr.hint == ExprResult::cx) { |