aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscompilerstats.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2025-04-15 13:08:55 +0200
committerOlivier De Cannière <olivier.decanniere@qt.io>2025-04-17 12:10:22 +0200
commit96f4e60ffe43d8d387b2ef0002a421edd5d06239 (patch)
tree1104d6a75302e3254db4ee184c26bbb8aec9070a /src/qmlcompiler/qqmljscompilerstats.cpp
parent4171f5c7388f0f8be168b9aeb78a0bda1586c8f2 (diff)
Compiler: Adapt AotStats to skipping functions
A revision was also added to the aotstats json format. Print a message asking the user to try again with a clean build if a missmatch in revision is found. Task-number: QTBUG-134790 Pick-to: 6.9 6.8 Change-Id: I0961bf841db17f280492ec787f404d9fe9b563f4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljscompilerstats.cpp')
-rw-r--r--src/qmlcompiler/qqmljscompilerstats.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/qmlcompiler/qqmljscompilerstats.cpp b/src/qmlcompiler/qqmljscompilerstats.cpp
index c536854491..24baa1f9fb 100644
--- a/src/qmlcompiler/qqmljscompilerstats.cpp
+++ b/src/qmlcompiler/qqmljscompilerstats.cpp
@@ -80,21 +80,31 @@ std::optional<AotStats> AotStats::aggregateAotstatsList(const QString &aotstatsL
return aggregated;
}
-static constexpr QLatin1StringView S_CODEGEN_SUCCESSFUL{ "codegenSuccessful" };
+static constexpr int S_AOTSTATS_FORMAT_REVISION = 1; // Added support for skipping
+
+static constexpr QLatin1StringView S_CODEGEN_RESULT{ "codegenResult" };
static constexpr QLatin1StringView S_COLUMN{ "column" };
static constexpr QLatin1StringView S_DURATION_MICROSECONDS{ "durationMicroseconds" };
static constexpr QLatin1StringView S_ENTRIES{ "entries" };
-static constexpr QLatin1StringView S_ERROR_MESSAGE{ "errorMessage" };
static constexpr QLatin1StringView S_FILE_PATH{ "filePath" };
+static constexpr QLatin1StringView S_FORMAT_REVISION{ "formatRevision" };
static constexpr QLatin1StringView S_FUNCTION_NAME{ "functionName" };
static constexpr QLatin1StringView S_LINE{ "line" };
+static constexpr QLatin1StringView S_MESSAGE{ "message" };
+static constexpr QLatin1StringView S_MODULES{ "modules" };
static constexpr QLatin1StringView S_MODULE_FILES{ "moduleFiles" };
static constexpr QLatin1StringView S_MODULE_ID{ "moduleId" };
-AotStats AotStats::fromJsonDocument(const QJsonDocument &document)
+std::optional<AotStats> AotStats::fromJsonDocument(const QJsonDocument &document)
{
- QJsonArray modulesArray = document.array();
+ QJsonObject root = document.object();
+ const QJsonValue revision = root[S_FORMAT_REVISION];
+ if (revision.isUndefined() || revision.toInt() != S_AOTSTATS_FORMAT_REVISION) {
+ qDebug() << "AotStats format revision missmatch. Please try again with a clean build.";
+ return std::nullopt;
+ }
+ const QJsonArray modulesArray = root[S_MODULES].toArray();
QQmlJS::AotStats result;
for (const auto &modulesArrayEntry : std::as_const(modulesArray)) {
const auto &moduleObject = modulesArrayEntry.toObject();
@@ -114,10 +124,10 @@ AotStats AotStats::fromJsonDocument(const QJsonDocument &document)
auto micros = statsObject[S_DURATION_MICROSECONDS].toInteger();
stat.codegenDuration = std::chrono::microseconds(micros);
stat.functionName = statsObject[S_FUNCTION_NAME].toString();
- stat.errorMessage = statsObject[S_ERROR_MESSAGE].toString();
+ stat.message = statsObject[S_MESSAGE].toString();
stat.line = statsObject[S_LINE].toInt();
stat.column = statsObject[S_COLUMN].toInt();
- stat.codegenSuccessful = statsObject[S_CODEGEN_SUCCESSFUL].toBool();
+ stat.codegenResult = QQmlJS::CodegenResult(statsObject[S_CODEGEN_RESULT].toInt());
stats.append(std::move(stat));
}
@@ -149,10 +159,12 @@ QJsonDocument AotStats::toJsonDocument() const
auto micros = static_cast<qint64>(stat.codegenDuration.count());
statObject.insert(S_DURATION_MICROSECONDS, micros);
statObject.insert(S_FUNCTION_NAME, stat.functionName);
- statObject.insert(S_ERROR_MESSAGE, stat.errorMessage);
+ statObject.insert(S_MESSAGE, stat.message);
statObject.insert(S_LINE, stat.line);
statObject.insert(S_COLUMN, stat.column);
- statObject.insert(S_CODEGEN_SUCCESSFUL, stat.codegenSuccessful);
+ using CodegenResType = std::underlying_type_t<QQmlJS::CodegenResult>;
+ statObject.insert(S_CODEGEN_RESULT,
+ static_cast<CodegenResType>(stat.codegenResult));
statsArray.append(statObject);
}
@@ -168,7 +180,10 @@ QJsonDocument AotStats::toJsonDocument() const
modulesArray.append(o);
}
- return QJsonDocument(modulesArray);
+ QJsonObject root;
+ root.insert(S_FORMAT_REVISION, S_AOTSTATS_FORMAT_REVISION);
+ root.insert(S_MODULES, modulesArray);
+ return QJsonDocument(root);
}
void AotStats::registerFile(const QString &moduleId, const QString &filepath)