diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-06-04 14:43:38 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-09 01:36:23 +0200 |
commit | 49a3883e86b61d8facfeea9c43037d484cb50b92 (patch) | |
tree | ba1afdf6ddc3740f26c5e3c95cb2fffeb953abb4 /src/qml/qml/v4/qv4irbuilder.cpp | |
parent | 3095493a4ce4bec11b9381a3d1d23f17b313332c (diff) |
Use V4 binding for non-final properties where possible
When a property referenced in a binding is not marked as final, do not
automatically abort optimization. Instead generate both V4 and V8
binidngs, and only fall back to the V8 binding if necessary at run time.
Change-Id: I1bcc7e2b495935c5d519a9a223f640c1972cdb4e
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/v4/qv4irbuilder.cpp')
-rw-r--r-- | src/qml/qml/v4/qv4irbuilder.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp index ddc2264cf7..79090b4269 100644 --- a/src/qml/qml/v4/qv4irbuilder.cpp +++ b/src/qml/qml/v4/qv4irbuilder.cpp @@ -91,14 +91,15 @@ static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine) } } -QV4IRBuilder::QV4IRBuilder(const QV4Compiler::Expression *expr, - QQmlEnginePrivate *engine) -: m_expression(expr), m_engine(engine), _function(0), _block(0), _discard(false) +QV4IRBuilder::QV4IRBuilder(const QV4Compiler::Expression *expr, + QQmlEnginePrivate *engine) +: m_expression(expr), m_engine(engine), _function(0), _block(0), _discard(false), + _invalidatable(false) { } bool QV4IRBuilder::operator()(QQmlJS::IR::Function *function, - QQmlJS::AST::Node *ast) + QQmlJS::AST::Node *ast, bool *invalidatable) { bool discarded = false; @@ -142,6 +143,7 @@ bool QV4IRBuilder::operator()(QQmlJS::IR::Function *function, qSwap(_function, function); qSwap(_discard, discarded); + *invalidatable = _invalidatable; return !discarded; } @@ -615,12 +617,8 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) - if(!data->isFinal()) { - if (qmlVerboseCompiler()) - qWarning() << "*** non-final attached property:" - << (*baseName->id + QLatin1Char('.') + ast->name.toString()); - return false; // We don't know enough about this property - } + if (!data->isFinal()) + _invalidatable = true; IR::Type irType = irTypeFromVariantType(data->propType, m_engine); _expr.code = _block->SYMBOL(baseName, irType, name, attachedMeta, data, line, column); @@ -654,12 +652,8 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) - if (!data->isFinal()) { - if (qmlVerboseCompiler()) - qWarning() << "*** non-final attached property:" - << (*baseName->id + QLatin1Char('.') + ast->name.toString()); - return false; // We don't know enough about this property - } + if (!data->isFinal()) + _invalidatable = true; IR::Type irType = irTypeFromVariantType(data->propType, m_engine); _expr.code = _block->SYMBOL(baseName, irType, name, baseName->meta, data, line, column); @@ -690,20 +684,15 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) break; case IR::Name::Property: - if (baseName->type == IR::ObjectType && !baseName->meta.isNull() && - baseName->property->isFinal()) { + if (baseName->type == IR::ObjectType && !baseName->meta.isNull()) { QQmlMetaObject meta = m_engine->metaObjectForType(baseName->property->propType); QQmlPropertyCache *cache = meta.propertyCache(m_engine); if (!cache) return false; if (QQmlPropertyData *data = cache->property(name)) { - if (!data->isFinal()) { - if (qmlVerboseCompiler()) - qWarning() << "*** non-final property access:" - << (*baseName->id + QLatin1Char('.') + ast->name.toString()); - return false; // We don't know enough about this property - } + if (!baseName->property->isFinal() || !data->isFinal()) + _invalidatable = true; IR::Type irType = irTypeFromVariantType(data->propType, m_engine); _expr.code = _block->SYMBOL(baseName, irType, name, |