@@ -1735,6 +1735,12 @@ struct TargetExistentialTypeMetadata
1735
1735
using ExistentialTypeMetadata
1736
1736
= TargetExistentialTypeMetadata<InProcess>;
1737
1737
1738
+ template <typename Runtime>
1739
+ struct TargetExistentialTypeExpression {
1740
+ // / The type expression.
1741
+ TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false > name;
1742
+ };
1743
+
1738
1744
// / A description of the shape of an existential type.
1739
1745
// /
1740
1746
// / An existential type has the general form:
@@ -1791,7 +1797,7 @@ struct TargetExtendedExistentialTypeShape
1791
1797
// Optional generalization signature header
1792
1798
TargetGenericContextDescriptorHeader<Runtime>,
1793
1799
// Optional type subexpression
1794
- TargetRelativeDirectPointer <Runtime, const char , /* nullable */ false >,
1800
+ TargetExistentialTypeExpression <Runtime>,
1795
1801
// Optional suggested value witnesses
1796
1802
TargetRelativeIndirectablePointer<Runtime, const TargetValueWitnessTable<Runtime>,
1797
1803
/* nullable*/ false >,
@@ -1802,8 +1808,6 @@ struct TargetExtendedExistentialTypeShape
1802
1808
// for generalization signature
1803
1809
TargetGenericRequirementDescriptor<Runtime>> {
1804
1810
private:
1805
- using RelativeStringPointer =
1806
- TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false >;
1807
1811
using RelativeValueWitnessTablePointer =
1808
1812
TargetRelativeIndirectablePointer<Runtime,
1809
1813
const TargetValueWitnessTable<Runtime>,
@@ -1812,7 +1816,7 @@ struct TargetExtendedExistentialTypeShape
1812
1816
swift::ABI::TrailingObjects<
1813
1817
TargetExtendedExistentialTypeShape<Runtime>,
1814
1818
TargetGenericContextDescriptorHeader<Runtime>,
1815
- RelativeStringPointer ,
1819
+ TargetExistentialTypeExpression<Runtime> ,
1816
1820
RelativeValueWitnessTablePointer,
1817
1821
GenericParamDescriptor,
1818
1822
TargetGenericRequirementDescriptor<Runtime>>;
@@ -1825,7 +1829,7 @@ struct TargetExtendedExistentialTypeShape
1825
1829
return Flags.hasGeneralizationSignature ();
1826
1830
}
1827
1831
1828
- size_t numTrailingObjects (OverloadToken<RelativeStringPointer >) const {
1832
+ size_t numTrailingObjects (OverloadToken<TargetExistentialTypeExpression<Runtime> >) const {
1829
1833
return Flags.hasTypeExpression ();
1830
1834
}
1831
1835
@@ -1879,12 +1883,13 @@ struct TargetExtendedExistentialTypeShape
1879
1883
// / we nonetheless distinguish at compile time. Storing this also
1880
1884
// / allows us to far more easily produce a formal type from this
1881
1885
// / shape reflectively.
1882
- RelativeStringPointer ExistentialType;
1886
+ TargetRelativeDirectPointer<Runtime, const char , /* nullable*/ false >
1887
+ ExistentialType;
1883
1888
1884
1889
// / The header describing the requirement signature of the existential.
1885
1890
TargetGenericContextDescriptorHeader<Runtime> ReqSigHeader;
1886
1891
1887
- RuntimeGenericSignature getRequirementSignature () const {
1892
+ RuntimeGenericSignature<Runtime> getRequirementSignature () const {
1888
1893
return {ReqSigHeader, getReqSigParams (), getReqSigRequirements ()};
1889
1894
}
1890
1895
@@ -1894,8 +1899,8 @@ struct TargetExtendedExistentialTypeShape
1894
1899
1895
1900
const GenericParamDescriptor *getReqSigParams () const {
1896
1901
return Flags.hasImplicitReqSigParams ()
1897
- ? ImplicitGenericParamDescriptors
1898
- : this ->template getTrailingObjects <GenericParamDescriptor>();
1902
+ ? swift::targetImplicitGenericParamDescriptors<Runtime>()
1903
+ : this ->template getTrailingObjects <GenericParamDescriptor>();
1899
1904
}
1900
1905
1901
1906
unsigned getNumReqSigRequirements () const {
@@ -1911,10 +1916,11 @@ struct TargetExtendedExistentialTypeShape
1911
1916
// / The type expression of the existential, as a symbolic mangled type
1912
1917
// / string. Must be null if the header is just the (single)
1913
1918
// / requirement type parameter.
1914
- TargetPointer<Runtime, const char > getTypeExpression () const {
1919
+ const TargetExistentialTypeExpression<Runtime> * getTypeExpression () const {
1915
1920
return Flags.hasTypeExpression ()
1916
- ? this ->template getTrailingObjects <RelativeStringPointer>()->get ()
1917
- : nullptr ;
1921
+ ? this ->template getTrailingObjects <
1922
+ TargetExistentialTypeExpression<Runtime>>()
1923
+ : nullptr ;
1918
1924
}
1919
1925
1920
1926
bool isTypeExpressionOpaque () const {
@@ -1961,8 +1967,8 @@ struct TargetExtendedExistentialTypeShape
1961
1967
return Flags.hasGeneralizationSignature ();
1962
1968
}
1963
1969
1964
- RuntimeGenericSignature getGeneralizationSignature () const {
1965
- if (!hasGeneralizationSignature ()) return RuntimeGenericSignature ();
1970
+ RuntimeGenericSignature<Runtime> getGeneralizationSignature () const {
1971
+ if (!hasGeneralizationSignature ()) return RuntimeGenericSignature<Runtime> ();
1966
1972
return {*getGenSigHeader (), getGenSigParams (), getGenSigRequirements ()};
1967
1973
}
1968
1974
@@ -1974,7 +1980,7 @@ struct TargetExtendedExistentialTypeShape
1974
1980
const GenericParamDescriptor *getGenSigParams () const {
1975
1981
assert (hasGeneralizationSignature ());
1976
1982
if (Flags.hasImplicitGenSigParams ())
1977
- return ImplicitGenericParamDescriptors ;
1983
+ return swift::targetImplicitGenericParamDescriptors<Runtime>() ;
1978
1984
auto base = this ->template getTrailingObjects <GenericParamDescriptor>();
1979
1985
if (!Flags.hasImplicitReqSigParams ())
1980
1986
base += getNumReqSigParams ();
@@ -2086,6 +2092,8 @@ struct TargetExtendedExistentialTypeMetadata
2086
2092
swift::ABI::TrailingObjects<
2087
2093
TargetExtendedExistentialTypeMetadata<Runtime>,
2088
2094
ConstTargetPointer<Runtime, void >> {
2095
+ using StoredSize = typename Runtime::StoredSize;
2096
+
2089
2097
private:
2090
2098
using TrailingObjects =
2091
2099
swift::ABI::TrailingObjects<
@@ -2097,9 +2105,12 @@ struct TargetExtendedExistentialTypeMetadata
2097
2105
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
2098
2106
2099
2107
size_t numTrailingObjects (OverloadToken<ConstTargetPointer<Runtime, void >>) const {
2100
- return Shape->getGenSigLayoutSizeInWords ();
2108
+ return Shape->getGenSigArgumentLayoutSizeInWords ();
2101
2109
}
2102
2110
2111
+ public:
2112
+ static constexpr StoredSize OffsetToArguments = sizeof (TargetMetadata<Runtime>);
2113
+
2103
2114
public:
2104
2115
explicit constexpr
2105
2116
TargetExtendedExistentialTypeMetadata (const ExtendedExistentialTypeShape *shape)
@@ -2113,6 +2124,11 @@ struct TargetExtendedExistentialTypeMetadata
2113
2124
ConstTargetPointer<Runtime, void > const *getGeneralizationArguments () const {
2114
2125
return this ->template getTrailingObjects <ConstTargetPointer<Runtime, void >>();
2115
2126
}
2127
+
2128
+ public:
2129
+ static bool classof (const TargetMetadata<Runtime> *metadata) {
2130
+ return metadata->getKind () == MetadataKind::ExtendedExistential;
2131
+ }
2116
2132
};
2117
2133
using ExtendedExistentialTypeMetadata
2118
2134
= TargetExtendedExistentialTypeMetadata<InProcess>;
0 commit comments