@@ -2987,6 +2987,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
2987
2987
}
2988
2988
}
2989
2989
2990
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
2990
2991
auto genericSig =
2991
2992
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
2992
2993
: nullptr ;
@@ -2995,6 +2996,14 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
2995
2996
genericEnv = nullptr ;
2996
2997
}
2997
2998
2999
+ // Add empty generic type parameter to match function signature on WebAssembly
3000
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3001
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3002
+ auto sig = GenericSignature::get (param, { });
3003
+ genericSig = CanGenericSignature (sig);
3004
+ genericEnv = sig.getGenericEnvironment ();
3005
+ }
3006
+
2998
3007
// Build the signature of the thunk as expected by the keypath runtime.
2999
3008
auto signature = [&]() {
3000
3009
CanType loweredBaseTy, loweredPropTy;
@@ -3010,7 +3019,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3010
3019
SmallVector<SILParameterInfo, 2 > params;
3011
3020
params.push_back ({loweredBaseTy, paramConvention});
3012
3021
auto &C = SGM.getASTContext ();
3013
- if (!indexes.empty ())
3022
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3023
+ if (!indexes.empty () || C.LangOpts .Target .isOSBinFormatWasm ())
3014
3024
params.push_back ({C.getUnsafeRawPointerType ()->getCanonicalType (),
3015
3025
ParameterConvention::Direct_Unowned});
3016
3026
@@ -3070,7 +3080,8 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
3070
3080
}
3071
3081
auto baseArg = entry->createFunctionArgument (baseArgTy);
3072
3082
SILValue indexPtrArg;
3073
- if (!indexes.empty ()) {
3083
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3084
+ if (!indexes.empty () || Target.isOSBinFormatWasm ()) {
3074
3085
auto indexArgTy =
3075
3086
subSGF.silConv .getSILType (signature->getParameters ()[1 ], signature,
3076
3087
subSGF.F .getTypeExpansionContext ());
@@ -3160,6 +3171,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3160
3171
}
3161
3172
}
3162
3173
3174
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
3163
3175
auto genericSig =
3164
3176
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
3165
3177
: nullptr ;
@@ -3168,6 +3180,14 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3168
3180
genericEnv = nullptr ;
3169
3181
}
3170
3182
3183
+ // Add empty generic type parameter to match function signature on WebAssembly
3184
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3185
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3186
+ auto sig = GenericSignature::get (param, { });
3187
+ genericSig = CanGenericSignature (sig);
3188
+ genericEnv = sig.getGenericEnvironment ();
3189
+ }
3190
+
3171
3191
// Build the signature of the thunk as expected by the keypath runtime.
3172
3192
auto signature = [&]() {
3173
3193
CanType loweredBaseTy, loweredPropTy;
@@ -3193,7 +3213,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3193
3213
? ParameterConvention::Indirect_Inout
3194
3214
: paramConvention});
3195
3215
// indexes
3196
- if (!indexes.empty ())
3216
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3217
+ if (!indexes.empty () || C.LangOpts .Target .isOSBinFormatWasm ())
3197
3218
params.push_back ({C.getUnsafeRawPointerType ()->getCanonicalType (),
3198
3219
ParameterConvention::Direct_Unowned});
3199
3220
@@ -3249,7 +3270,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
3249
3270
auto baseArg = entry->createFunctionArgument (baseArgTy);
3250
3271
SILValue indexPtrArg;
3251
3272
3252
- if (!indexes.empty ()) {
3273
+ // Always take indexes parameter to match callee and caller signature on WebAssembly
3274
+ if (!indexes.empty () || Target.isOSBinFormatWasm ()) {
3253
3275
auto indexArgTy =
3254
3276
subSGF.silConv .getSILType (signature->getParameters ()[2 ], signature,
3255
3277
subSGF.getTypeExpansionContext ());
@@ -3342,6 +3364,7 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
3342
3364
return ;
3343
3365
}
3344
3366
3367
+ auto Target = SGM.getASTContext ().LangOpts .Target ;
3345
3368
auto genericSig =
3346
3369
genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
3347
3370
: nullptr ;
@@ -3351,6 +3374,14 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
3351
3374
genericEnv = nullptr ;
3352
3375
}
3353
3376
3377
+ // Add empty generic type parameter to match function signature on WebAssembly
3378
+ if (!genericSig && Target.isOSBinFormatWasm ()) {
3379
+ auto param = GenericTypeParamType::get (false , 0 , 0 , SGM.getASTContext ());
3380
+ auto sig = GenericSignature::get (param, { });
3381
+ genericSig = CanGenericSignature (sig);
3382
+ genericEnv = sig.getGenericEnvironment ();
3383
+ }
3384
+
3354
3385
auto &C = SGM.getASTContext ();
3355
3386
auto unsafeRawPointerTy = C.getUnsafeRawPointerType ()->getCanonicalType ();
3356
3387
auto boolTy = C.getBoolType ()->getCanonicalType ();
0 commit comments