diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-07-04 14:43:10 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-07-05 16:31:45 +0200 |
commit | e203418096e66f2173d05788e5cb18e79141e772 (patch) | |
tree | a686a081985b9c120d83f6399af8b65fc7669aaa /src/qml/compiler/qv4compileddata_p.h | |
parent | 2024df6604dbb78f5eee6f61e73fb0d2fc3bb008 (diff) |
Reduce the size of Property fields in type compilation data
We can shave off 4 bytes of each property declaration by sharing the
bits for the custom type name index or the builtin type enum.
Change-Id: I77071cbef66c5a83b3e7e281dba3a435d3c68b39
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 9123f9f0ec..639595509a 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -642,18 +642,35 @@ struct Property { enum Type : unsigned int { Var = 0, Variant, Int, Bool, Real, String, Url, Color, Font, Time, Date, DateTime, Rect, Point, Size, - Vector2D, Vector3D, Vector4D, Matrix4x4, Quaternion, - Custom, CustomList }; + Vector2D, Vector3D, Vector4D, Matrix4x4, Quaternion, InvalidBuiltin }; quint32_le nameIndex; union { - quint32_le_bitfield<0, 31> type; + quint32_le_bitfield<0, 29> builtinTypeOrTypeNameIndex; + quint32_le_bitfield<29, 1> isBuiltinType; + quint32_le_bitfield<30, 1> isList; quint32_le_bitfield<31, 1> isReadOnly; }; - quint32_le customTypeNameIndex; // If type >= Custom + Location location; + + void setBuiltinType(Type t) + { + builtinTypeOrTypeNameIndex = t; + isBuiltinType = true; + } + Type builtinType() const { + if (isBuiltinType) + return static_cast<Type>(quint32(builtinTypeOrTypeNameIndex)); + return InvalidBuiltin; + } + void setCustomType(int nameIndex) + { + builtinTypeOrTypeNameIndex = nameIndex; + isBuiltinType = false; + } }; -static_assert(sizeof(Property) == 16, "Property 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(Property) == 12, "Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); struct Alias { enum Flags : unsigned int { @@ -1044,8 +1061,8 @@ struct TypeReferenceMap : QHash<int, TypeReference> auto prop = obj->propertiesBegin(); auto propEnd = obj->propertiesEnd(); for ( ; prop != propEnd; ++prop) { - if (prop->type >= QV4::CompiledData::Property::Custom) { - TypeReference &r = this->add(prop->customTypeNameIndex, prop->location); + if (!prop->isBuiltinType) { + TypeReference &r = this->add(prop->builtinTypeOrTypeNameIndex, prop->location); r.errorWhenNotFound = true; } } |