Add a QML debug config option QML_LOOKUP_HINTS to find non-final properties
authorSimon Hausmann <simon.hausmann@digia.com>
Sun, 17 Nov 2013 04:10:23 +0000 (05:10 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 28 Nov 2013 14:12:01 +0000 (15:12 +0100)
This helps to optimize property access, especially for attached properties.

Change-Id: Id47a9c5f184f84ce5ab813d3b01d1a6c6031233e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qqmlcodegenerator.cpp

index d80c4d1..24755ee 100644 (file)
@@ -45,6 +45,7 @@
 #include <private/qqmljsparser_p.h>
 #include <private/qqmljslexer_p.h>
 #include <private/qqmlcompiler_p.h>
+#include <private/qqmlglobal_p.h>
 #include <QCoreApplication>
 
 #ifdef CONST
@@ -53,6 +54,8 @@
 
 QT_USE_NAMESPACE
 
+DEFINE_BOOL_CONFIG_OPTION(lookupHints, QML_LOOKUP_HINTS);
+
 using namespace QtQml;
 
 #define COMPILE_EXCEPTION(location, desc) \
@@ -1450,6 +1453,15 @@ static V4IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, V4IR::
             if (QQmlPropertyData *candidate = metaObject->property(*member->name, /*object*/0, /*context*/0)) {
                 const bool isFinalProperty = (candidate->isFinal() || (resolver->flags & AllPropertiesAreFinal))
                                              && !candidate->isFunction();
+
+                if (lookupHints()
+                    && !(resolver->flags & AllPropertiesAreFinal)
+                    && !candidate->isFinal()
+                    && !candidate->isFunction()
+                    && candidate->isDirect()) {
+                    qWarning() << "Hint: Access to property" << *member->name << "of" << metaObject->className() << "could be accelerated if it was marked as FINAL";
+                }
+
                 if (isFinalProperty && metaObject->isAllowedInRevision(candidate)) {
                     property = candidate;
                     member->property = candidate; // Cache for next iteration and isel needs it.