@@ -1773,7 +1773,7 @@ using HeapLocalVariableMetadata
1773
1773
// / Swift-compiled.
1774
1774
template <typename Runtime>
1775
1775
struct TargetObjCClassWrapperMetadata : public TargetMetadata <Runtime> {
1776
- const TargetClassMetadata <Runtime> * Class;
1776
+ ConstTargetMetadataPointer <Runtime, TargetClassMetadata> Class;
1777
1777
1778
1778
static bool classof (const TargetMetadata<Runtime> *metadata) {
1779
1779
return metadata->getKind () == MetadataKind::ObjCClassWrapper;
@@ -2141,19 +2141,27 @@ struct TargetProtocolDescriptorList {
2141
2141
using StoredPointer = typename Runtime::StoredPointer;
2142
2142
StoredPointer NumProtocols;
2143
2143
2144
- const TargetProtocolDescriptor<Runtime> **getProtocols () {
2145
- return reinterpret_cast <const TargetProtocolDescriptor<Runtime> **>(this + 1 );
2144
+ ConstTargetMetadataPointer<Runtime, TargetProtocolDescriptor> *
2145
+ getProtocols () {
2146
+ return reinterpret_cast <
2147
+ ConstTargetMetadataPointer<
2148
+ Runtime, TargetProtocolDescriptor> *>(this + 1 );
2146
2149
}
2147
2150
2148
- const TargetProtocolDescriptor<Runtime> * const *getProtocols () const {
2149
- return reinterpret_cast <const TargetProtocolDescriptor<Runtime> * const *>(this + 1 );
2151
+ ConstTargetMetadataPointer<Runtime, TargetProtocolDescriptor> const *
2152
+ getProtocols () const {
2153
+ return reinterpret_cast <
2154
+ ConstTargetMetadataPointer<
2155
+ Runtime, TargetProtocolDescriptor> const *>(this + 1 );
2150
2156
}
2151
2157
2152
- const TargetProtocolDescriptor<Runtime> *operator [](size_t i) const {
2158
+ ConstTargetMetadataPointer<Runtime, TargetProtocolDescriptor> const &
2159
+ operator [](size_t i) const {
2153
2160
return getProtocols ()[i];
2154
2161
}
2155
2162
2156
- const TargetProtocolDescriptor<Runtime> *&operator [](size_t i) {
2163
+ ConstTargetMetadataPointer<Runtime, TargetProtocolDescriptor> &
2164
+ operator [](size_t i) {
2157
2165
return getProtocols ()[i];
2158
2166
}
2159
2167
@@ -2173,29 +2181,36 @@ struct TargetLiteralProtocolDescriptorList
2173
2181
2174
2182
template <typename ...DescriptorPointers>
2175
2183
constexpr TargetLiteralProtocolDescriptorList (DescriptorPointers...elements)
2176
- : TargetProtocolDescriptorList<Runtime>(NUM_PROTOCOLS), Protocols{elements...}
2184
+ : TargetProtocolDescriptorList<Runtime>(NUM_PROTOCOLS),
2185
+ Protocols{elements...}
2177
2186
{}
2178
2187
};
2188
+ using LiteralProtocolDescriptorList = TargetProtocolDescriptorList<InProcess>;
2179
2189
2180
2190
// / A protocol descriptor. This is not type metadata, but is referenced by
2181
2191
// / existential type metadata records to describe a protocol constraint.
2182
2192
// / Its layout is compatible with the Objective-C runtime's 'protocol_t' record
2183
2193
// / layout.
2184
2194
template <typename Runtime>
2185
2195
struct TargetProtocolDescriptor {
2196
+ using StoredPointer = typename Runtime::StoredPointer;
2186
2197
// / Unused by the Swift runtime.
2187
- const void * _ObjC_Isa;
2198
+ TargetPointer<Runtime, const void > _ObjC_Isa;
2188
2199
2189
2200
// / The mangled name of the protocol.
2190
- const char * Name;
2201
+ TargetPointer<Runtime, const char > Name;
2191
2202
2192
2203
// / The list of protocols this protocol refines.
2193
- const TargetProtocolDescriptorList<Runtime> *InheritedProtocols;
2204
+ ConstTargetMetadataPointer<Runtime, TargetProtocolDescriptorList>
2205
+ InheritedProtocols;
2194
2206
2195
2207
// / Unused by the Swift runtime.
2196
- const void *_ObjC_InstanceMethods, *_ObjC_ClassMethods,
2197
- *_ObjC_OptionalInstanceMethods, *_ObjC_OptionalClassMethods,
2198
- *_ObjC_InstanceProperties;
2208
+ TargetPointer<Runtime, const void >
2209
+ _ObjC_InstanceMethods,
2210
+ _ObjC_ClassMethods,
2211
+ _ObjC_OptionalInstanceMethods,
2212
+ _ObjC_OptionalClassMethods,
2213
+ _ObjC_InstanceProperties;
2199
2214
2200
2215
// / Size of the descriptor record.
2201
2216
uint32_t DescriptorSize;
@@ -2229,8 +2244,8 @@ struct TargetProtocolDescriptor {
2229
2244
}
2230
2245
2231
2246
constexpr TargetProtocolDescriptor<Runtime>(const char *Name,
2232
- const TargetProtocolDescriptorList<Runtime> *Inherited,
2233
- ProtocolDescriptorFlags Flags)
2247
+ const TargetProtocolDescriptorList<Runtime> *Inherited,
2248
+ ProtocolDescriptorFlags Flags)
2234
2249
: _ObjC_Isa(nullptr ), Name(Name), InheritedProtocols(Inherited),
2235
2250
_ObjC_InstanceMethods (nullptr ), _ObjC_ClassMethods(nullptr ),
2236
2251
_ObjC_OptionalInstanceMethods(nullptr ),
@@ -2304,6 +2319,7 @@ enum class ExistentialTypeRepresentation {
2304
2319
// / The structure of existential type metadata.
2305
2320
template <typename Runtime>
2306
2321
struct TargetExistentialTypeMetadata : public TargetMetadata <Runtime> {
2322
+ using StoredPointer = typename Runtime::StoredPointer;
2307
2323
// / The number of witness tables and class-constrained-ness of the type.
2308
2324
ExistentialTypeFlags Flags;
2309
2325
// / The protocol constraints.
@@ -2354,6 +2370,10 @@ struct TargetExistentialTypeMetadata : public TargetMetadata<Runtime> {
2354
2370
static bool classof (const TargetMetadata<Runtime> *metadata) {
2355
2371
return metadata->getKind () == MetadataKind::Existential;
2356
2372
}
2373
+
2374
+ static constexpr StoredPointer
2375
+ OffsetToNumProtocols = sizeof (TargetMetadata<Runtime>) + sizeof (Flags);
2376
+
2357
2377
};
2358
2378
using ExistentialTypeMetadata
2359
2379
= TargetExistentialTypeMetadata<InProcess>;
0 commit comments