diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-14 16:19:04 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-15 08:58:15 +0000 |
commit | cf23466f0aa370790bec05bc7764176c194fe5bb (patch) | |
tree | 98647e3a120c34af9cef3fb46fe0503fca593dd6 /src/qml/compiler/qv4compileddata_p.h | |
parent | c586fc4be2428db57ba8579f8280d09893ba796d (diff) |
Simplify CompiledData::Unit serialization
There are currently two places where we calculate the total size of a
CompiledData::Unit including all of its data, once in its calculateSize()
function and then when constructing the Unit itself. This is error prone when
trying to do changes to the layout, as two places need to be adjusted. Instead
we can centralize the populating of the entire CompiledData::Unit header, the
calculation of the various offsets as well as the entire size in one shot in a
new generateHeader function. Afterwards we can allocate the final amount of
memory and copy the remaining bytes across and assemble the final data
structure.
Change-Id: Ic26d7812e59d2bee2f45cd72742e3195a56950df
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 | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index b6c0e6e704..a1d0a6d732 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -146,8 +146,6 @@ struct RegExp QJsonPrivate::qle_bitfield<0, 4> flags; QJsonPrivate::qle_bitfield<4, 28> stringIndex; }; - - static int calculateSize() { return sizeof(RegExp); } }; struct Lookup @@ -166,8 +164,6 @@ struct Lookup }; Lookup() { type_and_flags = 0; nameIndex = 0; } - - static int calculateSize() { return sizeof(Lookup); } }; struct JSClassMember @@ -687,15 +683,6 @@ struct Unit *nMembers = klass->nMembers; return reinterpret_cast<const JSClassMember*>(ptr + sizeof(JSClass)); } - - static int calculateSize(uint nFunctions, uint nRegExps, uint nConstants, - uint nLookups, uint nClasses) { - return (sizeof(Unit) - + (nFunctions + nClasses) * sizeof(uint) - + nRegExps * RegExp::calculateSize() - + nConstants * sizeof(QV4::ReturnedValue) - + nLookups * Lookup::calculateSize() - + 7) & ~7; } }; #if defined(Q_CC_MSVC) || defined(Q_CC_GNU) |