From 1ab5d14615f713a87141b66675521d702542d3a6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Jan 2018 09:40:52 +0100 Subject: Minor data structure cleanup The cache files are architecture and ABI independent, so we can remove any associated field/code as well as the workaround for Android. Change-Id: Ia52a5be886fc22a2105460e003e7a76af7dc1818 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata.cpp | 18 --------------- src/qml/compiler/qv4compileddata_p.h | 6 ++--- src/qml/compiler/qv4compiler.cpp | 2 -- src/qml/compiler/qv4compilercontext_p.h | 1 - tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 2 +- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 24 -------------------- tools/qmlcachegen/qmlcache.prf | 15 +----------- tools/qmlcachegen/qmlcachegen.cpp | 29 ++++-------------------- 8 files changed, 8 insertions(+), 89 deletions(-) diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index e98cb32250..889e755682 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -354,24 +354,6 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeS return false; } - { - const QString foundArchitecture = stringAt(data->architectureIndex); - const QString expectedArchitecture = QSysInfo::buildAbi(); - if (foundArchitecture != expectedArchitecture) { - *errorString = QString::fromUtf8("Architecture mismatch. Found %1 expected %2").arg(foundArchitecture).arg(expectedArchitecture); - return false; - } - } - - { - const QString foundCodeGenerator = stringAt(data->codeGeneratorIndex); - const QString expectedCodeGenerator = QStringLiteral("moth"); // ### - if (foundCodeGenerator != expectedCodeGenerator) { - *errorString = QString::fromUtf8("Code generator mismatch. Found code generated by %1 but expected %2").arg(foundCodeGenerator).arg(expectedCodeGenerator); - return false; - } - } - dataPtrChange.commit(); free(const_cast(oldDataPtr)); backingFile.reset(cacheFile.take()); diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index bf3901a501..faa2d9bcb4 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE // Bump this whenever the compiler data structures change in an incompatible way. -#define QV4_DATA_STRUCTURE_VERSION 0x15 +#define QV4_DATA_STRUCTURE_VERSION 0x16 class QIODevice; class QQmlPropertyCache; @@ -691,8 +691,6 @@ struct Unit char md5Checksum[16]; // checksum of all bytes following this field. void generateChecksum(); - quint32_le architectureIndex; // string index to QSysInfo::buildAbi() - quint32_le codeGeneratorIndex; char dependencyMD5Checksum[16]; enum : unsigned int { @@ -790,7 +788,7 @@ struct Unit } }; -static_assert(sizeof(Unit) == 144, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); +static_assert(sizeof(Unit) == 136, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct TypeReference { diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 96c9307513..3be34720fa 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -394,8 +394,6 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp unit.version = QV4_DATA_STRUCTURE_VERSION; unit.qtVersion = QT_VERSION; memset(unit.md5Checksum, 0, sizeof(unit.md5Checksum)); - unit.architectureIndex = registerString(module->targetABI.isEmpty() ? QSysInfo::buildAbi() : module->targetABI); - unit.codeGeneratorIndex = registerString(codeGeneratorName); memset(unit.dependencyMD5Checksum, 0, sizeof(unit.dependencyMD5Checksum)); quint32 nextOffset = sizeof(CompiledData::Unit); diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h index 3db30ea23d..52a4bb9159 100644 --- a/src/qml/compiler/qv4compilercontext_p.h +++ b/src/qml/compiler/qv4compilercontext_p.h @@ -95,7 +95,6 @@ struct Module { QDateTime sourceTimeStamp; uint unitFlags = 0; // flags merged into CompiledData::Unit::flags bool debugMode = false; - QString targetABI; // ### seems unused currently }; diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index fb1072e67f..b20af06746 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -76,7 +76,7 @@ static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr if (capturedStderr == nullptr) proc.setProcessChannelMode(QProcess::ForwardedChannels); proc.setProgram(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator() + QLatin1String("qmlcachegen")); - proc.setArguments(QStringList() << (QLatin1String("--target-architecture=") + QSysInfo::buildCpuArchitecture()) << (QLatin1String("--target-abi=") + QSysInfo::buildAbi()) << qmlFileName); + proc.setArguments(QStringList() << qmlFileName); proc.start(); if (!proc.waitForFinished()) return false; diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index cdc9f29aab..f5905758f3 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -344,30 +344,6 @@ void tst_qmldiskcache::basicVersionChecks() QVERIFY(!testCompiler.verify()); QCOMPARE(testCompiler.lastErrorString, QString::fromUtf8("V4 data structure version mismatch. Found 0 expected %1").arg(QV4_DATA_STRUCTURE_VERSION, 0, 16)); } - - { - testCompiler.clearCache(); - QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString)); - - testCompiler.tweakHeader([](QV4::CompiledData::Unit *header) { - header->architectureIndex = 0; - }); - - QVERIFY(!testCompiler.verify()); - QCOMPARE(testCompiler.lastErrorString, QString::fromUtf8("Architecture mismatch. Found expected %1").arg(QSysInfo::buildAbi())); - } - - { - testCompiler.clearCache(); - QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString)); - - testCompiler.tweakHeader([](QV4::CompiledData::Unit *header) { - header->codeGeneratorIndex = 0; - }); - - QVERIFY(!testCompiler.verify()); - QCOMPARE(testCompiler.lastErrorString, QString::fromUtf8("Code generator mismatch. Found code generated by but expected %1").arg(QStringLiteral("moth"))); - } } class TypeVersion1 : public QObject diff --git a/tools/qmlcachegen/qmlcache.prf b/tools/qmlcachegen/qmlcache.prf index dfb06cb760..537eaf62ea 100644 --- a/tools/qmlcachegen/qmlcache.prf +++ b/tools/qmlcachegen/qmlcache.prf @@ -3,23 +3,10 @@ static { return() } -android { - message("QML cache generation ahead of time is not supported on Android") - return() -} - qtPrepareTool(QML_CACHEGEN, qmlcachegen, _ARCH_CHECK) isEmpty(TARGETPATH): error("Must set TARGETPATH (QML import name) for ahead-of-time QML cache generation") -!isEmpty(QT_TARGET_ARCH):QML_CACHEGEN_ARCH=$$QT_TARGET_ARCH -else:QML_CACHEGEN_ARCH=$$QT_ARCH - -!isEmpty(QT_TARGET_BUILDABI):QML_CACHEGEN_ABI=$$QT_TARGET_BUILDABI -else:QML_CACHEGEN_ABI=$$QT_BUILDABI - -QML_CACHEGEN_ARGS=--target-architecture=$$QML_CACHEGEN_ARCH --target-abi=$$QML_CACHEGEN_ABI - load(qt_build_paths) prefix_build: QMLCACHE_DESTDIR = $$MODULE_BASE_OUTDIR/qml/$$TARGETPATH @@ -45,7 +32,7 @@ qmlcacheinst.CONFIG = no_check_exist qmlcachegen.input = CACHEGEN_FILES qmlcachegen.output = ${QMAKE_FUNC_FILE_IN_qmlCacheOutputFileName} qmlcachegen.CONFIG = no_link target_predeps -qmlcachegen.commands = $$QML_CACHEGEN $$QML_CACHEGEN_ARGS -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} +qmlcachegen.commands = $$QML_CACHEGEN -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} qmlcachegen.name = Generate QML Cache ${QMAKE_FILE_IN} qmlcachegen.variable_out = GENERATED_FILES diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index 807a213f14..18f8f79ba3 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -135,10 +135,9 @@ static bool checkArgumentsObjectUseInSignalHandlers(const QmlIR::Document &doc, return true; } -static bool compileQmlFile(const QString &inputFileName, const QString &outputFileName, const QString &targetABI, Error *error) +static bool compileQmlFile(const QString &inputFileName, const QString &outputFileName, Error *error) { QmlIR::Document irDocument(/*debugMode*/false); - irDocument.jsModule.targetABI = targetABI; QString sourceCode; { @@ -218,10 +217,9 @@ static bool compileQmlFile(const QString &inputFileName, const QString &outputFi return true; } -static bool compileJSFile(const QString &inputFileName, const QString &outputFileName, const QString &targetABI, Error *error) +static bool compileJSFile(const QString &inputFileName, const QString &outputFileName, Error *error) { QmlIR::Document irDocument(/*debugMode*/false); - irDocument.jsModule.targetABI = targetABI; QString sourceCode; { @@ -322,12 +320,6 @@ int main(int argc, char **argv) parser.addHelpOption(); parser.addVersionOption(); - QCommandLineOption targetArchitectureOption(QStringLiteral("target-architecture"), QCoreApplication::translate("main", "Target architecture"), QCoreApplication::translate("main", "architecture")); - parser.addOption(targetArchitectureOption); - - QCommandLineOption targetABIOption(QStringLiteral("target-abi"), QCoreApplication::translate("main", "Target architecture binary interface"), QCoreApplication::translate("main", "abi")); - parser.addOption(targetABIOption); - QCommandLineOption outputFileOption(QStringLiteral("o"), QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "file name")); parser.addOption(outputFileOption); @@ -339,17 +331,6 @@ int main(int argc, char **argv) parser.process(app); - if (!parser.isSet(targetArchitectureOption)) { - fprintf(stderr, "Target architecture not specified. Please specify with --target-architecture=\n"); - parser.showHelp(); - return EXIT_FAILURE; - } - - // Since we're now storing bytecode in the cache, the --check-if-supported option - // doesn't make sense anymore. Return EXIT_SUCCESS for backwards compatibility. - if (parser.isSet(checkIfSupportedOption)) - return EXIT_SUCCESS; - const QStringList sources = parser.positionalArguments(); if (sources.isEmpty()){ parser.showHelp(); @@ -365,15 +346,13 @@ int main(int argc, char **argv) if (parser.isSet(outputFileOption)) outputFileName = parser.value(outputFileOption); - const QString targetABI = parser.value(targetABIOption); - if (inputFile.endsWith(QLatin1String(".qml"))) { - if (!compileQmlFile(inputFile, outputFileName, targetABI, &error)) { + if (!compileQmlFile(inputFile, outputFileName, &error)) { error.augment(QLatin1String("Error compiling qml file: ")).print(); return EXIT_FAILURE; } } else if (inputFile.endsWith(QLatin1String(".js"))) { - if (!compileJSFile(inputFile, outputFileName, targetABI, &error)) { + if (!compileJSFile(inputFile, outputFileName, &error)) { error.augment(QLatin1String("Error compiling qml file: ")).print(); return EXIT_FAILURE; } -- cgit v1.2.3