@@ -1735,6 +1735,12 @@ struct TargetExistentialTypeMetadata
17351735using ExistentialTypeMetadata
17361736 = TargetExistentialTypeMetadata<InProcess>;
17371737
1738+ template <typename Runtime>
1739+ struct TargetExistentialTypeExpression {
1740+ // / The type expression.
1741+ TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false > name;
1742+ };
1743+
17381744// / A description of the shape of an existential type.
17391745// /
17401746// / An existential type has the general form:
@@ -1791,7 +1797,7 @@ struct TargetExtendedExistentialTypeShape
17911797 // Optional generalization signature header
17921798 TargetGenericContextDescriptorHeader<Runtime>,
17931799 // Optional type subexpression
1794- TargetRelativeDirectPointer <Runtime, const char , /* nullable */ false >,
1800+ TargetExistentialTypeExpression <Runtime>,
17951801 // Optional suggested value witnesses
17961802 TargetRelativeIndirectablePointer<Runtime, const TargetValueWitnessTable<Runtime>,
17971803 /* nullable*/ false >,
@@ -1802,8 +1808,6 @@ struct TargetExtendedExistentialTypeShape
18021808 // for generalization signature
18031809 TargetGenericRequirementDescriptor<Runtime>> {
18041810private:
1805- using RelativeStringPointer =
1806- TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false >;
18071811 using RelativeValueWitnessTablePointer =
18081812 TargetRelativeIndirectablePointer<Runtime,
18091813 const TargetValueWitnessTable<Runtime>,
@@ -1812,7 +1816,7 @@ struct TargetExtendedExistentialTypeShape
18121816 swift::ABI::TrailingObjects<
18131817 TargetExtendedExistentialTypeShape<Runtime>,
18141818 TargetGenericContextDescriptorHeader<Runtime>,
1815- RelativeStringPointer ,
1819+ TargetExistentialTypeExpression<Runtime> ,
18161820 RelativeValueWitnessTablePointer,
18171821 GenericParamDescriptor,
18181822 TargetGenericRequirementDescriptor<Runtime>>;
@@ -1825,7 +1829,7 @@ struct TargetExtendedExistentialTypeShape
18251829 return Flags.hasGeneralizationSignature ();
18261830 }
18271831
1828- size_t numTrailingObjects (OverloadToken<RelativeStringPointer >) const {
1832+ size_t numTrailingObjects (OverloadToken<TargetExistentialTypeExpression<Runtime> >) const {
18291833 return Flags.hasTypeExpression ();
18301834 }
18311835
@@ -1879,12 +1883,13 @@ struct TargetExtendedExistentialTypeShape
18791883 // / we nonetheless distinguish at compile time. Storing this also
18801884 // / allows us to far more easily produce a formal type from this
18811885 // / shape reflectively.
1882- RelativeStringPointer ExistentialType;
1886+ TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false >
1887+ ExistentialType;
18831888
18841889 // / The header describing the requirement signature of the existential.
18851890 TargetGenericContextDescriptorHeader<Runtime> ReqSigHeader;
18861891
1887- RuntimeGenericSignature getRequirementSignature () const {
1892+ RuntimeGenericSignature<Runtime> getRequirementSignature () const {
18881893 return {ReqSigHeader, getReqSigParams (), getReqSigRequirements ()};
18891894 }
18901895
@@ -1894,8 +1899,8 @@ struct TargetExtendedExistentialTypeShape
18941899
18951900 const GenericParamDescriptor *getReqSigParams () const {
18961901 return Flags.hasImplicitReqSigParams ()
1897- ? ImplicitGenericParamDescriptors
1898- : this ->template getTrailingObjects <GenericParamDescriptor>();
1902+ ? swift::targetImplicitGenericParamDescriptors<Runtime>()
1903+ : this ->template getTrailingObjects <GenericParamDescriptor>();
18991904 }
19001905
19011906 unsigned getNumReqSigRequirements () const {
@@ -1911,10 +1916,11 @@ struct TargetExtendedExistentialTypeShape
19111916 // / The type expression of the existential, as a symbolic mangled type
19121917 // / string. Must be null if the header is just the (single)
19131918 // / requirement type parameter.
1914- TargetPointer<Runtime, const char > getTypeExpression () const {
1919+ const TargetExistentialTypeExpression<Runtime> * getTypeExpression () const {
19151920 return Flags.hasTypeExpression ()
1916- ? this ->template getTrailingObjects <RelativeStringPointer>()->get ()
1917- : nullptr ;
1921+ ? this ->template getTrailingObjects <
1922+ TargetExistentialTypeExpression<Runtime>>()
1923+ : nullptr ;
19181924 }
19191925
19201926 bool isTypeExpressionOpaque () const {
@@ -1961,8 +1967,8 @@ struct TargetExtendedExistentialTypeShape
19611967 return Flags.hasGeneralizationSignature ();
19621968 }
19631969
1964- RuntimeGenericSignature getGeneralizationSignature () const {
1965- if (!hasGeneralizationSignature ()) return RuntimeGenericSignature ();
1970+ RuntimeGenericSignature<Runtime> getGeneralizationSignature () const {
1971+ if (!hasGeneralizationSignature ()) return RuntimeGenericSignature<Runtime> ();
19661972 return {*getGenSigHeader (), getGenSigParams (), getGenSigRequirements ()};
19671973 }
19681974
@@ -1974,7 +1980,7 @@ struct TargetExtendedExistentialTypeShape
19741980 const GenericParamDescriptor *getGenSigParams () const {
19751981 assert (hasGeneralizationSignature ());
19761982 if (Flags.hasImplicitGenSigParams ())
1977- return ImplicitGenericParamDescriptors ;
1983+ return swift::targetImplicitGenericParamDescriptors<Runtime>() ;
19781984 auto base = this ->template getTrailingObjects <GenericParamDescriptor>();
19791985 if (!Flags.hasImplicitReqSigParams ())
19801986 base += getNumReqSigParams ();
@@ -2086,6 +2092,8 @@ struct TargetExtendedExistentialTypeMetadata
20862092 swift::ABI::TrailingObjects<
20872093 TargetExtendedExistentialTypeMetadata<Runtime>,
20882094 ConstTargetPointer<Runtime, void >> {
2095+ using StoredSize = typename Runtime::StoredSize;
2096+
20892097private:
20902098 using TrailingObjects =
20912099 swift::ABI::TrailingObjects<
@@ -2097,9 +2105,12 @@ struct TargetExtendedExistentialTypeMetadata
20972105 using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
20982106
20992107 size_t numTrailingObjects (OverloadToken<ConstTargetPointer<Runtime, void >>) const {
2100- return Shape->getGenSigLayoutSizeInWords ();
2108+ return Shape->getGenSigArgumentLayoutSizeInWords ();
21012109 }
21022110
2111+ public:
2112+ static constexpr StoredSize OffsetToArguments = sizeof (TargetMetadata<Runtime>);
2113+
21032114public:
21042115 explicit constexpr
21052116 TargetExtendedExistentialTypeMetadata (const ExtendedExistentialTypeShape *shape)
@@ -2113,6 +2124,11 @@ struct TargetExtendedExistentialTypeMetadata
21132124 ConstTargetPointer<Runtime, void > const *getGeneralizationArguments () const {
21142125 return this ->template getTrailingObjects <ConstTargetPointer<Runtime, void >>();
21152126 }
2127+
2128+ public:
2129+ static bool classof (const TargetMetadata<Runtime> *metadata) {
2130+ return metadata->getKind () == MetadataKind::ExtendedExistential;
2131+ }
21162132};
21172133using ExtendedExistentialTypeMetadata
21182134 = TargetExtendedExistentialTypeMetadata<InProcess>;
0 commit comments