@@ -489,7 +489,8 @@ class EmitPolymorphicParameters : public PolymorphicConvention {
489
489
public:
490
490
EmitPolymorphicParameters (IRGenFunction &IGF, SILFunction &Fn);
491
491
492
- void emit (Explosion &in, WitnessMetadata *witnessMetadata,
492
+ void emit (EntryPointArgumentEmission &emission,
493
+ WitnessMetadata *witnessMetadata,
493
494
const GetParameterFn &getParameter);
494
495
495
496
private:
@@ -499,7 +500,8 @@ class EmitPolymorphicParameters : public PolymorphicConvention {
499
500
500
501
// / Fulfill local type data from any extra information associated with
501
502
// / the given source.
502
- void bindExtraSource (const MetadataSource &source, Explosion &in,
503
+ void bindExtraSource (const MetadataSource &source,
504
+ EntryPointArgumentEmission &emission,
503
505
WitnessMetadata *witnessMetadata);
504
506
505
507
void bindParameterSources (const GetParameterFn &getParameter);
@@ -528,9 +530,9 @@ CanType EmitPolymorphicParameters::getArgTypeInContext(unsigned paramIndex) cons
528
530
IGM.getSILModule (), FnType, IGM.getMaximalTypeExpansionContext ()));
529
531
}
530
532
531
- void EmitPolymorphicParameters::bindExtraSource (const MetadataSource &source,
532
- Explosion &in ,
533
- WitnessMetadata *witnessMetadata) {
533
+ void EmitPolymorphicParameters::bindExtraSource (
534
+ const MetadataSource &source, EntryPointArgumentEmission &emission ,
535
+ WitnessMetadata *witnessMetadata) {
534
536
switch (source.getKind ()) {
535
537
case MetadataSource::Kind::Metadata:
536
538
case MetadataSource::Kind::ClassPointer:
@@ -540,7 +542,7 @@ void EmitPolymorphicParameters::bindExtraSource(const MetadataSource &source,
540
542
case MetadataSource::Kind::GenericLValueMetadata: {
541
543
CanType argTy = getArgTypeInContext (source.getParamIndex ());
542
544
543
- llvm::Value *metadata = in. claimNext ();
545
+ llvm::Value *metadata = emission. getNextPolymorphicParameterAsMetadata ();
544
546
setTypeMetadataName (IGF.IGM , metadata, argTy);
545
547
546
548
IGF.bindLocalTypeDataFromTypeMetadata (argTy, IsExact, metadata,
@@ -2223,55 +2225,23 @@ bool irgen::hasPolymorphicParameters(CanSILFunctionType ty) {
2223
2225
}
2224
2226
2225
2227
// / Emit a polymorphic parameters clause, binding all the metadata necessary.
2226
- void EmitPolymorphicParameters::emit (Explosion &in ,
2228
+ void EmitPolymorphicParameters::emit (EntryPointArgumentEmission &emission ,
2227
2229
WitnessMetadata *witnessMetadata,
2228
2230
const GetParameterFn &getParameter) {
2229
2231
// Collect any early sources and bind local type data from them.
2230
2232
for (auto &source : getSources ()) {
2231
- bindExtraSource (source, in , witnessMetadata);
2233
+ bindExtraSource (source, emission , witnessMetadata);
2232
2234
}
2233
2235
2234
2236
auto getInContext = [&](CanType type) -> CanType {
2235
2237
return getTypeInContext (type);
2236
2238
};
2237
2239
2238
- unsigned index = 0 ;
2239
2240
// Collect any concrete type metadata that's been passed separately.
2240
2241
enumerateUnfulfilledRequirements ([&](GenericRequirement requirement) {
2241
- llvm::Value *value;
2242
- if (Fn.isAsync ()) {
2243
- auto *context = in.peek (
2244
- /* the index of the swift.context in the async function CC*/ 0 );
2245
- auto layout = getAsyncContextLayout (IGF, &Fn);
2246
- Address dataAddr = layout.emitCastTo (IGF, context);
2247
- assert (layout.hasBindings ());
2248
-
2249
- auto bindingLayout = layout.getBindingsLayout ();
2250
- auto bindingsAddr =
2251
- bindingLayout.project (IGF, dataAddr, /* offsets*/ None);
2252
- auto erasedBindingsAddr =
2253
- IGF.Builder .CreateBitCast (bindingsAddr, IGF.IGM .Int8PtrPtrTy );
2254
- auto uncastBindingAddr = IGF.Builder .CreateConstArrayGEP (
2255
- erasedBindingsAddr, index, IGF.IGM .getPointerSize ());
2256
- if (requirement.Protocol ) {
2257
- auto bindingAddrAddr = IGF.Builder .CreateBitCast (
2258
- uncastBindingAddr.getAddress (), IGF.IGM .WitnessTablePtrPtrTy );
2259
- auto bindingAddr = IGF.Builder .CreateLoad (
2260
- bindingAddrAddr, IGF.IGM .getPointerAlignment ());
2261
- value = bindingAddr;
2262
- } else {
2263
- auto bindingAddrAddr = IGF.Builder .CreateBitCast (
2264
- uncastBindingAddr.getAddress (), IGF.IGM .TypeMetadataPtrPtrTy );
2265
- auto bindingAddr = IGF.Builder .CreateLoad (
2266
- bindingAddrAddr, IGF.IGM .getPointerAlignment ());
2267
- value = bindingAddr;
2268
- }
2269
- } else {
2270
- value = in.claimNext ();
2271
- }
2242
+ llvm::Value *value = emission.getNextPolymorphicParameter (requirement);
2272
2243
bindGenericRequirement (IGF, requirement, value, MetadataState::Complete,
2273
2244
getInContext);
2274
- ++index;
2275
2245
});
2276
2246
2277
2247
// Bind all the fulfillments we can from the formal parameters.
@@ -2691,12 +2661,12 @@ void irgen::collectTrailingWitnessMetadata(
2691
2661
}
2692
2662
2693
2663
// / Perform all the bindings necessary to emit the given declaration.
2694
- void irgen::emitPolymorphicParameters (IRGenFunction &IGF,
2695
- SILFunction &Fn,
2696
- Explosion &in,
2664
+ void irgen::emitPolymorphicParameters (IRGenFunction &IGF, SILFunction &Fn,
2665
+ EntryPointArgumentEmission &emission,
2697
2666
WitnessMetadata *witnessMetadata,
2698
2667
const GetParameterFn &getParameter) {
2699
- EmitPolymorphicParameters (IGF, Fn).emit (in, witnessMetadata, getParameter);
2668
+ EmitPolymorphicParameters (IGF, Fn).emit (emission, witnessMetadata,
2669
+ getParameter);
2700
2670
}
2701
2671
2702
2672
// / Given an array of polymorphic arguments as might be set up by
0 commit comments