aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmltypecompiler.cpp
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 /src/qml/compiler/qqmltypecompiler.cpp
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 'src/qml/compiler/qqmltypecompiler.cpp')
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index a6bdf93e2e..15edc010fd 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -133,8 +133,12 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> QQmlTypeCompiler::compile()
return nullptr;
}
- // Compile JS binding expressions and signal handlers
- if (!document->javaScriptCompilationUnit) {
+ if (document->javaScriptCompilationUnit) {
+ // If this file was loaded from an ahead-of-time built cache file, then set up the original
+ // unit data as backing unit and fetch strings from there to save memory.
+ document->javaScriptCompilationUnit->backingUnit = document->javaScriptCompilationUnit->unitData();
+ } else {
+ // Compile JS binding expressions and signal handlers if necessary
{
// We can compile script strings ahead of time, but they must be compiled
// without type optimizations as their scope is always entirely dynamic.