Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4profiling_p.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | namespace QV4 { | - | ||||||||||||||||||
5 | - | |||||||||||||||||||
6 | namespace Profiling { | - | ||||||||||||||||||
7 | - | |||||||||||||||||||
8 | enum Features { | - | ||||||||||||||||||
9 | FeatureFunctionCall, | - | ||||||||||||||||||
10 | FeatureMemoryAllocation | - | ||||||||||||||||||
11 | }; | - | ||||||||||||||||||
12 | - | |||||||||||||||||||
13 | enum MemoryType { | - | ||||||||||||||||||
14 | HeapPage, | - | ||||||||||||||||||
15 | LargeItem, | - | ||||||||||||||||||
16 | SmallItem | - | ||||||||||||||||||
17 | }; | - | ||||||||||||||||||
18 | - | |||||||||||||||||||
19 | struct FunctionCallProperties { | - | ||||||||||||||||||
20 | qint64 start; | - | ||||||||||||||||||
21 | qint64 end; | - | ||||||||||||||||||
22 | quintptr id; | - | ||||||||||||||||||
23 | }; | - | ||||||||||||||||||
24 | - | |||||||||||||||||||
25 | struct FunctionLocation { | - | ||||||||||||||||||
26 | FunctionLocation(const QString &name = QString(), const QString &file = QString(), | - | ||||||||||||||||||
27 | int line = -1, int column = -1) : | - | ||||||||||||||||||
28 | name(name), file(file), line(line), column(column) | - | ||||||||||||||||||
29 | {} executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | bool isValid() | - | ||||||||||||||||||
32 | { | - | ||||||||||||||||||
33 | return executed 8 times by 1 test: !name.isEmpty();return !name.isEmpty(); Executed by:
executed 8 times by 1 test: return !name.isEmpty(); Executed by:
| 8 | ||||||||||||||||||
34 | } | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | QString name; | - | ||||||||||||||||||
37 | QString file; | - | ||||||||||||||||||
38 | int line; | - | ||||||||||||||||||
39 | int column; | - | ||||||||||||||||||
40 | }; | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | typedef QHash<quintptr, QV4::Profiling::FunctionLocation> FunctionLocationHash; | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | struct MemoryAllocationProperties { | - | ||||||||||||||||||
45 | qint64 timestamp; | - | ||||||||||||||||||
46 | qint64 size; | - | ||||||||||||||||||
47 | MemoryType type; | - | ||||||||||||||||||
48 | }; | - | ||||||||||||||||||
49 | - | |||||||||||||||||||
50 | class FunctionCall { | - | ||||||||||||||||||
51 | public: | - | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | FunctionCall() : m_function(nullptr), m_start(0), m_end(0) | - | ||||||||||||||||||
54 | { ((false) ? static_cast<void>(0) : qt_assert_x(__PRETTY_FUNCTION__, "Cannot construct a function call without function", __FILE__, 143)); } never executed: end of block | 0 | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | FunctionCall(Function *function, qint64 start, qint64 end) : | - | ||||||||||||||||||
57 | m_function(function), m_start(start), m_end(end) | - | ||||||||||||||||||
58 | { m_function->compilationUnit->addref(); } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
59 | - | |||||||||||||||||||
60 | FunctionCall(const FunctionCall &other) : | - | ||||||||||||||||||
61 | m_function(other.m_function), m_start(other.m_start), m_end(other.m_end) | - | ||||||||||||||||||
62 | { m_function->compilationUnit->addref(); } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | ~FunctionCall() | - | ||||||||||||||||||
65 | { m_function->compilationUnit->release(); } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | FunctionCall &operator=(const FunctionCall &other) { | - | ||||||||||||||||||
68 | if (&other != this
| 0-28 | ||||||||||||||||||
69 | other.m_function->compilationUnit->addref(); | - | ||||||||||||||||||
70 | m_function->compilationUnit->release(); | - | ||||||||||||||||||
71 | m_function = other.m_function; | - | ||||||||||||||||||
72 | m_start = other.m_start; | - | ||||||||||||||||||
73 | m_end = other.m_end; | - | ||||||||||||||||||
74 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||
75 | return executed 28 times by 1 test: *this;return *this; Executed by:
executed 28 times by 1 test: return *this; Executed by:
| 28 | ||||||||||||||||||
76 | } | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | Function *function() const | - | ||||||||||||||||||
79 | { | - | ||||||||||||||||||
80 | return executed 14 times by 1 test: m_function;return m_function; Executed by:
executed 14 times by 1 test: return m_function; Executed by:
| 14 | ||||||||||||||||||
81 | } | - | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | FunctionLocation resolveLocation() const; | - | ||||||||||||||||||
84 | FunctionCallProperties properties() const; | - | ||||||||||||||||||
85 | - | |||||||||||||||||||
86 | private: | - | ||||||||||||||||||
87 | friend bool operator<(const FunctionCall &call1, const FunctionCall &call2); | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | Function *m_function; | - | ||||||||||||||||||
90 | qint64 m_start; | - | ||||||||||||||||||
91 | qint64 m_end; | - | ||||||||||||||||||
92 | }; | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | class __attribute__((visibility("default"))) Profiler : public QObject { | - | ||||||||||||||||||
95 | public: | - | ||||||||||||||||||
96 | #pragma GCC diagnostic push | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||||||||
99 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||||||||
100 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||||||||
101 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||
102 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
103 | struct QPrivateSignal {}; | - | ||||||||||||||||||
104 | public: | - | ||||||||||||||||||
105 | struct SentMarker { | - | ||||||||||||||||||
106 | SentMarker() : m_function(nullptr) {} executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
107 | - | |||||||||||||||||||
108 | SentMarker(const SentMarker &other) : m_function(other.m_function) | - | ||||||||||||||||||
109 | { | - | ||||||||||||||||||
110 | if (m_function
| 0-8 | ||||||||||||||||||
111 | m_function->compilationUnit->addref(); never executed: m_function->compilationUnit->addref(); | 0 | ||||||||||||||||||
112 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
113 | - | |||||||||||||||||||
114 | ~SentMarker() | - | ||||||||||||||||||
115 | { | - | ||||||||||||||||||
116 | if (m_function
| 8 | ||||||||||||||||||
117 | m_function->compilationUnit->release(); executed 8 times by 1 test: m_function->compilationUnit->release(); Executed by:
| 8 | ||||||||||||||||||
118 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | SentMarker &operator=(const SentMarker &other) | - | ||||||||||||||||||
121 | { | - | ||||||||||||||||||
122 | if (&other != this
| 0 | ||||||||||||||||||
123 | if (m_function
| 0 | ||||||||||||||||||
124 | m_function->compilationUnit->release(); never executed: m_function->compilationUnit->release(); | 0 | ||||||||||||||||||
125 | m_function = other.m_function; | - | ||||||||||||||||||
126 | m_function->compilationUnit->addref(); | - | ||||||||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||||||||
128 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | void setFunction(Function *function) | - | ||||||||||||||||||
132 | { | - | ||||||||||||||||||
133 | ((m_function == nullptr) ? static_cast<void>(0) : qt_assert("m_function == nullptr", __FILE__, 214)); | - | ||||||||||||||||||
134 | m_function = function; | - | ||||||||||||||||||
135 | m_function->compilationUnit->addref(); | - | ||||||||||||||||||
136 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
137 | - | |||||||||||||||||||
138 | bool isValid() const | - | ||||||||||||||||||
139 | { return executed 14 times by 1 test: m_function != nullptr;return m_function != nullptr; Executed by:
executed 14 times by 1 test: }return m_function != nullptr; Executed by:
| 14 | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | private: | - | ||||||||||||||||||
142 | Function *m_function; | - | ||||||||||||||||||
143 | }; | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | Profiler(QV4::ExecutionEngine *engine); | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | bool trackAlloc(size_t size, MemoryType type) | - | ||||||||||||||||||
148 | { | - | ||||||||||||||||||
149 | if (size
| 0-152 | ||||||||||||||||||
150 | MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), (qint64)size, type}; | - | ||||||||||||||||||
151 | m_memory_data.append(allocation); | - | ||||||||||||||||||
152 | return executed 152 times by 1 test: true;return true; Executed by:
executed 152 times by 1 test: return true; Executed by:
| 152 | ||||||||||||||||||
153 | } else { | - | ||||||||||||||||||
154 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
155 | } | - | ||||||||||||||||||
156 | } | - | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | bool trackDealloc(size_t size, MemoryType type) | - | ||||||||||||||||||
159 | { | - | ||||||||||||||||||
160 | if (size
| 0 | ||||||||||||||||||
161 | MemoryAllocationProperties allocation = {m_timer.nsecsElapsed(), -(qint64)size, type}; | - | ||||||||||||||||||
162 | m_memory_data.append(allocation); | - | ||||||||||||||||||
163 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||
164 | } else { | - | ||||||||||||||||||
165 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
166 | } | - | ||||||||||||||||||
167 | } | - | ||||||||||||||||||
168 | - | |||||||||||||||||||
169 | quint64 featuresEnabled; | - | ||||||||||||||||||
170 | - | |||||||||||||||||||
171 | void stopProfiling(); | - | ||||||||||||||||||
172 | void startProfiling(quint64 features); | - | ||||||||||||||||||
173 | void reportData(); | - | ||||||||||||||||||
174 | void setTimer(const QElapsedTimer &timer) { m_timer = timer; } executed 32 times by 3 tests: end of block Executed by:
| 32 | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | public : | - | ||||||||||||||||||
177 | void dataReady(const QV4::Profiling::FunctionLocationHash &, | - | ||||||||||||||||||
178 | const QVector<QV4::Profiling::FunctionCallProperties> &, | - | ||||||||||||||||||
179 | const QVector<QV4::Profiling::MemoryAllocationProperties> &); | - | ||||||||||||||||||
180 | - | |||||||||||||||||||
181 | private: | - | ||||||||||||||||||
182 | QV4::ExecutionEngine *m_engine; | - | ||||||||||||||||||
183 | QElapsedTimer m_timer; | - | ||||||||||||||||||
184 | QVector<FunctionCall> m_data; | - | ||||||||||||||||||
185 | QVector<MemoryAllocationProperties> m_memory_data; | - | ||||||||||||||||||
186 | QHash<quintptr, SentMarker> m_sentLocations; | - | ||||||||||||||||||
187 | - | |||||||||||||||||||
188 | friend class FunctionCallProfiler; | - | ||||||||||||||||||
189 | }; | - | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | class FunctionCallProfiler { | - | ||||||||||||||||||
192 | FunctionCallProfiler(const FunctionCallProfiler &) = delete; FunctionCallProfiler &operator=(const FunctionCallProfiler &) = delete; | - | ||||||||||||||||||
193 | public: | - | ||||||||||||||||||
194 | - | |||||||||||||||||||
195 | - | |||||||||||||||||||
196 | - | |||||||||||||||||||
197 | FunctionCallProfiler(ExecutionEngine *engine, Function *f) | - | ||||||||||||||||||
198 | : profiler(nullptr) | - | ||||||||||||||||||
199 | { | - | ||||||||||||||||||
200 | Profiler *p = engine->profiler(); | - | ||||||||||||||||||
201 | if (__builtin_expect(!!(p), false)
| 14-17699042 | ||||||||||||||||||
202 | profiler = p; | - | ||||||||||||||||||
203 | function = f; | - | ||||||||||||||||||
204 | startTime = profiler->m_timer.nsecsElapsed(); | - | ||||||||||||||||||
205 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
206 | } executed 17704945 times by 134 tests: end of block Executed by:
| 17704945 | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | ~FunctionCallProfiler() | - | ||||||||||||||||||
209 | { | - | ||||||||||||||||||
210 | if (profiler
| 14-17678129 | ||||||||||||||||||
211 | profiler->m_data.append(FunctionCall(function, startTime, profiler->m_timer.nsecsElapsed())); executed 14 times by 1 test: profiler->m_data.append(FunctionCall(function, startTime, profiler->m_timer.nsecsElapsed())); Executed by:
| 14 | ||||||||||||||||||
212 | } executed 17696998 times by 134 tests: end of block Executed by:
| 17696998 | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | Profiler *profiler; | - | ||||||||||||||||||
215 | Function *function; | - | ||||||||||||||||||
216 | qint64 startTime; | - | ||||||||||||||||||
217 | }; | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | - | |||||||||||||||||||
220 | } | - | ||||||||||||||||||
221 | } | - | ||||||||||||||||||
222 | - | |||||||||||||||||||
223 | template<> class QTypeInfo<QV4::Profiling::MemoryAllocationProperties > { public: enum { isSpecialized = true, isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QV4::Profiling::MemoryAllocationProperties)>sizeof(void*)), isPointer = false, isIntegral = std::is_integral< QV4::Profiling::MemoryAllocationProperties >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QV4::Profiling::MemoryAllocationProperties) }; static inline const char *name() { return "QV4::Profiling::MemoryAllocationProperties"; } }; | - | ||||||||||||||||||
224 | template<> class QTypeInfo<QV4::Profiling::FunctionCallProperties > { public: enum { isSpecialized = true, isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QV4::Profiling::FunctionCallProperties)>sizeof(void*)), isPointer = false, isIntegral = std::is_integral< QV4::Profiling::FunctionCallProperties >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QV4::Profiling::FunctionCallProperties) }; static inline const char *name() { return "QV4::Profiling::FunctionCallProperties"; } }; | - | ||||||||||||||||||
225 | template<> class QTypeInfo<QV4::Profiling::FunctionCall > { public: enum { isSpecialized = true, isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QV4::Profiling::FunctionCall)>sizeof(void*)), isPointer = false, isIntegral = std::is_integral< QV4::Profiling::FunctionCall >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QV4::Profiling::FunctionCall) }; static inline const char *name() { return "QV4::Profiling::FunctionCall"; } }; | - | ||||||||||||||||||
226 | template<> class QTypeInfo<QV4::Profiling::FunctionLocation > { public: enum { isSpecialized = true, isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QV4::Profiling::FunctionLocation)>sizeof(void*)), isPointer = false, isIntegral = std::is_integral< QV4::Profiling::FunctionLocation >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QV4::Profiling::FunctionLocation) }; static inline const char *name() { return "QV4::Profiling::FunctionLocation"; } }; | - | ||||||||||||||||||
227 | template<> class QTypeInfo<QV4::Profiling::Profiler::SentMarker > { public: enum { isSpecialized = true, isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QV4::Profiling::Profiler::SentMarker)>sizeof(void*)), isPointer = false, isIntegral = std::is_integral< QV4::Profiling::Profiler::SentMarker >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QV4::Profiling::Profiler::SentMarker) }; static inline const char *name() { return "QV4::Profiling::Profiler::SentMarker"; } }; | - | ||||||||||||||||||
228 | - | |||||||||||||||||||
229 | - | |||||||||||||||||||
230 | template <> struct QMetaTypeId< QV4::Profiling::FunctionLocationHash > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { 0 }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< QV4::Profiling::FunctionLocationHash >("QV4::Profiling::FunctionLocationHash", reinterpret_cast< QV4::Profiling::FunctionLocationHash *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; | - | ||||||||||||||||||
231 | template <> struct QMetaTypeId< QVector<QV4::Profiling::FunctionCallProperties> > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { 0 }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< QVector<QV4::Profiling::FunctionCallProperties> >("QVector<QV4::Profiling::FunctionCallProperties>", reinterpret_cast< QVector<QV4::Profiling::FunctionCallProperties> *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; | - | ||||||||||||||||||
232 | template <> struct QMetaTypeId< QVector<QV4::Profiling::MemoryAllocationProperties> > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { 0 }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< QVector<QV4::Profiling::MemoryAllocationProperties> >("QVector<QV4::Profiling::MemoryAllocationProperties>", reinterpret_cast< QVector<QV4::Profiling::MemoryAllocationProperties> *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |