18#include <QtQml/private/qv4global_p.h>
22#include <QElapsedTimer>
24#if !QT_CONFIG(qml_debug)
26#define Q_V4_PROFILE_ALLOC(engine, size, type) Q_UNUSED(engine)
27#define Q_V4_PROFILE_DEALLOC(engine, size, type) Q_UNUSED(engine)
45#define Q_V4_PROFILE_ALLOC(engine, size, type)\
46 (engine->profiler() &&\
47 (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\
48 engine->profiler()->trackAlloc(size, type) : false)
50#define Q_V4_PROFILE_DEALLOC(engine, size, type) \
51 (engine->profiler() &&\
52 (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\
53 engine->profiler()->trackDealloc(size, type) : false)
63 FeatureMemoryAllocation
72struct FunctionCallProperties {
78struct FunctionLocation {
95typedef QHash<quintptr, QV4::Profiling::FunctionLocation> FunctionLocationHash;
97struct MemoryAllocationProperties {
105 FunctionCall() : m_function(
nullptr), m_start(0), m_end(0) {}
108 m_function(function), m_start(
start), m_end(
end)
109 { m_function->executableCompilationUnit()->addref(); }
111 FunctionCall(
const FunctionCall &
other) :
112 m_function(
other.m_function), m_start(
other.m_start), m_end(
other.m_end)
113 { m_function->executableCompilationUnit()->addref(); }
115 FunctionCall(FunctionCall &&
other) noexcept
116 : m_function(std::exchange(
other.m_function,
nullptr))
117 , m_start(std::exchange(
other.m_start, 0))
118 , m_end(std::exchange(
other.m_end, 0))
124 m_function->executableCompilationUnit()->release();
127 FunctionCall &operator=(
const FunctionCall &
other) {
128 if (&
other !=
this) {
129 if (
other.m_function)
130 other.m_function->executableCompilationUnit()->addref();
132 m_function->executableCompilationUnit()->release();
133 m_function =
other.m_function;
134 m_start =
other.m_start;
140 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(FunctionCall)
145 std::swap(m_start,
other.m_start);
146 std::swap(m_end,
other.m_end);
154 FunctionLocation resolveLocation()
const;
158 friend bool operator<(
const FunctionCall &call1,
const FunctionCall &call2);
165class Q_QML_EXPORT Profiler :
public QObject {
169 SentMarker() : m_function(
nullptr) {}
171 SentMarker(
const SentMarker &
other) : m_function(
other.m_function)
174 m_function->executableCompilationUnit()->addref();
180 m_function->executableCompilationUnit()->release();
183 SentMarker &operator=(
const SentMarker &
other)
185 if (&
other !=
this) {
187 m_function->executableCompilationUnit()->release();
188 m_function =
other.m_function;
189 m_function->executableCompilationUnit()->addref();
198 m_function->executableCompilationUnit()->addref();
202 {
return m_function !=
nullptr; }
234 void stopProfiling();
235 void startProfiling(
quint64 features);
240 void dataReady(
const QV4::Profiling::FunctionLocationHash &,
241 const QVector<QV4::Profiling::FunctionCallProperties> &,
242 const QVector<QV4::Profiling::MemoryAllocationProperties> &);
247 QVector<FunctionCall>
m_data;
248 QVector<MemoryAllocationProperties> m_memory_data;
249 QHash<quintptr, SentMarker> m_sentLocations;
251 friend class FunctionCallProfiler;
254class FunctionCallProfiler {
262 Profiler *
p =
engine->profiler();
263 if (
Q_UNLIKELY(
p) && (
p->featuresEnabled & (1 << Profiling::FeatureFunctionCall))) {
266 startTime = profiler->m_timer.nsecsElapsed();
270 ~FunctionCallProfiler()
273 profiler->m_data.append(FunctionCall(function,
startTime, profiler->m_timer.nsecsElapsed()));
276 Profiler *profiler =
nullptr;
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
FunctionCallProfiler(ExecutionEngine *, Function *)
type name READ getFunction WRITE setFunction
[0]
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei void GLsizei void * column
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
std::unique_ptr< ThunkPool::ThunkAllocation > allocation
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64