summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcompiler.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-30 05:24:51 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-30 05:24:51 (GMT)
commit46eec6d54bad7a686b3dd5cd6e4aa8577d38740d (patch)
treee4c828d1d1456b3fafe74a339562263b3f2c156d /src/declarative/qml/qmlcompiler.cpp
parentd85d7addc5084ee7d5de31dec562437f9c31c35d (diff)
parentd788c0127b86d8245aa0a8e2472562f444d98ee9 (diff)
downloadQt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.zip
Qt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.tar.gz
Qt-46eec6d54bad7a686b3dd5cd6e4aa8577d38740d.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/qml/qmlcomponentjs.cpp src/declarative/qml/qmlcomponentjs_p.h src/declarative/qml/qmlcomponentjs_p_p.h
Diffstat (limited to 'src/declarative/qml/qmlcompiler.cpp')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index cc177f9..4798406 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -76,6 +76,7 @@
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
+DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATISTICS_DUMP);
using namespace QmlParser;
@@ -613,6 +614,8 @@ bool QmlCompiler::compile(QmlEngine *engine,
if (!isError()) {
if (compilerDump())
out->dumpInstructions();
+ if (compilerStatDump())
+ dumpStats();
} else {
reset(out);
}
@@ -664,6 +667,8 @@ void QmlCompiler::compileTree(Object *tree)
bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
{
+ componentStat.objects++;
+
Q_ASSERT (obj->type != -1);
const QmlCompiledData::TypeReference &tr =
output->types.at(obj->type);
@@ -1148,15 +1153,21 @@ bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
const BindingContext &ctxt)
{
ComponentCompileState oldComponentCompileState = compileState;
+ ComponentStat oldComponentStat = componentStat;
+
compileState = ComponentCompileState();
compileState.root = obj;
+ componentStat = ComponentStat();
+ componentStat.lineNumber = obj->location.start.line;
+
if (obj)
COMPILE_CHECK(buildObject(obj, ctxt));
COMPILE_CHECK(completeComponentBuild());
compileState = oldComponentCompileState;
+ componentStat = oldComponentStat;
return true;
}
@@ -1646,6 +1657,7 @@ void QmlCompiler::saveComponentState()
Q_ASSERT(!savedCompileStates.contains(compileState.root));
savedCompileStates.insert(compileState.root, compileState);
+ savedComponentStats.append(componentStat);
}
QmlCompiler::ComponentCompileState
@@ -2454,6 +2466,8 @@ int QmlCompiler::genContextCache()
bool QmlCompiler::completeComponentBuild()
{
+ componentStat.ids = compileState.ids.count();
+
for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
Object *aliasObject = compileState.aliasingObjects.at(ii);
COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
@@ -2478,6 +2492,8 @@ bool QmlCompiler::completeComponentBuild()
QByteArray(bs.compileData(), bs.compileDataSize());
type = QmlExpressionPrivate::BasicScriptEngineData;
binding.isBasicScript = true;
+
+ componentStat.optimizedBindings++;
} else {
type = QmlExpressionPrivate::PreTransformedQtScriptData;
@@ -2495,6 +2511,8 @@ bool QmlCompiler::completeComponentBuild()
QByteArray((const char *)expression.constData(),
expression.length() * sizeof(QChar));
binding.isBasicScript = false;
+
+ componentStat.scriptBindings++;
}
binding.compiledData.prepend(QByteArray((const char *)&type,
sizeof(quint32)));
@@ -2505,6 +2523,19 @@ bool QmlCompiler::completeComponentBuild()
return true;
}
+void QmlCompiler::dumpStats()
+{
+ qWarning().nospace() << "QML Document: " << output->url.toString();
+ for (int ii = 0; ii < savedComponentStats.count(); ++ii) {
+ const ComponentStat &stat = savedComponentStats.at(ii);
+ qWarning().nospace() << " Component Line " << stat.lineNumber;
+ qWarning().nospace() << " Total Objects: " << stat.objects;
+ qWarning().nospace() << " IDs Used: " << stat.ids;
+ qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings;
+ qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings;
+ }
+}
+
/*!
Returns true if from can be assigned to a (QObject) property of type
to.