aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-07-20 15:41:29 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-07-31 07:28:47 +0000
commit2ee5331d8ae73c0abde129eb26df4ca000470007 (patch)
tree748ef5bdf37fce8c5d8acdc448ddb7ac430f11dd /src/qml/compiler/qv4compileddata_p.h
parentfcf9b7efa5b2a0d8f49e59b2a977b8122632aff6 (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/qv4compileddata_p.h')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 7bbc4d2835..20e8db528e 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -362,11 +362,14 @@ static_assert(sizeof(Class) == 24, "Class structure needs to have the expected s
// Qml data structures
-struct Q_QML_EXPORT TranslationData {
+struct Q_QML_EXPORT TranslationData
+{
+ quint32_le stringIndex;
quint32_le commentIndex;
qint32_le number;
+ quint32_le padding;
};
-static_assert(sizeof(TranslationData) == 8, "TranslationData 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(TranslationData) == 16, "TranslationData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Q_QML_PRIVATE_EXPORT Binding
{
@@ -407,15 +410,13 @@ struct Q_QML_PRIVATE_EXPORT Binding
quint32_le constantValueIndex;
quint32_le compiledScriptIndex; // used when Type_Script
quint32_le objectIndex;
- TranslationData translationData; // used when Type_Translation
+ quint32_le translationDataIndex; // used when Type_Translation
} value;
- quint32_le stringIndex; // Set for Type_String, Type_Translation and Type_Script (the latter because of script strings)
+ quint32_le stringIndex; // Set for Type_String and Type_Script (the latter because of script strings)
Location location;
Location valueLocation;
- quint32_le padding;
-
bool isValueBinding() const
{
if (type == Type_AttachedProperty
@@ -490,7 +491,7 @@ struct Q_QML_PRIVATE_EXPORT Binding
};
-static_assert(sizeof(Binding) == 32, "Binding 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(Binding) == 24, "Binding structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct EnumValue
{
@@ -799,6 +800,8 @@ struct Unit
quint32_le offsetToConstantTable;
quint32_le jsClassTableSize;
quint32_le offsetToJSClassTable;
+ quint32_le translationTableSize;
+ quint32_le offsetToTranslationTable;
qint32_le indexOfRootFunction;
quint32_le sourceFileIndex;
quint32_le finalUrlIndex;
@@ -889,9 +892,13 @@ struct Unit
*nMembers = klass->nMembers;
return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass));
}
+
+ const TranslationData *translations() const {
+ return reinterpret_cast<const TranslationData *>(reinterpret_cast<const char *>(this) + offsetToTranslationTable);
+ }
};
-static_assert(sizeof(Unit) == 208, "Unit 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(Unit) == 216, "Unit structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct TypeReference
{