diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-01-24 12:44:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-15 22:37:48 +0100 |
commit | 72420889aa54342da4472683e67e2c70b76a170f (patch) | |
tree | 3bbbb3a3f7b3286cb40f01763c42886bfd265500 /src/qml/qml | |
parent | 9424383e6d0ea1dd02dcf1070259e21550da692a (diff) |
Add dedicated QML profiler and adapter
The remaining "profiling" parts of the QML profiler service are
engine specific and are best accessed through their own adapter.
Change-Id: Idb763104bdd80e4dabdf132ec1a496b9bc9f6f46
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 20 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme_p.h | 2 |
7 files changed, 31 insertions, 21 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 9b83feebb4..11b9353dfe 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -46,7 +46,7 @@ #include "qqmlinfo.h" #include "qqmlcompiler_p.h" #include "qqmldata_p.h" -#include <private/qqmlprofilerservice_p.h> +#include <private/qqmlprofiler_p.h> #include <private/qqmltrace_p.h> #include <private/qqmlexpression_p.h> #include <private/qqmlscriptstring_p.h> @@ -226,7 +226,8 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) trace.addDetail("Column", columnNo); if (!updatingFlag()) { - QQmlBindingProfiler prof(m_url, lineNo, columnNo, QQmlProfilerService::QmlBinding); + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); + QQmlBindingProfiler prof(ep->profiler, m_url, lineNo, columnNo); setUpdatingFlag(true); QQmlAbstractExpression::DeleteWatcher watcher(this); @@ -242,7 +243,6 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) QMetaObject::metacall(*m_coreObject, QMetaObject::WriteProperty, idx, a); } else { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); QV4::Scope scope(ep->v4engine()); ep->referenceScarceResources(); diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index d0476a92d4..e5a0df8c32 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -50,7 +50,7 @@ #include "qqml.h" #include "qqmlcontext.h" #include "qqmlglobal_p.h" -#include <private/qqmlprofilerservice_p.h> +#include <private/qqmlprofiler_p.h> #include <private/qv4debugservice_p.h> #include "qqmlinfo.h" @@ -356,14 +356,13 @@ void QQmlBoundSignal_callback(QQmlNotifierEndpoint *e, void **a) if (QQmlDebugService::isDebuggingEnabled()) QV4DebugService::instance()->signalEmitted(QString::fromLatin1(QMetaObjectPrivate::signal(s->m_expression->target()->metaObject(), s->m_index).methodSignature())); - QQmlHandlingSignalProfiler prof(s->m_expression); - s->m_isEvaluating = true; - if (s->m_expression && s->m_expression->engine()) { + QQmlEngine *engine; + if (s->m_expression && (engine = s->m_expression->engine())) { + QQmlHandlingSignalProfiler prof(QQmlEnginePrivate::get(engine)->profiler, s->m_expression); s->m_expression->evaluate(a); if (s->m_expression && s->m_expression->hasError()) { - QQmlEngine *engine = s->m_expression->engine(); QQmlEnginePrivate::warning(engine, s->m_expression->error(engine)); } } diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 68d021b5cb..d373c00574 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -556,7 +556,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlUseNewCompiler, QML_NEW_COMPILER) QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e) : propertyCapture(0), rootContext(0), isDebugging(false), - outputWarningsToStdErr(true), + profiler(0), outputWarningsToStdErr(true), cleanup(0), erroredBindings(0), inProgressCreations(0), workerScriptEngine(0), activeVME(0), activeObjectCreator(0), @@ -595,6 +595,12 @@ QQmlEnginePrivate::~QQmlEnginePrivate() (*iter)->release(); for (QHash<int, QQmlCompiledData *>::Iterator iter = m_compositeTypes.begin(); iter != m_compositeTypes.end(); ++iter) iter.value()->isRegisteredWithEngine = false; + delete profiler; +} + +void QQmlEnginePrivate::enableProfiler() +{ + profiler = new QQmlProfiler(); } void QQmlPrivate::qdeclarativeelement_destructor(QObject *o) diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index e292dbf6c0..d5ceea271e 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -102,6 +102,7 @@ class QQmlVME; class QmlObjectCreator; class QDir; class QQmlIncubator; +class QQmlProfiler; // This needs to be declared here so that the pool for it can live in QQmlEnginePrivate. // The inline method definitions are in qqmljavascriptexpression_p.h @@ -146,6 +147,8 @@ public: QQmlContext *rootContext; bool isDebugging; bool useNewCompiler; + QQmlProfiler *profiler; + void enableProfiler(); bool outputWarningsToStdErr; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 7c32d4f19c..1b947c421a 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -49,7 +49,7 @@ #include <private/qqmlthread_p.h> #include <private/qqmlcompiler_p.h> #include <private/qqmlcomponent_p.h> -#include <private/qqmlprofilerservice_p.h> +#include <private/qqmlprofiler_p.h> #include <private/qqmlmemoryprofiler_p.h> #include <private/qqmlcodegenerator_p.h> #include <private/qqmltypecompiler_p.h> @@ -2304,7 +2304,7 @@ void QQmlTypeData::compile() m_compiledData->url = finalUrl(); m_compiledData->name = finalUrlString(); - QQmlCompilingProfiler prof(m_compiledData->name); + QQmlCompilingProfiler prof(QQmlEnginePrivate::get(typeLoader()->engine())->profiler, m_compiledData->name); if (m_useNewCompiler) { QQmlTypeCompiler compiler(QQmlEnginePrivate::get(typeLoader()->engine()), m_compiledData, this, parsedQML.data()); diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 54c70feecc..fb1dff49fd 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -129,6 +129,7 @@ void QQmlVME::init(QQmlContextData *ctxt, QQmlCompiledData *comp, int start, rootContext = 0; engine = ctxt->engine; + profiler.profiler = QQmlEnginePrivate::get(engine)->profiler; } bool QQmlVME::initDeferred(QObject *object) @@ -168,6 +169,7 @@ bool QQmlVME::initDeferred(QObject *object) rootContext = 0; engine = ctxt->engine; + profiler.profiler = QQmlEnginePrivate::get(engine)->profiler; return true; } @@ -503,7 +505,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type); Q_ASSERT(type.component); - Q_QML_VME_PROFILE(profiler.startBackground(type.component->name)); + Q_QML_VME_PROFILE(profiler, startBackground(type.component->name)); states.push(State()); @@ -526,7 +528,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_END_INSTR(CreateQMLObject) QML_BEGIN_INSTR(CompleteQMLObject) - Q_QML_VME_PROFILE(profiler.foreground(CTXT->url, instr.line, instr.column)); + Q_QML_VME_PROFILE(profiler, foreground(CTXT->url, instr.line, instr.column)); QObject *o = objects.top(); Q_ASSERT(o); @@ -570,7 +572,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_BEGIN_INSTR(CreateCppObject) const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type); Q_ASSERT(type.type); - Q_QML_VME_PROFILE(profiler.start(type.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); + Q_QML_VME_PROFILE(profiler, start(type.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); QObject *o = 0; void *memory = 0; @@ -643,7 +645,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_BEGIN_INSTR(CreateSimpleObject) const QQmlCompiledData::TypeReference &ref = TYPES.at(instr.type); - Q_QML_VME_PROFILE(profiler.start(ref.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); + Q_QML_VME_PROFILE(profiler, start(ref.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData)); ::memset(static_cast<void *>(o), 0, instr.typeSize + sizeof(QQmlData)); instr.create(o); @@ -823,7 +825,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_END_INSTR(StoreScriptString) QML_BEGIN_INSTR(BeginObject) - Q_QML_VME_PROFILE(profiler.push()); + Q_QML_VME_PROFILE(profiler, push()); QObject *target = objects.top(); QQmlParserStatus *status = reinterpret_cast<QQmlParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue); parserStatus.push(status); @@ -1087,7 +1089,7 @@ normalExit: objects.deallocate(); lists.deallocate(); states.clear(); - Q_QML_VME_PROFILE(profiler.stop()); + Q_QML_VME_PROFILE(profiler, stop()); return rv; } @@ -1131,7 +1133,7 @@ void QQmlVME::reset() // 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(profiler.clear()); + Q_QML_VME_PROFILE(profiler, clear(true)); } #ifdef QML_THREADED_VME_INTERPRETER @@ -1191,7 +1193,7 @@ QQmlContextData *QQmlVME::complete(const QQmlInstantiationInterrupt &interrupt) if (componentCompleteEnabled()) { // the qml designer does the component complete later QQmlTrace trace("VME Component Complete"); while (!parserStatus.isEmpty()) { - Q_QML_VME_PROFILE(profiler.pop()); + Q_QML_VME_PROFILE(profiler, pop()); QQmlParserStatus *status = parserStatus.pop(); #ifdef QML_ENABLE_TRACE QQmlData *data = parserStatusData.pop(); @@ -1211,7 +1213,7 @@ QQmlContextData *QQmlVME::complete(const QQmlInstantiationInterrupt &interrupt) return 0; } parserStatus.deallocate(); - Q_QML_VME_PROFILE(profiler.clear()); + Q_QML_VME_PROFILE(profiler, clear()); } { diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h index 4da1aec74b..226d498d2c 100644 --- a/src/qml/qml/qqmlvme_p.h +++ b/src/qml/qml/qqmlvme_p.h @@ -68,7 +68,7 @@ #include <private/qfinitestack_p.h> #include <private/qqmltrace_p.h> -#include <private/qqmlprofilerservice_p.h> +#include <private/qqmlprofiler_p.h> QT_BEGIN_NAMESPACE |