diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-03 08:36:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-04 15:22:58 +0100 |
commit | 94d003c59b346c078e4aa8233c29c2c2c3467e3b (patch) | |
tree | 798d926effa9f4de07d704494dd1639bb2bf9cb0 | |
parent | 186f8e2f76dc6995d14e6632d9b9d704198feda2 (diff) |
[new compiler] Fix profiler support
Add profiler tracing calls during objection creation and make sure to set the
function token / source location correctly for the synthesized function
declarations of signal handlers.
Change-Id: Ie4f8accce3a5c5d1d57bb0646cda588b89b76718
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 1 | ||||
-rw-r--r-- | src/qml/debugger/qqmlprofiler_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 16 | ||||
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 3 |
4 files changed, 21 insertions, 1 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 6dcf15f24e..780b3dae36 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1043,6 +1043,7 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio QQmlJS::AST::FunctionBody *body = new (pool) QQmlJS::AST::FunctionBody(elements); QQmlJS::AST::FunctionDeclaration *functionDeclaration = new (pool) QQmlJS::AST::FunctionDeclaration(compiler->newStringRef(stringAt(binding->propertyNameIndex)), paramList, body); + functionDeclaration->functionToken = foe->node->firstSourceLocation(); foe->node = functionDeclaration; binding->propertyNameIndex = compiler->registerString(propertyName); diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h index ca464e86a3..27d4b58db6 100644 --- a/src/qml/debugger/qqmlprofiler_p.h +++ b/src/qml/debugger/qqmlprofiler_p.h @@ -258,7 +258,7 @@ struct QQmlCompilingProfiler : public QQmlProfilerHelper { } }; -#define Q_QML_VME_PROFILE(profiler, Method) Q_QML_PROFILE_IF_ENABLED(profiler.profiler, profiler.Method) +#define Q_QML_VME_PROFILE(profilerMember, Method) Q_QML_PROFILE_IF_ENABLED(profilerMember.profiler, profilerMember.Method) struct QQmlVmeProfiler : public QQmlProfilerDefinitions { public: diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 8a28fa1211..6ec8c2bea4 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -98,6 +98,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile sharedState->allCreatedObjects.allocate(compiledData->totalObjectCount); sharedState->creationContext = creationContext; sharedState->rootContext = 0; + sharedState->profiler.profiler = QQmlEnginePrivate::get(engine)->profiler; } QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlObjectCreatorSharedState *inheritedSharedState) @@ -224,6 +225,8 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI context->contextObject = instance; } + Q_QML_VME_PROFILE(sharedState->profiler, stop()); + phase = CreatingObjectsPhase2; if (interrupt && interrupt->shouldInterrupt()) @@ -993,6 +996,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent) installPropertyCache = !typeRef->isFullyDynamicType; QQmlType *type = typeRef->type; if (type) { + Q_QML_VME_PROFILE(sharedState->profiler, start(type->qmlTypeName(), context->url, obj->location.line, obj->location.column)); instance = type->create(); if (!instance) { recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex))); @@ -1019,8 +1023,10 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent) recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex))); return 0; } + Q_QML_VME_PROFILE(sharedState->profiler, startBackground(typeRef->component->name)); QQmlObjectCreator subCreator(context, typeRef->component, sharedState.data()); instance = subCreator.create(); + Q_QML_VME_PROFILE(sharedState->profiler, foreground(context->url, obj->location.line, obj->location.column)); if (!instance) { errors += subCreator.errors; return 0; @@ -1129,6 +1135,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru if (true /* ### componentCompleteEnabled()*/) { // the qml designer does the component complete later QQmlTrace trace("VME Component Complete"); while (!sharedState->allParserStatusCallbacks.isEmpty()) { + Q_QML_VME_PROFILE(sharedState->profiler, pop()); QQmlParserStatus *status = sharedState->allParserStatusCallbacks.pop(); if (status && status->d) { @@ -1139,6 +1146,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru if (watcher.hasRecursed() || interrupt.shouldInterrupt()) return 0; } + Q_QML_VME_PROFILE(sharedState->profiler, clear()); } { @@ -1187,12 +1195,20 @@ void QQmlObjectCreator::clear() while (!sharedState->allCreatedObjects.isEmpty()) delete sharedState->allCreatedObjects.pop(); + // If profiling is switched off during a VME run and then switched back on + // before or during the next run background ranges from the first run will + // be reported in the second run because we don't clear() here. We accept + // that as the collected data will be incomplete anyway and because not + // calling clear() here is benefitial for the non-profiling case. + Q_QML_VME_PROFILE(sharedState->profiler, clear(true)); + phase = Done; } bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty, bool installPropertyCache, const QBitArray &bindingsToSkip) { const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index); + Q_QML_VME_PROFILE(sharedState->profiler, push()); QQmlData *declarativeData = QQmlData::get(instance, /*create*/true); diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index cda17fe220..b7d6790a81 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -48,12 +48,14 @@ #include <private/qqmltypecompiler_p.h> #include <private/qfinitestack_p.h> #include <private/qrecursionwatcher_p.h> +#include <private/qqmlprofiler_p.h> QT_BEGIN_NAMESPACE class QQmlAbstractBinding; struct QQmlTypeCompiler; class QQmlInstantiationInterrupt; +struct QQmlVmeProfiler; struct QQmlObjectCreatorSharedState { @@ -64,6 +66,7 @@ struct QQmlObjectCreatorSharedState QFiniteStack<QObject*> allCreatedObjects; QQmlComponentAttached *componentAttached; QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks; + QQmlVmeProfiler profiler; QRecursionNode recursionNode; }; |