Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljscompilerstats.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant
4
6
7#include <QFile>
8#include <QJsonArray>
9#include <QJsonDocument>
10#include <QJsonObject>
11#include <QTextStream>
12
14
15namespace QQmlJS {
16
17using namespace Qt::StringLiterals;
18
22
24{
25 if (line == other.line)
26 return column < other.column;
27 return line < other.line;
28}
29
31{
32 for (const auto &[moduleUri, moduleStats] : other.m_entries.asKeyValueRange()) {
34 }
35}
36
52
63
65{
68 return std::nullopt;
69
71 if (aotstatsFiles->empty())
72 return aggregated;
73
74 for (const auto &aotstatsFile : aotstatsFiles.value()) {
76 if (!parsed.has_value())
77 return std::nullopt;
79 }
80
81 return aggregated;
82}
83
84static constexpr int S_AOTSTATS_FORMAT_REVISION = 1; // Added support for skipping
85
86static constexpr QLatin1StringView S_CODEGEN_RESULT{ "codegenResult" };
87static constexpr QLatin1StringView S_COLUMN{ "column" };
88static constexpr QLatin1StringView S_DURATION_MICROSECONDS{ "durationMicroseconds" };
89static constexpr QLatin1StringView S_ENTRIES{ "entries" };
90static constexpr QLatin1StringView S_FILE_PATH{ "filePath" };
91static constexpr QLatin1StringView S_FORMAT_REVISION{ "formatRevision" };
92static constexpr QLatin1StringView S_FUNCTION_NAME{ "functionName" };
93static constexpr QLatin1StringView S_LINE{ "line" };
94static constexpr QLatin1StringView S_MESSAGE{ "message" };
95static constexpr QLatin1StringView S_MODULES{ "modules" };
96static constexpr QLatin1StringView S_MODULE_FILES{ "moduleFiles" };
97static constexpr QLatin1StringView S_MODULE_ID{ "moduleId" };
98
100{
104 qDebug() << "AotStats format revision missmatch. Please try again with a clean build.";
105 return std::nullopt;
106 }
107
110 for (const auto &modulesArrayEntry : std::as_const(modulesArray)) {
114
116 for (const auto &filesArrayEntry : filesArray) {
120
122 for (const auto &statsArrayEntry : statsArray) {
123 const auto &statsObject = statsArrayEntry.toObject();
133 }
134
135 std::sort(stats.begin(), stats.end());
137 }
138
140 }
141
142 return result;
143}
144
146{
148 for (auto it1 = m_entries.begin(); it1 != m_entries.end(); ++it1) {
149 const QString moduleId = it1.key();
151
153 for (auto it2 = files.begin(); it2 != files.end(); ++it2) {
154 const QString &filename = it2.key();
155 const QList<AotStatsEntry> &stats = it2.value();
156
158 for (const auto &stat : stats) {
160 auto micros = static_cast<qint64>(stat.codegenDuration.count());
168 static_cast<CodegenResType>(stat.codegenResult));
170 }
171
176 }
177
182 }
183
187 return QJsonDocument(root);
188}
189
191{
193}
194
200
202{
205 qDebug().noquote() << u"Could not open \"%1\""_s.arg(filepath);
206 return false;
207 }
208
210 return true;
211}
212
217
222
223} // namespace QQmlJS
224
225QT_END_NAMESPACE
static constexpr QLatin1StringView S_LINE
static constexpr QLatin1StringView S_FORMAT_REVISION
static constexpr QLatin1StringView S_ENTRIES
static constexpr QLatin1StringView S_COLUMN
static constexpr QLatin1StringView S_MESSAGE
static constexpr QLatin1StringView S_CODEGEN_RESULT
static constexpr int S_AOTSTATS_FORMAT_REVISION
static constexpr QLatin1StringView S_MODULES
static constexpr QLatin1StringView S_FILE_PATH
static constexpr QLatin1StringView S_DURATION_MICROSECONDS
static constexpr QLatin1StringView S_MODULE_FILES
static constexpr QLatin1StringView S_MODULE_ID
static constexpr QLatin1StringView S_FUNCTION_NAME