From aabf4e4f0474d8d6eb065fbab700432718070ae0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Oct 2018 10:59:13 +0200 Subject: Fix lookup of methods in the scope object Commit 939014cb9cad2f3357f47b28a4580397c17b913c improved performance of property lookups beyond the scope object, with the unfortunate side-effect that the previously polymorphic lookup of methods broke. Fix this by moving the handling to the caller side and falling back to the string lookup for functions. Fixes: QTBUG-71204 Change-Id: I2d9924034a9c14e7d161fa49d51b1f876ab5bc0f Reviewed-by: Lars Knoll --- src/qml/compiler/qqmlirbuilder.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 883b21ab07..9021fd0284 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1947,11 +1947,7 @@ QQmlPropertyData *JSCodeGen::lookupQmlCompliantProperty(QQmlPropertyCache *cache { QQmlPropertyData *pd = cache->property(name, /*object*/nullptr, /*context*/nullptr); - // Q_INVOKABLEs can't be FINAL, so we have to look them up at run-time - if (!pd || pd->isFunction()) - return nullptr; - - if (!cache->isAllowedInRevision(pd)) + if (pd && !cache->isAllowedInRevision(pd)) return nullptr; return pd; @@ -2280,6 +2276,10 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n if (_scopeObject) { QQmlPropertyData *data = lookupQmlCompliantProperty(_scopeObject, name); if (data) { + // Q_INVOKABLEs can't be FINAL, so we have to look them up at run-time + if (data->isFunction()) + return Reference::fromName(this, name); + Reference base = Reference::fromStackSlot(this, _qmlContextSlot); Reference::PropertyCapturePolicy capturePolicy; if (!data->isConstant() && !data->isQmlBinding()) @@ -2293,6 +2293,10 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n if (_contextObject) { QQmlPropertyData *data = lookupQmlCompliantProperty(_contextObject, name); if (data) { + // Q_INVOKABLEs can't be FINAL, so we have to look them up at run-time + if (data->isFunction()) + return Reference::fromName(this, name); + Reference base = Reference::fromStackSlot(this, _qmlContextSlot); Reference::PropertyCapturePolicy capturePolicy; if (!data->isConstant() && !data->isQmlBinding()) -- cgit v1.2.3