diff options
| author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-23 14:08:06 +0200 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-31 17:08:08 +0000 |
| commit | 8237f645a33199e0a8aded0a3f7e6077990707fd (patch) | |
| tree | 2011793b9c3775f307cd5e2560143017ddb57719 /src/qml/compiler/qv4compileddata.cpp | |
| parent | 9337b1c339c34cd4fe10d236be2ee61ca76e17ba (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/qv4compileddata.cpp')
| -rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 84abd081cf..32d17a709d 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -126,10 +126,11 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) Q_ASSERT(!runtimeStrings); Q_ASSERT(data); - runtimeStrings = (QV4::Heap::String **)malloc(data->stringTableSize * sizeof(QV4::Heap::String*)); + const quint32 stringCount = totalStringCount(); + runtimeStrings = (QV4::Heap::String **)malloc(stringCount * sizeof(QV4::Heap::String*)); // memset the strings to 0 in case a GC run happens while we're within the loop below - memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*)); - for (uint i = 0; i < data->stringTableSize; ++i) + memset(runtimeStrings, 0, stringCount * sizeof(QV4::Heap::String*)); + for (uint i = 0; i < stringCount; ++i) runtimeStrings[i] = engine->newString(stringAt(i)); runtimeRegularExpressions = new QV4::Value[data->regexpTableSize]; @@ -187,7 +188,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) qDebug() << "=== Constant table"; Moth::dumpConstantTable(constants, data->constantTableSize); qDebug() << "=== String table"; - for (uint i = 0; i < data->stringTableSize; ++i) + for (uint i = 0, end = totalStringCount(); i < end; ++i) qDebug() << " " << i << ":" << runtimeStrings[i]->toQString(); qDebug() << "=== Closure table"; for (uint i = 0; i < data->functionTableSize; ++i) @@ -240,7 +241,7 @@ void CompilationUnit::unlink() void CompilationUnit::markObjects(QV4::MarkStack *markStack) { if (runtimeStrings) { - for (uint i = 0; i < data->stringTableSize; ++i) + for (uint i = 0, end = totalStringCount(); i < end; ++i) if (runtimeStrings[i]) runtimeStrings[i]->mark(markStack); } |
