Skip to content

Commit fa998b1

Browse files
authored
Merge pull request #14826 from rjmccall/consolidate-patterns-into-descriptors
2 parents c452a68 + dd99536 commit fa998b1

38 files changed

+752
-646
lines changed

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Globals
5353
global ::= type 'MP' // type metadata pattern
5454
global ::= type 'Ma' // type metadata access function
5555
global ::= type 'ML' // type metadata lazy cache variable
56+
global ::= nominal-type 'Mi' // generic type instantiation function
57+
global ::= nominal-type 'MI' // generic type instantiation cache
5658
global ::= nominal-type 'Mm' // class metaclass
5759
global ::= nominal-type 'Mn' // nominal type descriptor
5860
global ::= module 'MXM' // module descriptor

include/swift/Demangling/DemangleNodes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ NODE(TypeList)
173173
NODE(TypeMangling)
174174
NODE(TypeMetadata)
175175
NODE(TypeMetadataAccessFunction)
176+
NODE(TypeMetadataInstantiationCache)
177+
NODE(TypeMetadataInstantiationFunction)
176178
NODE(TypeMetadataLazyCache)
177179
NODE(UncurriedFunctionType)
178180
NODE(Unmanaged)

include/swift/IRGen/Linking.h

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ class LinkEntity {
9090
// This field appears in the ValueWitness kind.
9191
ValueWitnessShift = 8, ValueWitnessMask = 0xFF00,
9292

93-
// These fields appear in the TypeMetadata kind.
93+
// This field appears in the TypeMetadata kind.
9494
MetadataAddressShift = 8, MetadataAddressMask = 0x0300,
95-
IsPatternShift = 10, IsPatternMask = 0x0400,
9695

9796
// This field appears in associated type access functions.
9897
AssociatedTypeIndexShift = 8, AssociatedTypeIndexMask = ~KindMask,
@@ -148,6 +147,18 @@ class LinkEntity {
148147
/// The pointer is a NominalTypeDecl*.
149148
NominalTypeDescriptor,
150149

150+
/// The metadata pattern for a generic nominal type.
151+
/// The pointer is a NominalTypeDecl*.
152+
TypeMetadataPattern,
153+
154+
/// The instantiation cache for a generic nominal type.
155+
/// The pointer is a NominalTypeDecl*.
156+
TypeMetadataInstantiationCache,
157+
158+
/// The instantiation function for a generic nominal type.
159+
/// The pointer is a NominalTypeDecl*.
160+
TypeMetadataInstantiationFunction,
161+
151162
/// The module descriptor for a module.
152163
/// The pointer is a ModuleDecl*.
153164
ModuleDescriptor,
@@ -444,14 +455,18 @@ class LinkEntity {
444455
}
445456

446457
static LinkEntity forTypeMetadata(CanType concreteType,
447-
TypeMetadataAddress addr,
448-
bool isPattern) {
458+
TypeMetadataAddress addr) {
449459
LinkEntity entity;
450460
entity.Pointer = concreteType.getPointer();
451461
entity.SecondaryPointer = nullptr;
452462
entity.Data = LINKENTITY_SET_FIELD(Kind, unsigned(Kind::TypeMetadata))
453-
| LINKENTITY_SET_FIELD(MetadataAddress, unsigned(addr))
454-
| LINKENTITY_SET_FIELD(IsPattern, unsigned(isPattern));
463+
| LINKENTITY_SET_FIELD(MetadataAddress, unsigned(addr));
464+
return entity;
465+
}
466+
467+
static LinkEntity forTypeMetadataPattern(NominalTypeDecl *decl) {
468+
LinkEntity entity;
469+
entity.setForDecl(Kind::TypeMetadataPattern, decl);
455470
return entity;
456471
}
457472

@@ -461,6 +476,18 @@ class LinkEntity {
461476
return entity;
462477
}
463478

479+
static LinkEntity forTypeMetadataInstantiationCache(NominalTypeDecl *decl) {
480+
LinkEntity entity;
481+
entity.setForDecl(Kind::TypeMetadataInstantiationCache, decl);
482+
return entity;
483+
}
484+
485+
static LinkEntity forTypeMetadataInstantiationFunction(NominalTypeDecl *decl){
486+
LinkEntity entity;
487+
entity.setForDecl(Kind::TypeMetadataInstantiationFunction, decl);
488+
return entity;
489+
}
490+
464491
static LinkEntity forTypeMetadataLazyCacheVariable(CanType type) {
465492
LinkEntity entity;
466493
entity.setForType(Kind::TypeMetadataLazyCacheVariable, type);
@@ -726,10 +753,6 @@ class LinkEntity {
726753
assert(getKind() == Kind::TypeMetadata);
727754
return (TypeMetadataAddress)LINKENTITY_GET_FIELD(Data, MetadataAddress);
728755
}
729-
bool isMetadataPattern() const {
730-
assert(getKind() == Kind::TypeMetadata);
731-
return LINKENTITY_GET_FIELD(Data, IsPattern);
732-
}
733756
bool isForeignTypeMetadataCandidate() const {
734757
return getKind() == Kind::ForeignTypeMetadataCandidate;
735758
}

include/swift/Remote/MetadataReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ class MetadataReader {
919919
// If this class has a null descriptor, it's artificial,
920920
// and we need to skip it upon request. Otherwise, we're done.
921921
if (descriptorAddress || !skipArtificialSubclasses)
922-
return static_cast<uintptr_t>(descriptorAddress);
922+
return static_cast<StoredPointer>(descriptorAddress);
923923

924924
auto superclassMetadataAddress = classMeta->SuperClass;
925925
if (!superclassMetadataAddress)
@@ -942,7 +942,7 @@ class MetadataReader {
942942
case MetadataKind::Optional:
943943
case MetadataKind::Enum: {
944944
auto valueMeta = cast<TargetValueMetadata<Runtime>>(metadata);
945-
return reinterpret_cast<uintptr_t>(valueMeta->getDescription());
945+
return valueMeta->getDescription();
946946
}
947947

948948
default:

include/swift/Runtime/Exclusivity.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
namespace swift {
2525

2626
enum class ExclusivityFlags : uintptr_t;
27-
struct ValueBuffer;
27+
template <typename Runtime> struct TargetValueBuffer;
28+
struct InProcess;
29+
using ValueBuffer = TargetValueBuffer<InProcess>;
2830

2931
/// Begin dynamically tracking an access.
3032
///

0 commit comments

Comments
 (0)