diff options
author | Ulf Hermann <[email protected]> | 2022-05-04 11:47:38 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2022-05-11 12:56:21 +0200 |
commit | 2642058df8429cd593d0c7adf45a818a42fc0d88 (patch) | |
tree | 01027c7f20156a930aaf54895c4ec9087e2c1ccd /src/qml | |
parent | b5a8a6943ab979e23db284780df9209af5ae03a8 (diff) |
QML: Port QV4::CompiledData::ParameterType to new special integer bitfield
Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: I515aa7a605accc4b45f9dd4918dd6bfb6e116379
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Sami Shalayel <[email protected]>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/common/qv4compileddata_p.h | 25 | ||||
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycachecreator_p.h | 7 |
3 files changed, 29 insertions, 15 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h index 297cee3610..0d2c171e5d 100644 --- a/src/qml/common/qv4compileddata_p.h +++ b/src/qml/common/qv4compileddata_p.h @@ -273,11 +273,26 @@ enum class BuiltinType : unsigned int { struct ParameterType { - union { - quint32 _dummy; - quint32_le_bitfield<0, 1> indexIsBuiltinType; - quint32_le_bitfield<1, 31> typeNameIndexOrBuiltinType; - }; + void set(bool indexIsBuiltinType, quint32 typeNameIndexOrBuiltinType) + { + m_data.set<IndexIsBuiltinTypeField>(indexIsBuiltinType ? 1 : 0); + m_data.set<TypeNameIndexOrBuiltinTypeField>(typeNameIndexOrBuiltinType); + } + + bool indexIsBuiltinType() const + { + return m_data.get<IndexIsBuiltinTypeField>() != 0; + } + + quint32 typeNameIndexOrBuiltinType() const + { + return m_data.get<TypeNameIndexOrBuiltinTypeField>(); + } + +private: + using IndexIsBuiltinTypeField = quint32_le_bitfield_member<0, 1>; + using TypeNameIndexOrBuiltinTypeField = quint32_le_bitfield_member<1, 31>; + quint32_le_bitfield_union<IndexIsBuiltinTypeField, TypeNameIndexOrBuiltinTypeField> m_data; }; static_assert(sizeof(ParameterType) == 4, "ParameterType structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target"); diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index bd3e5e7bde..8a61a58486 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -108,20 +108,18 @@ bool Parameter::init(QV4::CompiledData::Parameter *param, const QV4::Compiler::J bool Parameter::initType(QV4::CompiledData::ParameterType *paramType, const QV4::Compiler::JSUnitGenerator *stringGenerator, int typeNameIndex) { - paramType->indexIsBuiltinType = false; - paramType->typeNameIndexOrBuiltinType = 0; const QString typeName = stringGenerator->stringForIndex(typeNameIndex); auto builtinType = stringToBuiltinType(typeName); if (builtinType == QV4::CompiledData::BuiltinType::InvalidBuiltin) { - if (typeName.isEmpty()) + if (typeName.isEmpty()) { + paramType->set(false, 0); return false; - paramType->indexIsBuiltinType = false; - paramType->typeNameIndexOrBuiltinType = typeNameIndex; + } Q_ASSERT(quint32(typeNameIndex) < (1u << 31)); + paramType->set(false, typeNameIndex); } else { - paramType->indexIsBuiltinType = true; - paramType->typeNameIndexOrBuiltinType = static_cast<quint32>(builtinType); Q_ASSERT(quint32(builtinType) < (1u << 31)); + paramType->set(true, static_cast<quint32>(builtinType)); } return true; } diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index f683dc208c..892b08c614 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -743,13 +743,14 @@ template <typename ObjectContainer> inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter(const QV4::CompiledData::ParameterType ¶m, QString *customTypeName) { - if (param.indexIsBuiltinType) { + if (param.indexIsBuiltinType()) { // built-in type - return metaTypeForPropertyType(static_cast<QV4::CompiledData::BuiltinType>(int(param.typeNameIndexOrBuiltinType))); + return metaTypeForPropertyType( + static_cast<QV4::CompiledData::BuiltinType>(param.typeNameIndexOrBuiltinType())); } // lazily resolved type - const QString typeName = stringAt(param.typeNameIndexOrBuiltinType); + const QString typeName = stringAt(param.typeNameIndexOrBuiltinType()); if (customTypeName) *customTypeName = typeName; QQmlType qmltype; |