@@ -174,6 +174,7 @@ typedef struct {
174174 gboolean llvm_only ;
175175 gboolean has_got_access ;
176176 gboolean emit_dummy_arg ;
177+ gboolean has_safepoints ;
177178 int this_arg_pindex , rgctx_arg_pindex ;
178179 LLVMValueRef imt_rgctx_loc ;
179180 GHashTable * llvm_types ;
@@ -3560,7 +3561,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
35603561#ifdef TARGET_WASM
35613562 // For GC stack scanning to work, have to spill all reference variables to the stack
35623563 // Some ref variables have type intptr
3563- if (MONO_TYPE_IS_REFERENCE (var -> inst_vtype ) || var -> inst_vtype -> type == MONO_TYPE_I )
3564+ if (ctx -> has_safepoints && ( MONO_TYPE_IS_REFERENCE (var -> inst_vtype ) || var -> inst_vtype -> type == MONO_TYPE_I ) )
35643565 var -> flags |= MONO_INST_INDIRECT ;
35653566#endif
35663567
@@ -8625,6 +8626,20 @@ emit_method_inner (EmitContext *ctx)
86258626 }
86268627 }
86278628 }
8629+ if (cfg -> method -> wrapper_type ) {
8630+ WrapperInfo * info = mono_marshal_get_wrapper_info (cfg -> method );
8631+
8632+ switch (info -> subtype ) {
8633+ case WRAPPER_SUBTYPE_GSHAREDVT_IN :
8634+ case WRAPPER_SUBTYPE_GSHAREDVT_OUT :
8635+ case WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG :
8636+ case WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG :
8637+ /* Arguments are not used after the call */
8638+ requires_safepoint = FALSE;
8639+ break ;
8640+ }
8641+ }
8642+ ctx -> has_safepoints = requires_safepoint ;
86288643
86298644#ifndef MONO_LLVM_LOADED
86308645 if (!cfg -> llvm_only && mono_threads_are_safepoints_enabled () && requires_safepoint ) {
0 commit comments