2014-01-24 11:44:49 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-01-24 11:44:49 +00:00
|
|
|
**
|
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2014-01-24 11:44:49 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 09:38:36 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-01-24 11:44:49 +00:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2016-01-19 09:38:36 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
2014-01-24 11:44:49 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 2.0 or (at your option) the GNU General
|
|
|
|
** Public license version 3 or any later version approved by the KDE Free
|
|
|
|
** Qt Foundation. The licenses are as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
|
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-01-24 11:44:49 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QQMLPROFILER_P_H
|
|
|
|
#define QQMLPROFILER_P_H
|
|
|
|
|
|
|
|
//
|
|
|
|
// W A R N I N G
|
|
|
|
// -------------
|
|
|
|
//
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
//
|
|
|
|
// We mean it.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <private/qv4function_p.h>
|
|
|
|
#include <private/qqmlboundsignal_p.h>
|
2014-04-02 10:02:14 +00:00
|
|
|
#include <private/qfinitestack_p.h>
|
2016-04-25 12:52:12 +00:00
|
|
|
#include <private/qqmlbinding_p.h>
|
2014-01-24 11:44:49 +00:00
|
|
|
#include "qqmlprofilerdefinitions_p.h"
|
|
|
|
#include "qqmlabstractprofileradapter_p.h"
|
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2016-07-25 15:20:04 +00:00
|
|
|
#ifdef QT_NO_QML_DEBUGGER
|
|
|
|
|
|
|
|
#define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code)
|
|
|
|
#define Q_QML_PROFILE(feature, profiler, Method)
|
|
|
|
#define Q_QML_OC_PROFILE(member, Code)
|
|
|
|
|
|
|
|
struct QQmlProfiler {};
|
|
|
|
|
|
|
|
struct QQmlBindingProfiler
|
|
|
|
{
|
2017-01-23 09:28:52 +00:00
|
|
|
QQmlBindingProfiler(quintptr, QV4::Function *) {}
|
2016-07-25 15:20:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlHandlingSignalProfiler
|
|
|
|
{
|
2016-07-28 08:21:06 +00:00
|
|
|
QQmlHandlingSignalProfiler(quintptr, QQmlBoundSignalExpression *) {}
|
2016-07-25 15:20:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlCompilingProfiler
|
|
|
|
{
|
2016-07-28 08:21:06 +00:00
|
|
|
QQmlCompilingProfiler(quintptr, QQmlDataBlob *) {}
|
2016-07-25 15:20:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlVmeProfiler {
|
|
|
|
QQmlVmeProfiler() {}
|
|
|
|
|
2016-07-28 08:21:06 +00:00
|
|
|
void init(quintptr, int) {}
|
2016-07-25 15:20:04 +00:00
|
|
|
|
|
|
|
const QV4::CompiledData::Object *pop() { return nullptr; }
|
|
|
|
void push(const QV4::CompiledData::Object *) {}
|
|
|
|
|
|
|
|
static const quintptr profiler = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlObjectCreationProfiler
|
|
|
|
{
|
|
|
|
QQmlObjectCreationProfiler(quintptr, const QV4::CompiledData::Object *) {}
|
|
|
|
void update(QV4::CompiledData::CompilationUnit *, const QV4::CompiledData::Object *,
|
|
|
|
const QString &, const QUrl &) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlObjectCompletionProfiler
|
|
|
|
{
|
|
|
|
QQmlObjectCompletionProfiler(QQmlVmeProfiler *) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2014-09-03 17:28:35 +00:00
|
|
|
#define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code)\
|
|
|
|
if (profiler && (profiler->featuresEnabled & (1 << feature))) {\
|
2014-01-24 11:44:49 +00:00
|
|
|
Code;\
|
|
|
|
} else\
|
|
|
|
(void)0
|
|
|
|
|
2014-09-03 17:28:35 +00:00
|
|
|
#define Q_QML_PROFILE(feature, profiler, Method)\
|
|
|
|
Q_QML_PROFILE_IF_ENABLED(feature, profiler, profiler->Method)
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2016-07-25 15:20:04 +00:00
|
|
|
#define Q_QML_OC_PROFILE(member, Code)\
|
|
|
|
Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, member.profiler, Code)
|
|
|
|
|
2014-01-24 11:44:49 +00:00
|
|
|
// This struct is somewhat dangerous to use:
|
|
|
|
// The messageType is a bit field. You can pack multiple messages into
|
|
|
|
// one object, e.g. RangeStart and RangeLocation. Each one will be read
|
2015-07-20 16:09:42 +00:00
|
|
|
// independently when converting to QByteArrays. Thus you can only pack
|
|
|
|
// messages if their data doesn't overlap. It's up to you to figure that
|
|
|
|
// out.
|
2016-04-25 13:07:34 +00:00
|
|
|
struct Q_AUTOTEST_EXPORT QQmlProfilerData : public QQmlProfilerDefinitions
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
QQmlProfilerData(qint64 time = -1, int messageType = -1,
|
|
|
|
RangeType detailType = MaximumRangeType, quintptr locationId = 0) :
|
|
|
|
time(time), locationId(locationId), messageType(messageType), detailType(detailType)
|
|
|
|
{}
|
2014-01-24 11:44:49 +00:00
|
|
|
|
|
|
|
qint64 time;
|
2016-04-25 12:52:12 +00:00
|
|
|
quintptr locationId;
|
|
|
|
|
2014-01-24 11:44:49 +00:00
|
|
|
int messageType; //bit field of QQmlProfilerService::Message
|
2016-04-25 13:07:34 +00:00
|
|
|
RangeType detailType;
|
2014-01-24 11:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
|
|
|
|
|
2016-07-20 13:35:50 +00:00
|
|
|
class Q_QML_PRIVATE_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDefinitions {
|
2014-01-24 11:44:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-04-25 12:52:12 +00:00
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
class FunctionRefCount : public QQmlRefCount {
|
2016-04-25 12:52:12 +00:00
|
|
|
public:
|
2016-12-20 10:26:48 +00:00
|
|
|
FunctionRefCount(QV4::Function *function):
|
|
|
|
m_function(function)
|
2016-04-25 12:52:12 +00:00
|
|
|
{
|
2016-12-20 10:26:48 +00:00
|
|
|
m_function->compilationUnit->addref();
|
2016-04-25 12:52:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
FunctionRefCount(const FunctionRefCount &other) :
|
|
|
|
QQmlRefCount(other), m_function(other.m_function)
|
2016-04-25 12:52:12 +00:00
|
|
|
{
|
2016-12-20 10:26:48 +00:00
|
|
|
m_function->compilationUnit->addref();
|
2016-04-25 12:52:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
FunctionRefCount &operator=(const FunctionRefCount &other)
|
2016-04-25 12:52:12 +00:00
|
|
|
{
|
|
|
|
if (this != &other) {
|
|
|
|
QQmlRefCount::operator=(other);
|
2016-12-20 10:26:48 +00:00
|
|
|
other.m_function->compilationUnit->addref();
|
|
|
|
m_function->compilationUnit->release();
|
|
|
|
m_function = other.m_function;
|
2016-04-25 12:52:12 +00:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
~FunctionRefCount()
|
2016-04-25 12:52:12 +00:00
|
|
|
{
|
2016-12-20 10:26:48 +00:00
|
|
|
m_function->compilationUnit->release();
|
2016-04-25 12:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-12-20 10:26:48 +00:00
|
|
|
QV4::Function *m_function;
|
2016-04-25 12:52:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Location {
|
|
|
|
Location(const QQmlSourceLocation &location = QQmlSourceLocation(),
|
|
|
|
const QUrl &url = QUrl()) :
|
|
|
|
location(location), url(url) {}
|
|
|
|
QQmlSourceLocation location;
|
|
|
|
QUrl url;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Unfortunately we have to resolve the locations right away because the QML context might not
|
|
|
|
// be available anymore when we send the data.
|
|
|
|
struct RefLocation : public Location {
|
2016-05-24 09:58:07 +00:00
|
|
|
RefLocation() : Location(), locationType(MaximumRangeType), ref(nullptr), sent(false)
|
2016-04-25 12:52:12 +00:00
|
|
|
{}
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
RefLocation(QV4::Function *function) :
|
2016-04-25 12:52:12 +00:00
|
|
|
Location(function->sourceLocation()), locationType(Binding),
|
2016-12-20 10:26:48 +00:00
|
|
|
ref(new FunctionRefCount(function),
|
|
|
|
QQmlRefPointer<QQmlRefCount>::Adopt), sent(false)
|
2016-12-02 08:50:36 +00:00
|
|
|
{}
|
|
|
|
|
2016-06-01 10:22:11 +00:00
|
|
|
RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj,
|
2016-04-25 12:52:12 +00:00
|
|
|
const QString &type) :
|
|
|
|
Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url),
|
2016-05-24 09:58:07 +00:00
|
|
|
locationType(Creating), ref(ref), sent(false)
|
2016-04-25 12:52:12 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
RefLocation(QQmlBoundSignalExpression *ref) :
|
2016-05-24 09:58:07 +00:00
|
|
|
Location(ref->sourceLocation()), locationType(HandlingSignal), ref(ref), sent(false)
|
2016-04-25 12:52:12 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
RefLocation(QQmlDataBlob *ref) :
|
2016-05-24 09:58:07 +00:00
|
|
|
Location(QQmlSourceLocation(), ref->url()), locationType(Compiling), ref(ref),
|
|
|
|
sent(false)
|
2016-04-25 12:52:12 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
|
|
|
return locationType != MaximumRangeType;
|
|
|
|
}
|
|
|
|
|
|
|
|
RangeType locationType;
|
|
|
|
QQmlRefPointer<QQmlRefCount> ref;
|
2016-05-24 09:58:07 +00:00
|
|
|
bool sent;
|
2016-04-25 12:52:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef QHash<quintptr, Location> LocationHash;
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
void startBinding(QV4::Function *function)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-12-20 10:26:48 +00:00
|
|
|
// Use the QV4::Function as ID, as that is common among different instances of the same
|
|
|
|
// component. QQmlBinding is per instance.
|
|
|
|
// Add 1 to the ID, to make it different from the IDs the V4 profiler produces. The +1 makes
|
|
|
|
// the pointer point into the middle of the QV4::Function. Thus it still points to valid
|
|
|
|
// memory but we cannot accidentally create a duplicate key from another object.
|
|
|
|
quintptr locationId(id(function) + 1);
|
2014-01-24 11:44:49 +00:00
|
|
|
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
|
2016-04-25 13:07:34 +00:00
|
|
|
(1 << RangeStart | 1 << RangeLocation), Binding,
|
2016-04-25 12:52:12 +00:00
|
|
|
locationId));
|
|
|
|
|
|
|
|
RefLocation &location = m_locations[locationId];
|
|
|
|
if (!location.isValid())
|
2016-12-20 10:26:48 +00:00
|
|
|
location = RefLocation(function);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Have toByteArrays() construct another RangeData event from the same QString later.
|
|
|
|
// This is somewhat pointless but important for backwards compatibility.
|
2016-04-25 12:52:12 +00:00
|
|
|
void startCompiling(QQmlDataBlob *blob)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
quintptr locationId(id(blob));
|
2014-01-24 11:44:49 +00:00
|
|
|
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
|
|
|
|
(1 << RangeStart | 1 << RangeLocation | 1 << RangeData),
|
2016-04-25 12:52:12 +00:00
|
|
|
Compiling, locationId));
|
|
|
|
|
|
|
|
RefLocation &location = m_locations[locationId];
|
|
|
|
if (!location.isValid())
|
|
|
|
location = RefLocation(blob);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
void startHandlingSignal(QQmlBoundSignalExpression *expression)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
quintptr locationId(id(expression));
|
2014-01-24 11:44:49 +00:00
|
|
|
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
|
2016-04-25 13:07:34 +00:00
|
|
|
(1 << RangeStart | 1 << RangeLocation), HandlingSignal,
|
2016-04-25 12:52:12 +00:00
|
|
|
locationId));
|
|
|
|
|
|
|
|
RefLocation &location = m_locations[locationId];
|
|
|
|
if (!location.isValid())
|
|
|
|
location = RefLocation(expression);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
void startCreating(const QV4::CompiledData::Object *obj)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
|
|
|
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
|
|
|
|
(1 << RangeStart | 1 << RangeLocation | 1 << RangeData),
|
2016-04-25 12:52:12 +00:00
|
|
|
Creating, id(obj)));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 10:26:48 +00:00
|
|
|
void updateCreating(const QV4::CompiledData::Object *obj,
|
|
|
|
QV4::CompiledData::CompilationUnit *ref,
|
2016-04-25 12:52:12 +00:00
|
|
|
const QUrl &url, const QString &type)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
quintptr locationId(id(obj));
|
|
|
|
RefLocation &location = m_locations[locationId];
|
|
|
|
if (!location.isValid())
|
|
|
|
location = RefLocation(ref, url, obj, type);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<RangeType Range>
|
|
|
|
void endRange()
|
|
|
|
{
|
2016-04-25 13:07:34 +00:00
|
|
|
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), 1 << RangeEnd, Range));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QQmlProfiler();
|
|
|
|
|
2014-09-03 17:28:35 +00:00
|
|
|
quint64 featuresEnabled;
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
template<typename Object>
|
|
|
|
static quintptr id(const Object *pointer)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<quintptr>(pointer);
|
|
|
|
}
|
|
|
|
|
2014-09-03 17:28:35 +00:00
|
|
|
void startProfiling(quint64 features);
|
2014-01-24 11:44:49 +00:00
|
|
|
void stopProfiling();
|
2016-05-24 09:58:07 +00:00
|
|
|
void reportData(bool trackLocations);
|
2014-01-24 11:44:49 +00:00
|
|
|
void setTimer(const QElapsedTimer &timer) { m_timer = timer; }
|
|
|
|
|
|
|
|
signals:
|
2016-04-25 12:52:12 +00:00
|
|
|
void dataReady(const QVector<QQmlProfilerData> &, const QQmlProfiler::LocationHash &);
|
2014-01-24 11:44:49 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
QElapsedTimer m_timer;
|
2016-04-25 12:52:12 +00:00
|
|
|
QHash<quintptr, RefLocation> m_locations;
|
2015-07-28 11:22:33 +00:00
|
|
|
QVector<QQmlProfilerData> m_data;
|
2014-01-24 11:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// RAII helper structs
|
|
|
|
//
|
|
|
|
|
|
|
|
struct QQmlProfilerHelper : public QQmlProfilerDefinitions {
|
|
|
|
QQmlProfiler *profiler;
|
|
|
|
QQmlProfilerHelper(QQmlProfiler *profiler) : profiler(profiler) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlBindingProfiler : public QQmlProfilerHelper {
|
2016-12-20 10:26:48 +00:00
|
|
|
QQmlBindingProfiler(QQmlProfiler *profiler, QV4::Function *function) :
|
2014-01-24 11:44:49 +00:00
|
|
|
QQmlProfilerHelper(profiler)
|
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler,
|
2016-12-20 10:26:48 +00:00
|
|
|
startBinding(function));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~QQmlBindingProfiler()
|
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler,
|
|
|
|
endRange<Binding>());
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlHandlingSignalProfiler : public QQmlProfilerHelper {
|
|
|
|
QQmlHandlingSignalProfiler(QQmlProfiler *profiler, QQmlBoundSignalExpression *expression) :
|
|
|
|
QQmlProfilerHelper(profiler)
|
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler,
|
2016-04-25 12:52:12 +00:00
|
|
|
startHandlingSignal(expression));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~QQmlHandlingSignalProfiler()
|
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler,
|
|
|
|
endRange<QQmlProfiler::HandlingSignal>());
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlCompilingProfiler : public QQmlProfilerHelper {
|
2016-04-25 12:52:12 +00:00
|
|
|
QQmlCompilingProfiler(QQmlProfiler *profiler, QQmlDataBlob *blob) :
|
2014-01-24 11:44:49 +00:00
|
|
|
QQmlProfilerHelper(profiler)
|
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, startCompiling(blob));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~QQmlCompilingProfiler()
|
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, endRange<Compiling>());
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct QQmlVmeProfiler : public QQmlProfilerDefinitions {
|
|
|
|
public:
|
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
QQmlVmeProfiler() : profiler(0) {}
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
void init(QQmlProfiler *p, int maxDepth)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-04-02 10:02:14 +00:00
|
|
|
profiler = p;
|
|
|
|
ranges.allocate(maxDepth);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
const QV4::CompiledData::Object *pop()
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-04-02 10:02:14 +00:00
|
|
|
if (ranges.count() > 0)
|
|
|
|
return ranges.pop();
|
|
|
|
else
|
2016-04-25 12:52:12 +00:00
|
|
|
return nullptr;
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
void push(const QV4::CompiledData::Object *object)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-04-02 10:02:14 +00:00
|
|
|
if (ranges.capacity() > ranges.count())
|
2016-04-25 12:52:12 +00:00
|
|
|
ranges.push(object);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
QQmlProfiler *profiler;
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
private:
|
2016-04-25 12:52:12 +00:00
|
|
|
QFiniteStack<const QV4::CompiledData::Object *> ranges;
|
2014-04-02 10:02:14 +00:00
|
|
|
};
|
|
|
|
|
2016-04-25 12:52:12 +00:00
|
|
|
class QQmlObjectCreationProfiler {
|
2014-04-02 10:02:14 +00:00
|
|
|
public:
|
|
|
|
|
2016-05-24 09:58:07 +00:00
|
|
|
QQmlObjectCreationProfiler(QQmlProfiler *profiler, const QV4::CompiledData::Object *obj)
|
|
|
|
: profiler(profiler)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-05-24 09:58:07 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, startCreating(obj));
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
~QQmlObjectCreationProfiler()
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, endRange<QQmlProfilerDefinitions::Creating>());
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 10:22:11 +00:00
|
|
|
void update(QV4::CompiledData::CompilationUnit *ref, const QV4::CompiledData::Object *obj,
|
2016-04-25 12:52:12 +00:00
|
|
|
const QString &typeName, const QUrl &url)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2016-04-25 12:52:12 +00:00
|
|
|
profiler->updateCreating(obj, ref, url, typeName);
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-04-02 10:02:14 +00:00
|
|
|
QQmlProfiler *profiler;
|
|
|
|
};
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
class QQmlObjectCompletionProfiler {
|
|
|
|
public:
|
|
|
|
QQmlObjectCompletionProfiler(QQmlVmeProfiler *parent) :
|
|
|
|
profiler(parent->profiler)
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, {
|
2016-04-25 12:52:12 +00:00
|
|
|
profiler->startCreating(parent->pop());
|
2014-04-02 10:02:14 +00:00
|
|
|
});
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 10:02:14 +00:00
|
|
|
~QQmlObjectCompletionProfiler()
|
2014-01-24 11:44:49 +00:00
|
|
|
{
|
2014-09-03 17:28:35 +00:00
|
|
|
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler,
|
|
|
|
endRange<QQmlProfilerDefinitions::Creating>());
|
2014-01-24 11:44:49 +00:00
|
|
|
}
|
2014-04-02 10:02:14 +00:00
|
|
|
private:
|
|
|
|
QQmlProfiler *profiler;
|
2014-01-24 11:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
2015-07-20 16:15:05 +00:00
|
|
|
Q_DECLARE_METATYPE(QVector<QQmlProfilerData>)
|
2016-04-25 12:52:12 +00:00
|
|
|
Q_DECLARE_METATYPE(QQmlProfiler::LocationHash)
|
2014-01-24 11:44:49 +00:00
|
|
|
|
2016-07-25 15:20:04 +00:00
|
|
|
#endif // QT_NO_QML_DEBUGGER
|
|
|
|
|
2014-01-24 11:44:49 +00:00
|
|
|
#endif // QQMLPROFILER_P_H
|