diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-27 11:47:53 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-01 09:42:06 +0000 |
commit | e99038b24d8b9f4a8cc503d1e3f789a93a3e8330 (patch) | |
tree | 05a43cf4833f5eba65f54e7fbb61fa49575ba14d /tests/auto/qml/qmlcachegen | |
parent | 73fc89bb0dbe9a866e7b1cf47a42a85e5042fead (diff) |
Reduce memory consumption when loading AOT generated cache files
Separate the qml data (objects/imports) from the general compilation
unit data. It's only the former that needs to be re-generated as part of
the type re-compilation and by separating it we can allocate memory just
for that and keep using the mmap'ed general unit data for everything
else (including byte code).
Another upside of this change is that it allows eliminating the recently
introduced concept of a backing unit again.
Saves ~149K RAM with the QQC1 gallery.
Task-number: QTBUG-69588
Change-Id: Ie88a4286feb7e2f472f58a28fa5dd6ff0a91c4b6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcachegen')
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 41315fd5f0..17c12b87e8 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -165,7 +165,7 @@ void tst_qmlcachegen::loadGeneratedFile() QVERIFY(compilationUnit); auto unitData = compilationUnit->unitData(); QVERIFY(unitData); - QVERIFY(!(unitData->flags & QV4::CompiledData::Unit::StaticData)); + QVERIFY(unitData->flags & QV4::CompiledData::Unit::StaticData); } void tst_qmlcachegen::translationExpressionSupport() @@ -236,13 +236,11 @@ void tst_qmlcachegen::signalHandlerParameters() QVERIFY(QFile::exists(cacheFilePath)); QVERIFY(QFile::remove(testFilePath)); - quint32 oldImportsOffset = 0; { QFile cache(cacheFilePath); QVERIFY(cache.open(QIODevice::ReadOnly)); const QV4::CompiledData::Unit *cacheUnit = reinterpret_cast<const QV4::CompiledData::Unit *>(cache.map(/*offset*/0, sizeof(QV4::CompiledData::Unit))); QVERIFY(cacheUnit); - oldImportsOffset = cacheUnit->offsetToImports; } QQmlEngine engine; @@ -259,19 +257,18 @@ void tst_qmlcachegen::signalHandlerParameters() QVERIFY(compilationUnit); QVERIFY(compilationUnit->unitData()); - // Verify that the JS unit is used unchanged, no tables were added, by checking the - // offset of the first QML specific table. - QCOMPARE(quint32(compilationUnit->unitData()->offsetToImports), oldImportsOffset); + // Verify that the QML objects don't come from the original data. + QVERIFY(compilationUnit->objectAt(0) != compilationUnit->unitData()->qmlUnit()->objectAt(0)); // Typically the final file name is one of those strings that is not in the original // pre-compiled qml file's string table, while for example the signal parameter // name ("value") is. - const auto isStringIndexInOriginalStringTable = [compilationUnit](uint index) { - return index < compilationUnit->backingUnit->stringTableSize; + const auto isStringIndexInStringTable = [compilationUnit](uint index) { + return index < compilationUnit->unitData()->stringTableSize; }; - QVERIFY(isStringIndexInOriginalStringTable(compilationUnit->objectAt(0)->signalAt(0)->parameterAt(0)->nameIndex)); - QVERIFY(!isStringIndexInOriginalStringTable(compilationUnit->unitData()->sourceFileIndex)); + QVERIFY(isStringIndexInStringTable(compilationUnit->objectAt(0)->signalAt(0)->parameterAt(0)->nameIndex)); + QVERIFY(!compilationUnit->dynamicStrings.isEmpty()); } } |