@@ -3176,6 +3176,20 @@ 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
+ }
3190
+ }
3191
+ #endif
3192
+
3179
3193
/* Allocate storage for value types */
3180
3194
stackval * newsp = sp ;
3181
3195
/* FIXME we should reuse computation on imethod for this */
@@ -3195,6 +3209,11 @@ interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untype
3195
3209
} else {
3196
3210
size = MINT_STACK_SLOT_SIZE ;
3197
3211
}
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
3198
3217
newsp = STACK_ADD_BYTES (newsp , size );
3199
3218
}
3200
3219
newsp = (stackval * )ALIGN_TO (newsp , MINT_STACK_ALIGNMENT );
@@ -3205,6 +3224,12 @@ 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
+ }
3231
+ #endif
3232
+
3208
3233
context -> stack_pointer = (guchar * )sp ;
3209
3234
g_assert (!context -> has_resume_state );
3210
3235
@@ -3459,7 +3484,7 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e
3459
3484
return (gpointer )no_llvmonly_interp_method_pointer ;
3460
3485
}
3461
3486
3462
- #ifndef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
3487
+ #if !defined( MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE ) && !defined( MONO_ARCH_HAVE_SWIFTCALL )
3463
3488
/*
3464
3489
* Interp in wrappers get the argument in the rgctx register. If
3465
3490
* MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE is defined it means that
0 commit comments