@@ -155,28 +155,20 @@ Metadata *TargetSingletonMetadataInitialization<InProcess>::allocate(
155
155
return metadata;
156
156
}
157
157
158
- // / Copy the generic arguments into place in a newly-allocated metadata.
159
- static void installGenericArguments (Metadata *metadata,
160
- const TypeContextDescriptor *description,
161
- const void *arguments) {
162
- const auto &genericContext = *description->getGenericContext ();
163
- const auto &header = genericContext.getGenericContextHeader ();
164
-
165
- auto dst = (reinterpret_cast <const void **>(metadata) +
166
- description->getGenericArgumentOffset ());
167
- memcpy (dst,
168
- reinterpret_cast <const void * const *>(arguments),
169
- header.NumKeyArguments * sizeof (void *));
158
+ void MetadataCacheKey::installGenericArguments (
159
+ uint16_t numKeyArguments,
160
+ uint16_t numPacks,
161
+ const GenericPackShapeDescriptor *PackShapeDescriptors,
162
+ const void **dst, const void * const *src) {
163
+ memcpy (dst, src, numKeyArguments * sizeof (void *));
170
164
171
165
// If we don't have any pack arguments, there is nothing more to do.
172
- auto packShapeHeader = genericContext.getGenericPackShapeHeader ();
173
- if (packShapeHeader.NumPacks == 0 )
166
+ if (numPacks == 0 )
174
167
return ;
175
168
176
169
// Heap-allocate all installed metadata and witness table packs.
177
- for (auto pack : genericContext.getGenericPackShapeDescriptors ()) {
178
- assert (pack.ShapeClass < packShapeHeader.NumShapeClasses );
179
-
170
+ for (unsigned i = 0 ; i < numPacks; ++i) {
171
+ auto pack = PackShapeDescriptors[i];
180
172
size_t count = reinterpret_cast <size_t >(dst[pack.ShapeClass ]);
181
173
182
174
switch (pack.Kind ) {
@@ -195,6 +187,26 @@ static void installGenericArguments(Metadata *metadata,
195
187
}
196
188
}
197
189
190
+ // / Copy the generic arguments into place in a newly-allocated metadata.
191
+ static void installGenericArguments (Metadata *metadata,
192
+ const TypeContextDescriptor *description,
193
+ const void *arguments) {
194
+ const auto &genericContext = *description->getGenericContext ();
195
+ const auto &header = genericContext.getGenericContextHeader ();
196
+
197
+ auto dst = (reinterpret_cast <const void **>(metadata) +
198
+ description->getGenericArgumentOffset ());
199
+ auto src = reinterpret_cast <const void * const *>(arguments);
200
+
201
+ auto packShapeHeader = genericContext.getGenericPackShapeHeader ();
202
+
203
+ MetadataCacheKey::installGenericArguments (
204
+ header.NumKeyArguments ,
205
+ packShapeHeader.NumPacks ,
206
+ genericContext.getGenericPackShapeDescriptors ().data (),
207
+ dst, src);
208
+ }
209
+
198
210
#if SWIFT_OBJC_INTEROP
199
211
static ClassMetadataBounds computeMetadataBoundsForObjCClass (Class cls) {
200
212
cls = swift_getInitializedObjCClass (cls);
0 commit comments