@@ -3176,6 +3176,21 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
3176
3176
/* Copy the args saved in the trampoline to the frame stack */
3177
3177
gpointer retp = mono_arch_get_native_call_context_args (ccontext , & frame , sig , call_info );
3178
3178
3179
+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3180
+ int swift_error_arg_index = -1 ;
3181
+ gpointer swift_error_data ;
3182
+ gpointer * swift_error_pointer ;
3183
+ if (mono_method_signature_has_ext_callconv (sig , MONO_EXT_CALLCONV_SWIFTCALL )) {
3184
+ swift_error_data = mono_arch_get_swift_error (ccontext , sig , & swift_error_arg_index );
3185
+
3186
+ int swift_error_offset = frame .imethod -> swift_error_offset ;
3187
+ if (swift_error_offset >= 0 ) {
3188
+ swift_error_pointer = (gpointer * )((guchar * )frame .stack + swift_error_offset );
3189
+ * swift_error_pointer = * (gpointer * )swift_error_data ;
3190
+ }
3191
+ }
3192
+ #endif
3193
+
3179
3194
/* Allocate storage for value types */
3180
3195
stackval * newsp = sp ;
3181
3196
/* FIXME we should reuse computation on imethod for this */
@@ -3195,6 +3210,10 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
3195
3210
} else {
3196
3211
size = MINT_STACK_SLOT_SIZE ;
3197
3212
}
3213
+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3214
+ if (swift_error_arg_index >= 0 && swift_error_arg_index == i )
3215
+ newsp -> data .p = swift_error_pointer ;
3216
+ #endif
3198
3217
newsp = STACK_ADD_BYTES (newsp , size );
3199
3218
}
3200
3219
newsp = (stackval * )ALIGN_TO (newsp , MINT_STACK_ALIGNMENT );
@@ -3205,6 +3224,11 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
3205
3224
mono_interp_exec_method (& frame , context , NULL );
3206
3225
MONO_EXIT_GC_UNSAFE ;
3207
3226
3227
+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3228
+ if (swift_error_arg_index >= 0 )
3229
+ * (gpointer * )swift_error_data = * (gpointer * )swift_error_pointer ;
3230
+ #endif
3231
+
3208
3232
context -> stack_pointer = (guchar * )sp ;
3209
3233
g_assert (!context -> has_resume_state );
3210
3234
@@ -3467,9 +3491,16 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e
3467
3491
* separate temp register. We should update the wrappers for this
3468
3492
* if we really care about those architectures (arm).
3469
3493
*/
3470
- MonoMethod * wrapper = mini_get_interp_in_wrapper (sig );
3471
3494
3472
- entry_wrapper = mono_jit_compile_method_jit_only (wrapper , error );
3495
+ MonoMethod * wrapper = NULL ;
3496
+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3497
+ /* Methods with Swift cconv should go to trampoline */
3498
+ if (!mono_method_signature_has_ext_callconv (sig , MONO_EXT_CALLCONV_SWIFTCALL ))
3499
+ #endif
3500
+ {
3501
+ wrapper = mini_get_interp_in_wrapper (sig );
3502
+ entry_wrapper = mono_jit_compile_method_jit_only (wrapper , error );
3503
+ }
3473
3504
#endif
3474
3505
if (!entry_wrapper ) {
3475
3506
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
0 commit comments