Skip to content

Commit 150d896

Browse files
committed
[coop] Remove support for invoke thunk wrapper
The support will be broken when we will introduce MonoHandle, as we can't pass the exception naked object ref around, but need to wrap it in a MonoHandle, while still in RUNNING mode.
1 parent 13a64c5 commit 150d896

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,6 +3595,8 @@ AC_ARG_WITH(cooperative_gc, [ --with-cooperative-gc=yes|no Enable cooperat
35953595
fi
35963596
], [with_cooperative_gc=no])
35973597

3598+
AM_CONDITIONAL([ENABLE_COOP], [test x$with_cooperative_gc != xno])
3599+
35983600
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread],[
35993601
36003602
if test x$enable_checked_build != x ; then

mono/metadata/marshal.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11692,10 +11692,12 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
1169211692
GHashTable *cache;
1169311693
MonoMethod *res;
1169411694
int i, param_count, sig_size, pos_leave;
11695-
int coop_gc_var, coop_gc_dummy_local;
1169611695

1169711696
g_assert (method);
1169811697

11698+
// FIXME: we need to store the exception into a MonoHandle
11699+
g_assert (!mono_threads_is_coop_enabled ());
11700+
1169911701
klass = method->klass;
1170011702
image = method->klass->image;
1170111703

@@ -11745,26 +11747,11 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
1174511747
if (!MONO_TYPE_IS_VOID (sig->ret))
1174611748
mono_mb_add_local (mb, sig->ret);
1174711749

11748-
if (mono_threads_is_coop_enabled ()) {
11749-
/* local 4, the local to be used when calling the reset_blocking funcs */
11750-
/* tons of code hardcode 3 to be the return var */
11751-
coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
11752-
/* local 5, the local used to get a stack address for suspend funcs */
11753-
coop_gc_dummy_local = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
11754-
}
11755-
1175611750
/* clear exception arg */
1175711751
mono_mb_emit_ldarg (mb, param_count - 1);
1175811752
mono_mb_emit_byte (mb, CEE_LDNULL);
1175911753
mono_mb_emit_byte (mb, CEE_STIND_REF);
1176011754

11761-
if (mono_threads_is_coop_enabled ()) {
11762-
/* FIXME this is technically wrong as the callback itself must be executed in gc unsafe context. */
11763-
mono_mb_emit_ldloc_addr (mb, coop_gc_dummy_local);
11764-
mono_mb_emit_icall (mb, mono_threads_reset_blocking_start);
11765-
mono_mb_emit_stloc (mb, coop_gc_var);
11766-
}
11767-
1176811755
/* try */
1176911756
clause = (MonoExceptionClause *)mono_image_alloc0 (image, sizeof (MonoExceptionClause));
1177011757
clause->try_offset = mono_mb_get_label (mb);
@@ -11834,13 +11821,6 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
1183411821
mono_mb_emit_op (mb, CEE_BOX, mono_class_from_mono_type (sig->ret));
1183511822
}
1183611823

11837-
if (mono_threads_is_coop_enabled ()) {
11838-
/* XXX merge reset_blocking_end with detach */
11839-
mono_mb_emit_ldloc (mb, coop_gc_var);
11840-
mono_mb_emit_ldloc_addr (mb, coop_gc_dummy_local);
11841-
mono_mb_emit_icall (mb, mono_threads_reset_blocking_end);
11842-
}
11843-
1184411824
mono_mb_emit_byte (mb, CEE_RET);
1184511825
#endif
1184611826

mono/metadata/object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,6 +3115,8 @@ mono_method_get_unmanaged_thunk (MonoMethod *method)
31153115

31163116
gpointer res;
31173117

3118+
g_assert (!mono_threads_is_coop_enabled ());
3119+
31183120
MONO_PREPARE_RESET_BLOCKING;
31193121
method = mono_marshal_get_thunk_invoke_wrapper (method);
31203122
res = mono_compile_method (method);

mono/tests/Makefile.am

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,12 @@ endif
585585

586586
endif
587587

588+
if ENABLE_COOP
589+
COOP_DISABLED_TESTS= thunks.exe
590+
else
591+
COOP_DISABLED_TESTS=
592+
endif
593+
588594
# The two finalizer tests only work under sgen
589595
# gc-altstack.exe fails under boehm because it has no support for altstack
590596
# bug-459094.exe creates an extremely deep directory tree
@@ -598,7 +604,8 @@ DISABLED_TESTS= \
598604
delegate-invoke.exe \
599605
bug-Xamarin-5278.exe \
600606
$(PLATFORM_DISABLED_TESTS) \
601-
$(EXTRA_DISABLED_TESTS)
607+
$(EXTRA_DISABLED_TESTS) \
608+
$(COOP_DISABLED_TESTS)
602609

603610
DISABLED_TESTS_WRENCH= \
604611
$(DISABLED_TESTS) \

0 commit comments

Comments
 (0)