@@ -3176,6 +3176,20 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
31763176 /* Copy the args saved in the trampoline to the frame stack */
31773177 gpointer retp = mono_arch_get_native_call_context_args (ccontext , & frame , sig , call_info );
31783178
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+ }
3190+ }
3191+ #endif
3192+
31793193 /* Allocate storage for value types */
31803194 stackval * newsp = sp ;
31813195 /* FIXME we should reuse computation on imethod for this */
@@ -3195,6 +3209,11 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
31953209 } else {
31963210 size = MINT_STACK_SLOT_SIZE ;
31973211 }
3212+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3213+ if (swift_error_arg_index >= 0 && swift_error_arg_index == i ) {
3214+ newsp -> data .p = swift_error_pointer ;
3215+ }
3216+ #endif
31983217 newsp = STACK_ADD_BYTES (newsp , size );
31993218 }
32003219 newsp = (stackval * )ALIGN_TO (newsp , MINT_STACK_ALIGNMENT );
@@ -3205,6 +3224,12 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
32053224 mono_interp_exec_method (& frame , context , NULL );
32063225 MONO_EXIT_GC_UNSAFE ;
32073226
3227+ #ifdef MONO_ARCH_HAVE_SWIFTCALL
3228+ if (swift_error_arg_index >= 0 ) {
3229+ * (gpointer * )swift_error_data = * (gpointer * )swift_error_pointer ;
3230+ }
3231+ #endif
3232+
32083233 context -> stack_pointer = (guchar * )sp ;
32093234 g_assert (!context -> has_resume_state );
32103235
@@ -3459,7 +3484,7 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e
34593484 return (gpointer )no_llvmonly_interp_method_pointer ;
34603485 }
34613486
3462- #ifndef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
3487+ #if !defined( MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE ) && !defined( MONO_ARCH_HAVE_SWIFTCALL )
34633488 /*
34643489 * Interp in wrappers get the argument in the rgctx register. If
34653490 * MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE is defined it means that
0 commit comments