[coop] The magic trampoline might be called from BLOCKING state
authorLudovic Henry <ludovic@xamarin.com>
Fri, 13 May 2016 14:56:47 +0000 (10:56 -0400)
committerLudovic Henry <ludovic@xamarin.com>
Mon, 16 May 2016 14:57:02 +0000 (10:57 -0400)
mono/mini/jit-icalls.h
mono/mini/mini-trampolines.c
mono/mini/mini.h
mono/utils/mono-threads-coop.h

index d6f560b8553076bf053bbd828ac48aef10b5090d..c90c5de2c596fd0226642c1ec74d683d026e4252 100644 (file)
@@ -189,8 +189,6 @@ ves_icall_runtime_class_init (MonoVTable *vtable);
 void
 mono_generic_class_init (MonoVTable *vtable);
 
-void mono_interruption_checkpoint_from_trampoline (void);
-
 MonoObject*
 mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *klass, gboolean deref_arg, gpointer *args);
 
index c464a0033a77c727829ba44f5e6acea3bba0e84c..cda972ea2586a7073fcda364a56d6df09bcf221c 100644 (file)
@@ -822,16 +822,21 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *
 gpointer
 mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
 {
-       MonoError error;
        gpointer res;
 
+       MONO_PREPARE_RESET_BLOCKING_UNBALANCED;
+
+       MonoError error;
+
        trampoline_calls ++;
 
        res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
-               return NULL;
-       }
+       mono_error_set_pending_exception (&error);
+
+       mono_interruption_checkpoint_from_trampoline ();
+
+       MONO_FINISH_RESET_BLOCKING_UNBALANCED;
+
        return res;
 }
 
index 097308b2c9142666fcd6d6a9e201bc22b585cc3d..ec6bcb6eea13bb278111e814a2eb0b31db65c45f 100644 (file)
@@ -3200,5 +3200,9 @@ gboolean MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal);
  */
 void mono_exception_native_unwind (void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info);
 
+/*
+ * Coop support for trampolines
+ */
+void mono_interruption_checkpoint_from_trampoline (void);
 
 #endif /* __MONO_MINI_H__ */
index 2f3ede958ef8b8fffb7fa0ff10d8bca689c754f7..eaf49ee57ffd33ac3f13ac63a280ce9f813ea98b 100644 (file)
@@ -95,6 +95,15 @@ mono_threads_reset_blocking_start_unbalanced (gpointer *stackdata);
 void
 mono_threads_reset_blocking_end_unbalanced (gpointer cookie, gpointer *stackdata);
 
+#define MONO_PREPARE_RESET_BLOCKING_UNBALANCED \
+       do {    \
+               gpointer __dummy;       \
+               gpointer __reset_cookie = mono_threads_reset_blocking_start_unbalanced (&__dummy)
+
+#define MONO_FINISH_RESET_BLOCKING_UNBALANCED  \
+               mono_threads_reset_blocking_end_unbalanced (__reset_cookie, &__dummy);  \
+       } while (0)
+
 G_END_DECLS
 
 #endif