From 41076956f7d38d9c661ae97111af9834786efa24 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 20 Jul 2018 15:54:53 +0200 Subject: Shrink CompiledData::Function by 8 bytes We can express the offset to the line number table relative to the locals. Saves ~1.4k with examples/quickcontrols/extras/flat/Content.qml and ~11K RAM with the gallery. Task-number: QTBUG-69588 Change-Id: I802928102b4291e05ff1462226d22303f8a6d35b Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata_p.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/qml/compiler/qv4compileddata_p.h') diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 20e8db528e..715882c985 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -263,18 +263,17 @@ struct Function quint32_le nameIndex; quint16_le length; quint16_le nFormals; - quint32_le formalsOffset; + quint32_le formalsOffset; // Can't turn this into a calculated offset because of the mutation in CompilationUnit::createUnitData. quint32_le localsOffset; quint16_le nLocals; quint16_le nLineNumbers; - quint32_le lineNumberOffset; + size_t lineNumberOffset() const { return localsOffset + nLocals * sizeof(quint32); } quint32_le nestedFunctionIndex; // for functions that only return a single closure, used in signal handlers - quint32_le nRegisters; Location location; // Qml Extensions Begin // Array of resolved ID objects - size_t dependingIdObjectsOffset() const { return lineNumberOffset + nLineNumbers * sizeof(CodeOffsetToLine); } + size_t dependingIdObjectsOffset() const { return lineNumberOffset() + nLineNumbers * sizeof(CodeOffsetToLine); } quint16_le nDependingIdObjects; quint16_le nDependingContextProperties; // Array of int pairs (property index and notify index) @@ -287,14 +286,14 @@ struct Function // Keep all unaligned data at the end quint8 flags; quint8 padding1; - quint16_le padding2; + quint16_le nRegisters; // quint32 formalsIndex[nFormals] // quint32 localsIndex[nLocals] const quint32_le *formalsTable() const { return reinterpret_cast(reinterpret_cast(this) + formalsOffset); } const quint32_le *localsTable() const { return reinterpret_cast(reinterpret_cast(this) + localsOffset); } - const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast(reinterpret_cast(this) + lineNumberOffset); } + const CodeOffsetToLine *lineNumberTable() const { return reinterpret_cast(reinterpret_cast(this) + lineNumberOffset()); } const quint32_le *qmlIdObjectDependencyTable() const { return reinterpret_cast(reinterpret_cast(this) + dependingIdObjectsOffset()); } const quint32_le *qmlContextPropertiesDependencyTable() const { return reinterpret_cast(reinterpret_cast(this) + dependingContextPropertiesOffset()); } const quint32_le *qmlScopePropertiesDependencyTable() const { return reinterpret_cast(reinterpret_cast(this) + dependingScopePropertiesOffset()); } @@ -320,7 +319,7 @@ struct Function return (a + 7) & ~size_t(7); } }; -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"); +static_assert(sizeof(Function) == 48, "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 { -- cgit v1.2.3