Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/debugger/qqmlprofiler_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #ifndef QQMLPROFILER_P_H | - | ||||||||||||
41 | #define QQMLPROFILER_P_H | - | ||||||||||||
42 | - | |||||||||||||
43 | // | - | ||||||||||||
44 | // W A R N I N G | - | ||||||||||||
45 | // ------------- | - | ||||||||||||
46 | // | - | ||||||||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||||||||
48 | // implementation detail. This header file may change from version to | - | ||||||||||||
49 | // version without notice, or even be removed. | - | ||||||||||||
50 | // | - | ||||||||||||
51 | // We mean it. | - | ||||||||||||
52 | // | - | ||||||||||||
53 | - | |||||||||||||
54 | #include <private/qv4function_p.h> | - | ||||||||||||
55 | #include <private/qqmlboundsignal_p.h> | - | ||||||||||||
56 | #include <private/qfinitestack_p.h> | - | ||||||||||||
57 | #include <private/qqmlbinding_p.h> | - | ||||||||||||
58 | #if QT_CONFIG(qml_debug) | - | ||||||||||||
59 | #include "qqmlprofilerdefinitions_p.h" | - | ||||||||||||
60 | #include "qqmlabstractprofileradapter_p.h" | - | ||||||||||||
61 | #endif | - | ||||||||||||
62 | - | |||||||||||||
63 | #include <QUrl> | - | ||||||||||||
64 | #include <QString> | - | ||||||||||||
65 | - | |||||||||||||
66 | QT_BEGIN_NAMESPACE | - | ||||||||||||
67 | - | |||||||||||||
68 | #if !QT_CONFIG(qml_debug) | - | ||||||||||||
69 | - | |||||||||||||
70 | #define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code) | - | ||||||||||||
71 | #define Q_QML_PROFILE(feature, profiler, Method) | - | ||||||||||||
72 | #define Q_QML_OC_PROFILE(member, Code) | - | ||||||||||||
73 | - | |||||||||||||
74 | class QQmlProfiler {}; | - | ||||||||||||
75 | - | |||||||||||||
76 | struct QQmlBindingProfiler | - | ||||||||||||
77 | { | - | ||||||||||||
78 | QQmlBindingProfiler(quintptr, QV4::Function *) {} | - | ||||||||||||
79 | }; | - | ||||||||||||
80 | - | |||||||||||||
81 | struct QQmlHandlingSignalProfiler | - | ||||||||||||
82 | { | - | ||||||||||||
83 | QQmlHandlingSignalProfiler(quintptr, QQmlBoundSignalExpression *) {} | - | ||||||||||||
84 | }; | - | ||||||||||||
85 | - | |||||||||||||
86 | struct QQmlCompilingProfiler | - | ||||||||||||
87 | { | - | ||||||||||||
88 | QQmlCompilingProfiler(quintptr, QQmlDataBlob *) {} | - | ||||||||||||
89 | }; | - | ||||||||||||
90 | - | |||||||||||||
91 | struct QQmlVmeProfiler { | - | ||||||||||||
92 | QQmlVmeProfiler() {} | - | ||||||||||||
93 | - | |||||||||||||
94 | void init(quintptr, int) {} | - | ||||||||||||
95 | - | |||||||||||||
96 | const QV4::CompiledData::Object *pop() { return nullptr; } | - | ||||||||||||
97 | void push(const QV4::CompiledData::Object *) {} | - | ||||||||||||
98 | - | |||||||||||||
99 | static const quintptr profiler = 0; | - | ||||||||||||
100 | }; | - | ||||||||||||
101 | - | |||||||||||||
102 | struct QQmlObjectCreationProfiler | - | ||||||||||||
103 | { | - | ||||||||||||
104 | QQmlObjectCreationProfiler(quintptr, const QV4::CompiledData::Object *) {} | - | ||||||||||||
105 | void update(QV4::CompiledData::CompilationUnit *, const QV4::CompiledData::Object *, | - | ||||||||||||
106 | const QString &, const QUrl &) {} | - | ||||||||||||
107 | }; | - | ||||||||||||
108 | - | |||||||||||||
109 | struct QQmlObjectCompletionProfiler | - | ||||||||||||
110 | { | - | ||||||||||||
111 | QQmlObjectCompletionProfiler(QQmlVmeProfiler *) {} | - | ||||||||||||
112 | }; | - | ||||||||||||
113 | - | |||||||||||||
114 | #else | - | ||||||||||||
115 | - | |||||||||||||
116 | #define Q_QML_PROFILE_IF_ENABLED(feature, profiler, Code)\ | - | ||||||||||||
117 | if (profiler && (profiler->featuresEnabled & (1 << feature))) {\ | - | ||||||||||||
118 | Code;\ | - | ||||||||||||
119 | } else\ | - | ||||||||||||
120 | (void)0 | - | ||||||||||||
121 | - | |||||||||||||
122 | #define Q_QML_PROFILE(feature, profiler, Method)\ | - | ||||||||||||
123 | Q_QML_PROFILE_IF_ENABLED(feature, profiler, profiler->Method) | - | ||||||||||||
124 | - | |||||||||||||
125 | #define Q_QML_OC_PROFILE(member, Code)\ | - | ||||||||||||
126 | Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, member.profiler, Code) | - | ||||||||||||
127 | - | |||||||||||||
128 | // This struct is somewhat dangerous to use: | - | ||||||||||||
129 | // The messageType is a bit field. You can pack multiple messages into | - | ||||||||||||
130 | // one object, e.g. RangeStart and RangeLocation. Each one will be read | - | ||||||||||||
131 | // independently when converting to QByteArrays. Thus you can only pack | - | ||||||||||||
132 | // messages if their data doesn't overlap. It's up to you to figure that | - | ||||||||||||
133 | // out. | - | ||||||||||||
134 | struct Q_AUTOTEST_EXPORT QQmlProfilerData : public QQmlProfilerDefinitions | - | ||||||||||||
135 | { | - | ||||||||||||
136 | QQmlProfilerData(qint64 time = -1, int messageType = -1, | - | ||||||||||||
137 | RangeType detailType = MaximumRangeType, quintptr locationId = 0) : | - | ||||||||||||
138 | time(time), locationId(locationId), messageType(messageType), detailType(detailType) | - | ||||||||||||
139 | {} executed 44 times by 1 test: end of block Executed by:
| 44 | ||||||||||||
140 | - | |||||||||||||
141 | qint64 time; | - | ||||||||||||
142 | quintptr locationId; | - | ||||||||||||
143 | - | |||||||||||||
144 | int messageType; //bit field of QQmlProfilerService::Message | - | ||||||||||||
145 | RangeType detailType; | - | ||||||||||||
146 | }; | - | ||||||||||||
147 | - | |||||||||||||
148 | Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE); | - | ||||||||||||
149 | - | |||||||||||||
150 | class Q_QML_PRIVATE_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDefinitions { | - | ||||||||||||
151 | Q_OBJECT | - | ||||||||||||
152 | public: | - | ||||||||||||
153 | - | |||||||||||||
154 | struct Location { | - | ||||||||||||
155 | Location(const QQmlSourceLocation &location = QQmlSourceLocation(), | - | ||||||||||||
156 | const QUrl &url = QUrl()) : | - | ||||||||||||
157 | location(location), url(url) {} executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||
158 | QQmlSourceLocation location; | - | ||||||||||||
159 | QUrl url; | - | ||||||||||||
160 | }; | - | ||||||||||||
161 | - | |||||||||||||
162 | // Unfortunately we have to resolve the locations right away because the QML context might not | - | ||||||||||||
163 | // be available anymore when we send the data. | - | ||||||||||||
164 | struct RefLocation : public Location { | - | ||||||||||||
165 | RefLocation() | - | ||||||||||||
166 | : Location(), locationType(MaximumRangeType), something(nullptr), sent(false) | - | ||||||||||||
167 | { | - | ||||||||||||
168 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||
169 | - | |||||||||||||
170 | RefLocation(QV4::Function *ref) | - | ||||||||||||
171 | : Location(ref->sourceLocation()), locationType(Binding), sent(false) | - | ||||||||||||
172 | { | - | ||||||||||||
173 | function = ref; | - | ||||||||||||
174 | function->compilationUnit->addref(); | - | ||||||||||||
175 | } never executed: end of block | 0 | ||||||||||||
176 | - | |||||||||||||
177 | RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, const QString &type) | - | ||||||||||||
178 | : Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url), | - | ||||||||||||
179 | locationType(Creating), sent(false) | - | ||||||||||||
180 | { | - | ||||||||||||
181 | unit = ref; | - | ||||||||||||
182 | unit->addref(); | - | ||||||||||||
183 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
184 | - | |||||||||||||
185 | RefLocation(QQmlBoundSignalExpression *ref) | - | ||||||||||||
186 | : Location(ref->sourceLocation()), locationType(HandlingSignal), sent(false) | - | ||||||||||||
187 | { | - | ||||||||||||
188 | boundSignal = ref; | - | ||||||||||||
189 | boundSignal->addref(); | - | ||||||||||||
190 | } never executed: end of block | 0 | ||||||||||||
191 | - | |||||||||||||
192 | RefLocation(QQmlDataBlob *ref) | - | ||||||||||||
193 | : Location(QQmlSourceLocation(), ref->url()), locationType(Compiling), sent(false) | - | ||||||||||||
194 | { | - | ||||||||||||
195 | blob = ref; | - | ||||||||||||
196 | blob->addref(); | - | ||||||||||||
197 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
198 | - | |||||||||||||
199 | RefLocation(const RefLocation &other) | - | ||||||||||||
200 | : Location(other), | - | ||||||||||||
201 | locationType(other.locationType), | - | ||||||||||||
202 | function(other.function), | - | ||||||||||||
203 | sent(other.sent) | - | ||||||||||||
204 | { | - | ||||||||||||
205 | addref(); | - | ||||||||||||
206 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||
207 | - | |||||||||||||
208 | RefLocation &operator=(const RefLocation &other) | - | ||||||||||||
209 | { | - | ||||||||||||
210 | if (this != &other) {
| 0-14 | ||||||||||||
211 | release(); | - | ||||||||||||
212 | Location::operator=(other); | - | ||||||||||||
213 | locationType = other.locationType; | - | ||||||||||||
214 | function = other.function; | - | ||||||||||||
215 | sent = other.sent; | - | ||||||||||||
216 | addref(); | - | ||||||||||||
217 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||
218 | return *this; executed 14 times by 1 test: return *this; Executed by:
| 14 | ||||||||||||
219 | } | - | ||||||||||||
220 | - | |||||||||||||
221 | ~RefLocation() | - | ||||||||||||
222 | { | - | ||||||||||||
223 | release(); | - | ||||||||||||
224 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||
225 | - | |||||||||||||
226 | void addref() | - | ||||||||||||
227 | { | - | ||||||||||||
228 | if (isNull())
| 14-16 | ||||||||||||
229 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||
230 | - | |||||||||||||
231 | switch (locationType) { | - | ||||||||||||
232 | case Binding: never executed: case Binding: | 0 | ||||||||||||
233 | function->compilationUnit->addref(); | - | ||||||||||||
234 | break; never executed: break; | 0 | ||||||||||||
235 | case Creating: executed 8 times by 1 test: case Creating: Executed by:
| 8 | ||||||||||||
236 | unit->addref(); | - | ||||||||||||
237 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||
238 | case HandlingSignal: never executed: case HandlingSignal: | 0 | ||||||||||||
239 | boundSignal->addref(); | - | ||||||||||||
240 | break; never executed: break; | 0 | ||||||||||||
241 | case Compiling: executed 6 times by 1 test: case Compiling: Executed by:
| 6 | ||||||||||||
242 | blob->addref(); | - | ||||||||||||
243 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||
244 | default: never executed: default: | 0 | ||||||||||||
245 | Q_ASSERT(locationType == MaximumRangeType); | - | ||||||||||||
246 | break; never executed: break; | 0 | ||||||||||||
247 | } | - | ||||||||||||
248 | } | - | ||||||||||||
249 | - | |||||||||||||
250 | void release() | - | ||||||||||||
251 | { | - | ||||||||||||
252 | if (isNull())
| 14-30 | ||||||||||||
253 | return; executed 30 times by 1 test: return; Executed by:
| 30 | ||||||||||||
254 | - | |||||||||||||
255 | switch (locationType) { | - | ||||||||||||
256 | case Binding: never executed: case Binding: | 0 | ||||||||||||
257 | function->compilationUnit->release(); | - | ||||||||||||
258 | break; never executed: break; | 0 | ||||||||||||
259 | case Creating: executed 8 times by 1 test: case Creating: Executed by:
| 8 | ||||||||||||
260 | unit->release(); | - | ||||||||||||
261 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||
262 | case HandlingSignal: never executed: case HandlingSignal: | 0 | ||||||||||||
263 | boundSignal->release(); | - | ||||||||||||
264 | break; never executed: break; | 0 | ||||||||||||
265 | case Compiling: executed 6 times by 1 test: case Compiling: Executed by:
| 6 | ||||||||||||
266 | blob->release(); | - | ||||||||||||
267 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||
268 | default: never executed: default: | 0 | ||||||||||||
269 | Q_ASSERT(locationType == MaximumRangeType); | - | ||||||||||||
270 | break; never executed: break; | 0 | ||||||||||||
271 | } | - | ||||||||||||
272 | } | - | ||||||||||||
273 | - | |||||||||||||
274 | bool isValid() const | - | ||||||||||||
275 | { | - | ||||||||||||
276 | return locationType != MaximumRangeType; executed 16 times by 1 test: return locationType != MaximumRangeType; Executed by:
| 16 | ||||||||||||
277 | } | - | ||||||||||||
278 | - | |||||||||||||
279 | bool isNull() const | - | ||||||||||||
280 | { | - | ||||||||||||
281 | return !something; executed 74 times by 1 test: return !something; Executed by:
| 74 | ||||||||||||
282 | } | - | ||||||||||||
283 | - | |||||||||||||
284 | RangeType locationType; | - | ||||||||||||
285 | union { | - | ||||||||||||
286 | QV4::Function *function; | - | ||||||||||||
287 | QV4::CompiledData::CompilationUnit *unit; | - | ||||||||||||
288 | QQmlBoundSignalExpression *boundSignal; | - | ||||||||||||
289 | QQmlDataBlob *blob; | - | ||||||||||||
290 | void *something; | - | ||||||||||||
291 | }; | - | ||||||||||||
292 | bool sent; | - | ||||||||||||
293 | }; | - | ||||||||||||
294 | - | |||||||||||||
295 | typedef QHash<quintptr, Location> LocationHash; | - | ||||||||||||
296 | - | |||||||||||||
297 | void startBinding(QV4::Function *function) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | // Use the QV4::Function as ID, as that is common among different instances of the same | - | ||||||||||||
300 | // component. QQmlBinding is per instance. | - | ||||||||||||
301 | // Add 1 to the ID, to make it different from the IDs the V4 and signal handling profilers | - | ||||||||||||
302 | // produce. The +1 makes the pointer point into the middle of the QV4::Function. Thus it | - | ||||||||||||
303 | // still points to valid memory but we cannot accidentally create a duplicate key from | - | ||||||||||||
304 | // another object. | - | ||||||||||||
305 | // If there is no function, use a static but valid address: The profiler itself. | - | ||||||||||||
306 | quintptr locationId = function ? id(function) + 1 : id(this);
| 0-2 | ||||||||||||
307 | m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), | - | ||||||||||||
308 | (1 << RangeStart | 1 << RangeLocation), Binding, | - | ||||||||||||
309 | locationId)); | - | ||||||||||||
310 | - | |||||||||||||
311 | RefLocation &location = m_locations[locationId]; | - | ||||||||||||
312 | if (!location.isValid()) {
| 0-2 | ||||||||||||
313 | if (function)
| 0-2 | ||||||||||||
314 | location = RefLocation(function); never executed: location = RefLocation(function); | 0 | ||||||||||||
315 | else // Make it valid without actually providing a location | - | ||||||||||||
316 | location.locationType = Binding; executed 2 times by 1 test: location.locationType = Binding; Executed by:
| 2 | ||||||||||||
317 | } | - | ||||||||||||
318 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
319 | - | |||||||||||||
320 | // Have toByteArrays() construct another RangeData event from the same QString later. | - | ||||||||||||
321 | // This is somewhat pointless but important for backwards compatibility. | - | ||||||||||||
322 | void startCompiling(QQmlDataBlob *blob) | - | ||||||||||||
323 | { | - | ||||||||||||
324 | quintptr locationId(id(blob)); | - | ||||||||||||
325 | m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), | - | ||||||||||||
326 | (1 << RangeStart | 1 << RangeLocation | 1 << RangeData), | - | ||||||||||||
327 | Compiling, locationId)); | - | ||||||||||||
328 | - | |||||||||||||
329 | RefLocation &location = m_locations[locationId]; | - | ||||||||||||
330 | if (!location.isValid())
| 0-6 | ||||||||||||
331 | location = RefLocation(blob); executed 6 times by 1 test: location = RefLocation(blob); Executed by:
| 6 | ||||||||||||
332 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
333 | - | |||||||||||||
334 | void startHandlingSignal(QQmlBoundSignalExpression *expression) | - | ||||||||||||
335 | { | - | ||||||||||||
336 | // Use the QV4::Function as ID, as that is common among different instances of the same | - | ||||||||||||
337 | // component. QQmlBoundSignalExpression is per instance. | - | ||||||||||||
338 | // Add 2 to the ID, to make it different from the IDs the V4 and binding profilers produce. | - | ||||||||||||
339 | // The +2 makes the pointer point into the middle of the QV4::Function. Thus it still points | - | ||||||||||||
340 | // to valid memory but we cannot accidentally create a duplicate key from another object. | - | ||||||||||||
341 | quintptr locationId(id(expression->function()) + 2); | - | ||||||||||||
342 | m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), | - | ||||||||||||
343 | (1 << RangeStart | 1 << RangeLocation), HandlingSignal, | - | ||||||||||||
344 | locationId)); | - | ||||||||||||
345 | - | |||||||||||||
346 | RefLocation &location = m_locations[locationId]; | - | ||||||||||||
347 | if (!location.isValid())
| 0 | ||||||||||||
348 | location = RefLocation(expression); never executed: location = RefLocation(expression); | 0 | ||||||||||||
349 | } never executed: end of block | 0 | ||||||||||||
350 | - | |||||||||||||
351 | void startCreating(const QV4::CompiledData::Object *obj) | - | ||||||||||||
352 | { | - | ||||||||||||
353 | m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), | - | ||||||||||||
354 | (1 << RangeStart | 1 << RangeLocation | 1 << RangeData), | - | ||||||||||||
355 | Creating, id(obj))); | - | ||||||||||||
356 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||
357 | - | |||||||||||||
358 | void updateCreating(const QV4::CompiledData::Object *obj, | - | ||||||||||||
359 | QV4::CompiledData::CompilationUnit *ref, | - | ||||||||||||
360 | const QUrl &url, const QString &type) | - | ||||||||||||
361 | { | - | ||||||||||||
362 | quintptr locationId(id(obj)); | - | ||||||||||||
363 | RefLocation &location = m_locations[locationId]; | - | ||||||||||||
364 | if (!location.isValid())
| 0-8 | ||||||||||||
365 | location = RefLocation(ref, url, obj, type); executed 8 times by 1 test: location = RefLocation(ref, url, obj, type); Executed by:
| 8 | ||||||||||||
366 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
367 | - | |||||||||||||
368 | template<RangeType Range> | - | ||||||||||||
369 | void endRange() | - | ||||||||||||
370 | { | - | ||||||||||||
371 | m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), 1 << RangeEnd, Range)); | - | ||||||||||||
372 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||
373 | - | |||||||||||||
374 | QQmlProfiler(); | - | ||||||||||||
375 | - | |||||||||||||
376 | quint64 featuresEnabled; | - | ||||||||||||
377 | - | |||||||||||||
378 | template<typename Object> | - | ||||||||||||
379 | static quintptr id(const Object *pointer) | - | ||||||||||||
380 | { | - | ||||||||||||
381 | return reinterpret_cast<quintptr>(pointer); executed 30 times by 1 test: return reinterpret_cast<quintptr>(pointer); Executed by:
| 30 | ||||||||||||
382 | } | - | ||||||||||||
383 | - | |||||||||||||
384 | void startProfiling(quint64 features); | - | ||||||||||||
385 | void stopProfiling(); | - | ||||||||||||
386 | void reportData(); | - | ||||||||||||
387 | void setTimer(const QElapsedTimer &timer) { m_timer = timer; } executed 64 times by 3 tests: end of block Executed by:
| 64 | ||||||||||||
388 | - | |||||||||||||
389 | signals: | - | ||||||||||||
390 | void dataReady(const QVector<QQmlProfilerData> &, const QQmlProfiler::LocationHash &); | - | ||||||||||||
391 | - | |||||||||||||
392 | protected: | - | ||||||||||||
393 | QElapsedTimer m_timer; | - | ||||||||||||
394 | QHash<quintptr, RefLocation> m_locations; | - | ||||||||||||
395 | QVector<QQmlProfilerData> m_data; | - | ||||||||||||
396 | }; | - | ||||||||||||
397 | - | |||||||||||||
398 | // | - | ||||||||||||
399 | // RAII helper structs | - | ||||||||||||
400 | // | - | ||||||||||||
401 | - | |||||||||||||
402 | struct QQmlProfilerHelper : public QQmlProfilerDefinitions { | - | ||||||||||||
403 | QQmlProfiler *profiler; | - | ||||||||||||
404 | QQmlProfilerHelper(QQmlProfiler *profiler) : profiler(profiler) {} executed 946959 times by 141 tests: end of block Executed by:
| 946959 | ||||||||||||
405 | }; | - | ||||||||||||
406 | - | |||||||||||||
407 | struct QQmlBindingProfiler : public QQmlProfilerHelper { | - | ||||||||||||
408 | QQmlBindingProfiler(QQmlProfiler *profiler, QV4::Function *function) : | - | ||||||||||||
409 | QQmlProfilerHelper(profiler) | - | ||||||||||||
410 | { | - | ||||||||||||
411 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, executed 2 times by 1 test: end of block Executed by:
executed 891366 times by 120 tests: (void)0 ; Executed by:
| 0-891366 | ||||||||||||
412 | startBinding(function)); executed 891366 times by 120 tests: (void)0 ; Executed by:
| 891366 | ||||||||||||
413 | } | - | ||||||||||||
414 | - | |||||||||||||
415 | ~QQmlBindingProfiler() | - | ||||||||||||
416 | { | - | ||||||||||||
417 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, executed 2 times by 1 test: end of block Executed by:
executed 891366 times by 120 tests: (void)0 ; Executed by:
| 0-891366 | ||||||||||||
418 | endRange<Binding>()); executed 891366 times by 120 tests: (void)0 ; Executed by:
| 891366 | ||||||||||||
419 | } | - | ||||||||||||
420 | }; | - | ||||||||||||
421 | - | |||||||||||||
422 | struct QQmlHandlingSignalProfiler : public QQmlProfilerHelper { | - | ||||||||||||
423 | QQmlHandlingSignalProfiler(QQmlProfiler *profiler, QQmlBoundSignalExpression *expression) : | - | ||||||||||||
424 | QQmlProfilerHelper(profiler) | - | ||||||||||||
425 | { | - | ||||||||||||
426 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler, never executed: end of block never executed: (void)0 ;
| 0 | ||||||||||||
427 | startHandlingSignal(expression)); never executed: (void)0 ; | 0 | ||||||||||||
428 | } | - | ||||||||||||
429 | - | |||||||||||||
430 | ~QQmlHandlingSignalProfiler() | - | ||||||||||||
431 | { | - | ||||||||||||
432 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileHandlingSignal, profiler, never executed: end of block never executed: (void)0 ;
| 0 | ||||||||||||
433 | endRange<QQmlProfiler::HandlingSignal>()); never executed: (void)0 ; | 0 | ||||||||||||
434 | } | - | ||||||||||||
435 | }; | - | ||||||||||||
436 | - | |||||||||||||
437 | struct QQmlCompilingProfiler : public QQmlProfilerHelper { | - | ||||||||||||
438 | QQmlCompilingProfiler(QQmlProfiler *profiler, QQmlDataBlob *blob) : | - | ||||||||||||
439 | QQmlProfilerHelper(profiler) | - | ||||||||||||
440 | { | - | ||||||||||||
441 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, startCompiling(blob)); executed 6 times by 1 test: end of block Executed by:
executed 55585 times by 140 tests: (void)0; Executed by:
| 6-55585 | ||||||||||||
442 | } | - | ||||||||||||
443 | - | |||||||||||||
444 | ~QQmlCompilingProfiler() | - | ||||||||||||
445 | { | - | ||||||||||||
446 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCompiling, profiler, endRange<Compiling>()); executed 6 times by 1 test: end of block Executed by:
executed 55585 times by 140 tests: (void)0; Executed by:
| 6-55585 | ||||||||||||
447 | } | - | ||||||||||||
448 | }; | - | ||||||||||||
449 | - | |||||||||||||
450 | struct QQmlVmeProfiler : public QQmlProfilerDefinitions { | - | ||||||||||||
451 | public: | - | ||||||||||||
452 | - | |||||||||||||
453 | QQmlVmeProfiler() : profiler(nullptr) {} executed 152912 times by 139 tests: end of block Executed by:
| 152912 | ||||||||||||
454 | - | |||||||||||||
455 | void init(QQmlProfiler *p, int maxDepth) | - | ||||||||||||
456 | { | - | ||||||||||||
457 | profiler = p; | - | ||||||||||||
458 | ranges.allocate(maxDepth); | - | ||||||||||||
459 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
460 | - | |||||||||||||
461 | const QV4::CompiledData::Object *pop() | - | ||||||||||||
462 | { | - | ||||||||||||
463 | if (ranges.count() > 0)
| 0-6 | ||||||||||||
464 | return ranges.pop(); executed 6 times by 1 test: return ranges.pop(); Executed by:
| 6 | ||||||||||||
465 | else | - | ||||||||||||
466 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||
467 | } | - | ||||||||||||
468 | - | |||||||||||||
469 | void push(const QV4::CompiledData::Object *object) | - | ||||||||||||
470 | { | - | ||||||||||||
471 | if (ranges.capacity() > ranges.count())
| 0-6 | ||||||||||||
472 | ranges.push(object); executed 6 times by 1 test: ranges.push(object); Executed by:
| 6 | ||||||||||||
473 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
474 | - | |||||||||||||
475 | QQmlProfiler *profiler; | - | ||||||||||||
476 | - | |||||||||||||
477 | private: | - | ||||||||||||
478 | QFiniteStack<const QV4::CompiledData::Object *> ranges; | - | ||||||||||||
479 | }; | - | ||||||||||||
480 | - | |||||||||||||
481 | class QQmlObjectCreationProfiler { | - | ||||||||||||
482 | public: | - | ||||||||||||
483 | - | |||||||||||||
484 | QQmlObjectCreationProfiler(QQmlProfiler *profiler, const QV4::CompiledData::Object *obj) | - | ||||||||||||
485 | : profiler(profiler) | - | ||||||||||||
486 | { | - | ||||||||||||
487 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, startCreating(obj)); executed 8 times by 1 test: end of block Executed by:
executed 521528 times by 138 tests: (void)0; Executed by:
| 0-521528 | ||||||||||||
488 | } | - | ||||||||||||
489 | - | |||||||||||||
490 | ~QQmlObjectCreationProfiler() | - | ||||||||||||
491 | { | - | ||||||||||||
492 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, endRange<QQmlProfilerDefinitions::Creating>()); executed 8 times by 1 test: end of block Executed by:
executed 521528 times by 138 tests: (void)0; Executed by:
| 0-521528 | ||||||||||||
493 | } | - | ||||||||||||
494 | - | |||||||||||||
495 | void update(QV4::CompiledData::CompilationUnit *ref, const QV4::CompiledData::Object *obj, | - | ||||||||||||
496 | const QString &typeName, const QUrl &url) | - | ||||||||||||
497 | { | - | ||||||||||||
498 | profiler->updateCreating(obj, ref, url, typeName); | - | ||||||||||||
499 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
500 | - | |||||||||||||
501 | private: | - | ||||||||||||
502 | QQmlProfiler *profiler; | - | ||||||||||||
503 | }; | - | ||||||||||||
504 | - | |||||||||||||
505 | class QQmlObjectCompletionProfiler { | - | ||||||||||||
506 | public: | - | ||||||||||||
507 | QQmlObjectCompletionProfiler(QQmlVmeProfiler *parent) : | - | ||||||||||||
508 | profiler(parent->profiler) | - | ||||||||||||
509 | { | - | ||||||||||||
510 | Q_QML_PROFILE_IF_ENABLED(QQmlProfilerDefinitions::ProfileCreating, profiler, { executed 6 times by 1 test: end of block Executed by:
executed 479706 times by 131 tests: (void)0 ; Executed by:
| 0-479706 | ||||||||||||
511 | profiler->startCreating(parent->pop()); executed 479706 times by 131 tests: (void)0 ; Executed by:
| 479706 | ||||||||||||
512 | }); executed 479706 times by 131 tests: (void)0 ; Executed by:
| 479706 | ||||||||||||
513 | } | - | ||||||||||||
514 | - | |||||||||||||
515 | ~QQmlObjectCompletionProfiler() | - | ||||||||||||
516 | { | - | ||||||||||||
517 | Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, executed 6 times by 1 test: end of block Executed by:
executed 479706 times by 131 tests: (void)0 ; Executed by:
| 0-479706 | ||||||||||||
518 | endRange<QQmlProfilerDefinitions::Creating>()); executed 479706 times by 131 tests: (void)0 ; Executed by:
| 479706 | ||||||||||||
519 | } | - | ||||||||||||
520 | private: | - | ||||||||||||
521 | QQmlProfiler *profiler; | - | ||||||||||||
522 | }; | - | ||||||||||||
523 | - | |||||||||||||
524 | #endif // QT_CONFIG(qml_debug) | - | ||||||||||||
525 | - | |||||||||||||
526 | QT_END_NAMESPACE | - | ||||||||||||
527 | - | |||||||||||||
528 | #if QT_CONFIG(qml_debug) | - | ||||||||||||
529 | - | |||||||||||||
530 | Q_DECLARE_METATYPE(QVector<QQmlProfilerData>) | - | ||||||||||||
531 | Q_DECLARE_METATYPE(QQmlProfiler::LocationHash) | - | ||||||||||||
532 | - | |||||||||||||
533 | #endif // QT_CONFIG(qml_debug) | - | ||||||||||||
534 | - | |||||||||||||
535 | #endif // QQMLPROFILER_P_H | - | ||||||||||||
Source code | Switch to Preprocessed file |