aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlcodegenerator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-02 20:35:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-12 18:20:30 +0100
commit7a092000169a8e9d537f3d341ef48277397f997d (patch)
treef29f189d57e4923dff2decfd073b8e04f4a211a8 /src/qml/compiler/qqmlcodegenerator.cpp
parent7c6d2d78fe0997dfebba5569f097bdacbba5a861 (diff)
Fix property dependency generation for accelerated QML QObject properties
The previous approach of collecting the dependencies through an IR visitor doesn't work, because it relies on a fixed structure - for example MEMBER(NAME, prop) - which we can't guarantee (it's usually MEMBER(TEMP, prop)). But it turns out that we can only pre-calculate dependencies for context, scope or id properties, so we can do that right away in the QML specific JS codegen, store that information in the IR function and use it from there in the data structure generator as well as in the isel as a parameter to getQObjectProperty to tell the run-time whether capture is required or not. Change-Id: I33711c3420d6534c653c2a6a4284f0fc12e941cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator.cpp')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 19264493be..2b3cb80acb 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -1355,7 +1355,6 @@ V4IR::Expr *JSCodeGen::member(V4IR::Expr *base, const QString *name)
V4IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col)
{
- V4IR::Expr *result = 0;
// Implement QML lookup semantics in the current file context.
//
// Note: We do not check if properties of the qml scope object or context object
@@ -1370,53 +1369,49 @@ V4IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int col
// Look for IDs first.
foreach (const IdMapping &mapping, _idObjects)
if (name == mapping.name) {
- result = _block->QML_CONTEXT_MEMBER(_block->NAME(V4IR::Name::builtin_qml_id_scope, line, col),
- _function->newString(mapping.name), mapping.idIndex);
- break;
+ _function->idObjectDependencies.insert(mapping.idIndex);
+ return _block->QML_CONTEXT_MEMBER(_block->NAME(V4IR::Name::builtin_qml_id_scope, line, col),
+ _function->newString(mapping.name), mapping.idIndex);
}
- if (!result) {
+ {
QQmlTypeNameCache::Result r = imports->query(name);
if (r.isValid()) {
- if (r.scriptIndex != -1) {
- result = subscript(_block->NAME(V4IR::Name::builtin_qml_imported_scripts_object, line, col), _block->CONST(V4IR::NumberType, r.scriptIndex));
- } else {
+ if (r.scriptIndex != -1)
+ return subscript(_block->NAME(V4IR::Name::builtin_qml_imported_scripts_object, line, col), _block->CONST(V4IR::NumberType, r.scriptIndex));
+ else
return 0; // TODO: We can't do fast lookup for these yet.
- }
}
}
- if (!result && _scopeObject) {
+ if (_scopeObject) {
bool propertyExistsButForceNameLookup = false;
QQmlPropertyData *pd = lookupQmlCompliantProperty(_scopeObject, name, &propertyExistsButForceNameLookup);
if (propertyExistsButForceNameLookup)
return 0;
if (pd) {
+ if (!pd->isConstant())
+ _function->scopeObjectDependencies.insert(pd);
int base = _block->newTemp();
move(_block->TEMP(base), _block->NAME(V4IR::Name::builtin_qml_scope_object, line, col));
- result = _block->QML_QOBJECT_PROPERTY(_block->TEMP(base),
- _function->newString(name), pd);
+ return _block->QML_QOBJECT_PROPERTY(_block->TEMP(base), _function->newString(name), pd);
}
}
- if (!result && _contextObject) {
+ if (_contextObject) {
bool propertyExistsButForceNameLookup = false;
QQmlPropertyData *pd = lookupQmlCompliantProperty(_contextObject, name, &propertyExistsButForceNameLookup);
if (propertyExistsButForceNameLookup)
return 0;
if (pd) {
+ if (!pd->isConstant())
+ _function->contextObjectDependencies.insert(pd);
int base = _block->newTemp();
move(_block->TEMP(base), _block->NAME(V4IR::Name::builtin_qml_context_object, line, col));
- result = _block->QML_QOBJECT_PROPERTY(_block->TEMP(base),
- _function->newString(name), pd);
+ return _block->QML_QOBJECT_PROPERTY(_block->TEMP(base), _function->newString(name), pd);
}
}
- if (result) {
- _function->hasQmlDependencies = true;
- return result;
- }
-
// fall back to name lookup at run-time.
return 0;
}