@@ -3176,6 +3176,21 @@ 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+ * swift_error_pointer = * (gpointer * )swift_error_data ;
3190+ }
3191+ }
3192+ #endif
3193+
31793194 /* Allocate storage for value types */
31803195 stackval * newsp = sp ;
31813196 /* FIXME we should reuse computation on imethod for this */
@@ -3195,6 +3210,10 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
31953210 } else {
31963211 size = MINT_STACK_SLOT_SIZE ;
31973212 }
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
31983217 newsp = STACK_ADD_BYTES (newsp , size );
31993218 }
32003219 newsp = (stackval * )ALIGN_TO (newsp , MINT_STACK_ALIGNMENT );
@@ -3205,6 +3224,11 @@ 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+ #endif
3231+
32083232 context -> stack_pointer = (guchar * )sp ;
32093233 g_assert (!context -> has_resume_state );
32103234
@@ -3467,9 +3491,16 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e
34673491 * separate temp register. We should update the wrappers for this
34683492 * if we really care about those architectures (arm).
34693493 */
3470- MonoMethod * wrapper = mini_get_interp_in_wrapper (sig );
34713494
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+ }
34733504#endif
34743505 if (!entry_wrapper ) {
34753506#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
0 commit comments