Skip to content

Commit e9d22f2

Browse files
authored
[Serialization] Replace fixed-width fields with smaller VBR fields (#26887)
VBR fields can store up to 64 bits of info in N-bit units, where the top bit describes whether there are further units to come. See http://llvm.org/docs/BitCodeFormat.html for more information. In the cases of the fields changed here, these are all usually-small values that can /occasionally/ get a lot larger; a VBR field allows us to pick a reasonable default while still not setting a maximum. Swiftmodule size micro-optimization. No functionality change; due to LLVM bitstream being a self-describing container format, this does not actually break compatibility.
1 parent 9b514db commit e9d22f2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

include/swift/Serialization/ModuleFormat.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,9 @@ namespace decls_block {
901901
BCFixed<1>, // pseudogeneric?
902902
BCFixed<1>, // noescape?
903903
BCFixed<1>, // error result?
904-
BCFixed<30>, // number of parameters
905-
BCFixed<30>, // number of yields
906-
BCFixed<30>, // number of results
904+
BCVBR<6>, // number of parameters
905+
BCVBR<5>, // number of yields
906+
BCVBR<5>, // number of results
907907
GenericSignatureIDField, // generic signature
908908
BCArray<TypeIDField> // parameter types/conventions, alternating
909909
// followed by result types/conventions, alternating
@@ -919,7 +919,7 @@ namespace decls_block {
919919
using SILLayoutLayout = BCRecordLayout<
920920
SIL_LAYOUT,
921921
GenericSignatureIDField, // generic signature
922-
BCFixed<31>, // number of fields
922+
BCVBR<8>, // number of fields
923923
BCArray<TypeIDWithBitField> // field types with mutability
924924
>;
925925

@@ -1106,7 +1106,7 @@ namespace decls_block {
11061106
AccessLevelField, // setter access, if applicable
11071107
DeclIDField, // opaque return type decl
11081108
BCFixed<2>, // # of property wrapper backing properties
1109-
BCVBR<4>, // total number of vtable entries introduced by all accessors
1109+
BCVBR<4>, // total number of vtable entries introduced by all accessors
11101110
BCArray<TypeIDField> // accessors, backing properties, and dependencies
11111111
>;
11121112

@@ -1272,7 +1272,7 @@ namespace decls_block {
12721272
StaticSpellingKindField, // is subscript static?
12731273
BCVBR<5>, // number of parameter name components
12741274
DeclIDField, // opaque return type decl
1275-
BCFixed<8>, // total number of vtable entries introduced by all accessors
1275+
BCVBR<4>, // total number of vtable entries introduced by all accessors
12761276
BCArray<IdentifierIDField> // name components,
12771277
// followed by DeclID accessors,
12781278
// followed by TypeID dependencies
@@ -1396,8 +1396,8 @@ namespace decls_block {
13961396
LAYOUT_REQUIREMENT,
13971397
LayoutRequirementKindField, // requirement kind
13981398
TypeIDField, // type being constrained
1399-
BCFixed<24>, // size
1400-
BCFixed<32> // alignment
1399+
BCVBR<16>, // size
1400+
BCVBR<8> // alignment
14011401
>;
14021402

14031403
/// Specifies the private discriminator string for a private declaration. This
@@ -1549,7 +1549,7 @@ namespace decls_block {
15491549
using AlignmentDeclAttrLayout = BCRecordLayout<
15501550
Alignment_DECL_ATTR,
15511551
BCFixed<1>, // implicit flag
1552-
BCFixed<31> // alignment
1552+
BCVBR<8> // alignment
15531553
>;
15541554

15551555
using SwiftNativeObjCRuntimeBaseDeclAttrLayout = BCRecordLayout<

0 commit comments

Comments
 (0)