aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcachegen
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-07-23 14:08:06 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-07-31 17:08:08 +0000
commit8237f645a33199e0a8aded0a3f7e6077990707fd (patch)
tree2011793b9c3775f307cd5e2560143017ddb57719 /tests/auto/qml/qmlcachegen
parent9337b1c339c34cd4fe10d236be2ee61ca76e17ba (diff)
Optimize memory consumption of ahead-of-time compile cache files
When loading a pre-compiled cache file, the strings contained therein will remain available in memory since commit 7dcada48d2435e8ceb0cc8a6771f79b76979e11f. While for aot built cache files we may have to add new strings (for example for signal handler parameters), we can re-use the existing strings by omitting them from the intermediately created string table. This saves ~283K RAM with qtquickcontrols1 gallery. Task-number: QTBUG-69588 Change-Id: I8ea807f6dea4cc35d8b7e5f7329809ed1cd12880 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcachegen')
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index fab33a4175..71e661e507 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -266,6 +266,16 @@ void tst_qmlcachegen::signalHandlerParameters()
// (offsetToImports) should be the same _plus_ one entry in the newly added formals table.
const quint32 sizeOfNewFormalsTable = 1 * sizeof(quint32);
QCOMPARE(quint32(compilationUnit->unitData()->offsetToImports), oldImportsOffset + sizeOfNewFormalsTable);
+
+ // 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;
+ };
+
+ QVERIFY(isStringIndexInOriginalStringTable(compilationUnit->objectAt(0)->signalAt(0)->parameterAt(0)->nameIndex));
+ QVERIFY(!isStringIndexInOriginalStringTable(compilationUnit->unitData()->sourceFileIndex));
}
}