diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-20 15:41:29 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-31 07:28:47 +0000 |
commit | 2ee5331d8ae73c0abde129eb26df4ca000470007 (patch) | |
tree | 748ef5bdf37fce8c5d8acdc448ddb7ac430f11dd /src/qml/compiler/qv4compiler.cpp | |
parent | fcf9b7efa5b2a0d8f49e59b2a977b8122632aff6 (diff) |
Shrink CompiledData::Binding by 8 bytes
Move the translation data out into a separately indexed table, which
allows to shrunk the value union down to 4 bytes, together with the
previous commit.
Saves ~4k with examples/quickcontrols/extras/flat/Content.qml and ~37K
RAM with the gallery.
Task-number: QTBUG-69588
Change-Id: Ia5016b072320ebb6b8fcfbb4dad128d53c901c74
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index a2afc7fefe..252056b2b6 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -208,6 +208,12 @@ int QV4::Compiler::JSUnitGenerator::registerJSClass(const QStringList &members) return jsClassOffsets.size() - 1; } +int QV4::Compiler::JSUnitGenerator::registerTranslation(const QV4::CompiledData::TranslationData &translation) +{ + translations.append(translation); + return translations.size() - 1; +} + QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorOption option) { registerString(module->fileName); @@ -286,6 +292,8 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO jsClassOffsetTable[i] = jsClassDataOffset + jsClassOffsets.at(i); } + memcpy(dataPtr + unit->offsetToTranslationTable, translations.constData(), translations.count() * sizeof(CompiledData::TranslationData)); + // write strings and string table if (option == GenerateWithStringTable) stringTable.serialize(unit); @@ -521,6 +529,12 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp nextOffset = (nextOffset + 7) & ~quint32(0x7); + unit.translationTableSize = translations.count(); + unit.offsetToTranslationTable = nextOffset; + nextOffset += unit.translationTableSize * sizeof(CompiledData::TranslationData); + + nextOffset = (nextOffset + 7) & ~quint32(0x7); + quint32 functionSize = 0; for (int i = 0; i < module->functions.size(); ++i) { @@ -575,6 +589,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp if (showStats) { qDebug() << "Generated JS unit that is" << unit.unitSize << "bytes contains:"; qDebug() << " " << functionSize << "bytes for non-code function data for" << unit.functionTableSize << "functions"; + qDebug() << " " << translations.count() * sizeof(CompiledData::TranslationData) << "bytes for" << translations.count() << "translations"; } return unit; |