From a7c56b79d2f682b1e82b6b92d11fc942148d8c3b Mon Sep 17 00:00:00 2001
From: Michael Brasser <michael.brasser@nokia.com>
Date: Thu, 1 Mar 2012 10:34:01 +1000
Subject: [PATCH] More verbose compiler stats.

Report shared and unshared v8 bindings separately.

Change-Id: Iaa198dcc93035a778b13d7137742a7b308aa782f
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
---
 src/declarative/qml/qdeclarativecompiler.cpp | 28 +++++++++++++++++---
 src/declarative/qml/qdeclarativecompiler_p.h |  1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index b7b882cd97..aaa1acaaa3 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -3613,12 +3613,15 @@ bool QDeclarativeCompiler::completeComponentBuild()
             binding.property->type != qMetaTypeId<QDeclarativeBinding*>()) {
             binding.dataType = BindingReference::V8;
             sharedBindings.append(b);
+
+            if (componentStats)
+                componentStats->componentStat.sharedBindings.append(b->value->location);
         } else {
             binding.dataType = BindingReference::QtScript;
-        }
 
-        if (componentStats)
-            componentStats->componentStat.scriptBindings.append(b->value->location);
+            if (componentStats)
+                componentStats->componentStat.scriptBindings.append(b->value->location);
+        }
     }
 
     if (!sharedBindings.isEmpty()) {
@@ -3699,6 +3702,25 @@ void QDeclarativeCompiler::dumpStats()
             qWarning().nospace() << output.constData();
         }
 
+        qWarning().nospace() << "        Shared Bindings:    " << stat.sharedBindings.count();
+        {
+        QByteArray output;
+        for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) {
+            if (0 == (ii % 10)) {
+                if (ii) output.append("\n");
+                output.append("            ");
+            }
+
+            output.append("(");
+            output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line));
+            output.append(":");
+            output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column));
+            output.append(") ");
+        }
+        if (!output.isEmpty())
+            qWarning().nospace() << output.constData();
+        }
+
         qWarning().nospace() << "        QScript Bindings:   " << stat.scriptBindings.count();
         {
         QByteArray output;
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 637cd80569..3ef4668b79 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -450,6 +450,7 @@ private:
 
         int ids;
         QList<QDeclarativeScript::LocationSpan> scriptBindings;
+        QList<QDeclarativeScript::LocationSpan> sharedBindings;
         QList<QDeclarativeScript::LocationSpan> optimizedBindings;
         int objects;
     };
-- 
GitLab