mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Rework the serialization schema for conformances and requirements.
We now schedule conformance emissions in basically the same way we do for types and declarations, which means that we'll emit them uniquely in the module file instead of redundantly at every use. This should produce substantially smaller module files overall, especially for modules that heavily use generics. It also means that we can remove all the unfortunate code to support using different abbrev codes for them in different bitcode blocks. Requirement lists are now emitted inline in the records that need them instead of as trailing records. I think this will improve space usage, but mostly it assists in eliminating the problem where abbrev codes are shared between blocks.
This commit is contained in:
@@ -56,7 +56,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
|
||||
/// describe what change you made. The content of this comment isn't important;
|
||||
/// it just ensures a conflict if two people change the module format.
|
||||
/// Don't worry about adhering to the 80-column limit for this line.
|
||||
const uint16_t SWIFTMODULE_VERSION_MINOR = 672; // default expression type
|
||||
const uint16_t SWIFTMODULE_VERSION_MINOR = 673; // new schema for conformances
|
||||
|
||||
/// A standard hash seed used for all string hashes in a serialized module.
|
||||
///
|
||||
@@ -133,10 +133,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// NormalConformanceID must be the same as DeclID because it is stored
|
||||
// ProtocolConformanceID must be the same as DeclID because it is stored
|
||||
// in the same way.
|
||||
using NormalConformanceID = DeclID;
|
||||
using NormalConformanceIDField = DeclIDField;
|
||||
using ProtocolConformanceID = DeclID;
|
||||
using ProtocolConformanceIDField = DeclIDField;
|
||||
|
||||
// GenericSignatureID must be the same as DeclID because it is stored in the
|
||||
// same way.
|
||||
@@ -1629,9 +1629,8 @@ namespace decls_block {
|
||||
using SubstitutionMapLayout = BCRecordLayout<
|
||||
SUBSTITUTION_MAP,
|
||||
GenericSignatureIDField, // generic signature
|
||||
BCVBR<5>, // # of conformances
|
||||
BCArray<TypeIDField> // replacement types
|
||||
// Conformances trail the record.
|
||||
BCVBR<5>, // # of replacement types
|
||||
BCArray<TypeIDField> // replacement types and conformances
|
||||
>;
|
||||
|
||||
using SILGenericSignatureLayout = BCRecordLayout<
|
||||
@@ -1640,25 +1639,9 @@ namespace decls_block {
|
||||
// type) pairs
|
||||
>;
|
||||
|
||||
using GenericRequirementLayout = BCRecordLayout<
|
||||
GENERIC_REQUIREMENT,
|
||||
GenericRequirementKindField, // requirement kind
|
||||
TypeIDField, // subject type
|
||||
TypeIDField // constraint type
|
||||
>;
|
||||
|
||||
using LayoutRequirementLayout = BCRecordLayout<
|
||||
LAYOUT_REQUIREMENT,
|
||||
LayoutRequirementKindField, // requirement kind
|
||||
TypeIDField, // type being constrained
|
||||
BCVBR<16>, // size
|
||||
BCVBR<8> // alignment
|
||||
>;
|
||||
|
||||
using ProtocolTypeAliasLayout = BCRecordLayout<
|
||||
PROTOCOL_TYPEALIAS,
|
||||
IdentifierIDField, // name
|
||||
TypeIDField // underlying type
|
||||
using RequirementSignatureLayout = BCRecordLayout<
|
||||
REQUIREMENT_SIGNATURE,
|
||||
BCArray<BCVBR<6>> // requirements and protocol type aliases
|
||||
>;
|
||||
|
||||
using AssociatedTypeLayout = BCRecordLayout<
|
||||
@@ -1683,17 +1666,6 @@ namespace decls_block {
|
||||
IdentifierIDField // the file name, as an identifier
|
||||
>;
|
||||
|
||||
/// A placeholder for lack of concrete conformance information.
|
||||
using AbstractProtocolConformanceLayout = BCRecordLayout<
|
||||
ABSTRACT_PROTOCOL_CONFORMANCE,
|
||||
DeclIDField // the protocol
|
||||
>;
|
||||
|
||||
/// A placeholder for an invalid conformance.
|
||||
using InvalidProtocolConformanceLayout = BCRecordLayout<
|
||||
INVALID_PROTOCOL_CONFORMANCE
|
||||
>;
|
||||
|
||||
using NormalProtocolConformanceLayout = BCRecordLayout<
|
||||
NORMAL_PROTOCOL_CONFORMANCE,
|
||||
DeclIDField, // the protocol
|
||||
@@ -1703,9 +1675,8 @@ namespace decls_block {
|
||||
BCVBR<5>, // requirement signature conformance count
|
||||
BCFixed<1>, // unchecked
|
||||
BCArray<DeclIDField>
|
||||
// The array contains type witnesses, then value witnesses.
|
||||
// Requirement signature conformances follow, then the substitution records
|
||||
// for the associated types.
|
||||
// The array contains requirement signature conformances, then
|
||||
// type witnesses, then value witnesses.
|
||||
>;
|
||||
|
||||
using SelfProtocolConformanceLayout = BCRecordLayout<
|
||||
@@ -1715,14 +1686,15 @@ namespace decls_block {
|
||||
|
||||
using SpecializedProtocolConformanceLayout = BCRecordLayout<
|
||||
SPECIALIZED_PROTOCOL_CONFORMANCE,
|
||||
ProtocolConformanceIDField, // underlying conformance
|
||||
TypeIDField, // conforming type
|
||||
SubstitutionMapIDField // substitution map
|
||||
// trailed by the underlying conformance
|
||||
>;
|
||||
|
||||
using InheritedProtocolConformanceLayout = BCRecordLayout<
|
||||
INHERITED_PROTOCOL_CONFORMANCE,
|
||||
TypeIDField // the conforming type
|
||||
ProtocolConformanceIDField, // underlying conformance
|
||||
TypeIDField // the conforming type
|
||||
>;
|
||||
|
||||
using BuiltinProtocolConformanceLayout = BCRecordLayout<
|
||||
@@ -1730,14 +1702,8 @@ namespace decls_block {
|
||||
TypeIDField, // the conforming type
|
||||
DeclIDField, // the protocol
|
||||
GenericSignatureIDField, // the generic signature
|
||||
BCFixed<2> // the builtin conformance kind
|
||||
// the (optional) conditional requirements follow
|
||||
>;
|
||||
|
||||
// Refers to a normal protocol conformance in the given module via its id.
|
||||
using NormalProtocolConformanceIdLayout = BCRecordLayout<
|
||||
NORMAL_PROTOCOL_CONFORMANCE_ID,
|
||||
NormalConformanceIDField // the normal conformance ID
|
||||
BCFixed<2>, // the builtin conformance kind
|
||||
BCArray<BCVBR<6>> // conditional requirements
|
||||
>;
|
||||
|
||||
using ProtocolConformanceXrefLayout = BCRecordLayout<
|
||||
@@ -2136,7 +2102,7 @@ namespace index_block {
|
||||
LOCAL_TYPE_DECLS,
|
||||
OPAQUE_RETURN_TYPE_DECLS,
|
||||
GENERIC_SIGNATURE_OFFSETS,
|
||||
NORMAL_CONFORMANCE_OFFSETS,
|
||||
PROTOCOL_CONFORMANCE_OFFSETS,
|
||||
SIL_LAYOUT_OFFSETS,
|
||||
|
||||
PRECEDENCE_GROUPS,
|
||||
|
||||
Reference in New Issue
Block a user