aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-07-20 15:54:53 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-07-31 07:28:52 +0000
commit41076956f7d38d9c661ae97111af9834786efa24 (patch)
treecb196b4b7e628991a021784a41d9e82af3c3222f /src/qml/compiler/qv4compileddata_p.h
parent2ee5331d8ae73c0abde129eb26df4ca000470007 (diff)
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h13
1 files changed, 6 insertions, 7 deletions
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<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 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()); }
@@ -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 {