diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-20 11:57:38 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-30 19:46:51 +0000 |
commit | 7c1c016ced09c62ce0d857aef5ea734b7c35f394 (patch) | |
tree | 756826d7c714e8686d7fe77d54985b0bd762b5d9 /src/qml/compiler/qv4compileddata_p.h | |
parent | d08f437e3fb0bc6a2c9c1b63f955c223851ff6d8 (diff) |
Shrink the size of CompiledData::Function by 16 bytes
It was previously 68 bytes but rounded up to 72 to be multiple of 8.
After removing the rarely used qml offset table properties and
calculating them on the fly instead, the data structure shrinks to 56
bytes.
Saves 2.8K on examples/quickcontrols/extras/flat/Content.qml and about
~22K RAM on the gallery.
Task-number: QTBUG-69588
Change-Id: I13d1efae7fa1dff96674d937ffbad002c2f703c8
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.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 6a1014399b..a556ccb0c0 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -271,12 +271,15 @@ struct Function Location location; // Qml Extensions Begin - quint32_le dependingIdObjectsOffset; // Array of resolved ID objects + // Array of resolved ID objects + size_t dependingIdObjectsOffset() const { return lineNumberOffset + nLineNumbers * sizeof(CodeOffsetToLine); } quint16_le nDependingIdObjects; quint16_le nDependingContextProperties; - quint32_le dependingContextPropertiesOffset; // Array of int pairs (property index and notify index) - quint32_le nDependingScopeProperties; - quint32_le dependingScopePropertiesOffset; // Array of int pairs (property index and notify index) + // Array of int pairs (property index and notify index) + size_t dependingContextPropertiesOffset() const { return dependingIdObjectsOffset() + nDependingIdObjects * sizeof(quint32); } + quint16_le nDependingScopeProperties; + // Array of int pairs (property index and notify index) + size_t dependingScopePropertiesOffset() const { return dependingContextPropertiesOffset() + nDependingContextProperties * sizeof(quint32); } // Qml Extensions End // Keep all unaligned data at the end @@ -290,9 +293,9 @@ struct Function const quint32_le *formalsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + formalsOffset); } const quint32_le *localsTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + localsOffset); } const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast<const CodeOffsetToLine *>(reinterpret_cast<const char *>(this) + lineNumberOffset); } - const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset); } - const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset); } - const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset); } + const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingIdObjectsOffset()); } + const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset()); } + const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset()); } // --- QQmlPropertyCacheCreator interface const quint32_le *formalsBegin() const { return formalsTable(); } @@ -315,7 +318,7 @@ struct Function return (a + 7) & ~size_t(7); } }; -static_assert(sizeof(Function) == 68, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); +static_assert(sizeof(Function) == 56, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Method { enum Type { |