aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata_p.h
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/qv4compileddata_p.h
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/qv4compileddata_p.h')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index b3edf1c701..bf83c45384 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -831,6 +831,7 @@ struct Unit
/* end QML specific fields*/
QString stringAtInternal(int idx) const {
+ Q_ASSERT(idx < int(stringTableSize));
const quint32_le *offsetTable = reinterpret_cast<const quint32_le*>((reinterpret_cast<const char *>(this)) + offsetToStringTable);
const quint32_le offset = offsetTable[idx];
const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset);
@@ -1083,12 +1084,22 @@ public:
bool isRegisteredWithEngine = false;
QScopedPointer<CompilationUnitMapper> backingFile;
+ const QV4::CompiledData::Unit *backingUnit = nullptr;
// --- interface for QQmlPropertyCacheCreator
typedef Object CompiledObject;
int objectCount() const { return data->nObjects; }
const Object *objectAt(int index) const { return data->objectAt(index); }
- QString stringAt(int index) const { return data->stringAtInternal(index); }
+ QString stringAt(int index) const
+ {
+ if (backingUnit) {
+ const qint32 backingUnitStringTableSize = backingUnit->stringTableSize;
+ if (index < backingUnitStringTableSize)
+ return backingUnit->stringAtInternal(index);
+ index -= backingUnitStringTableSize;
+ }
+ return data->stringAtInternal(index);
+ }
struct FunctionIterator
{
@@ -1117,6 +1128,10 @@ public:
protected:
void linkBackendToEngine(QV4::ExecutionEngine *engine);
+
+ quint32 totalStringCount() const
+ { return data->stringTableSize + (backingUnit ? backingUnit->stringTableSize : 0); }
+
#endif // V4_BOOTSTRAP
private: