[checked] Nest MONO_{PREPARE,FINISH}_GC_CRITICAL_REGION
authorAleksey Kliger <aleksey@xamarin.com>
Mon, 4 Jan 2016 16:26:55 +0000 (11:26 -0500)
committerAleksey Kliger <aleksey@xamarin.com>
Thu, 14 Jan 2016 16:38:15 +0000 (11:38 -0500)
mono/utils/checked-build.c
mono/utils/checked-build.h

index 5c4fd4249e9acd79cd6635d5a0bd82504be451f2..dfe9880e560f869e3a9a0d8389801b6f33b85ec2 100644 (file)
@@ -81,7 +81,7 @@ translate_backtrace (gpointer native_trace[], int size)
 
 typedef struct {
        GPtrArray *transitions;
-       gboolean in_gc_critical_region;
+       guint32 in_gc_critical_region;
 } CheckState;
 
 typedef struct {
@@ -235,7 +235,7 @@ void *
 critical_gc_region_begin(void)
 {
        CheckState *state = get_state ();
-       state->in_gc_critical_region = TRUE;
+       state->in_gc_critical_region++;
        return state;
 }
 
@@ -245,14 +245,14 @@ critical_gc_region_end(void* token)
 {
        CheckState *state = get_state();
        g_assert (state == token);
-       state->in_gc_critical_region = FALSE;
+       state->in_gc_critical_region--;
 }
 
 void
 assert_not_in_gc_critical_region(void)
 {
        CheckState *state = get_state();
-       if (state->in_gc_critical_region) {
+       if (state->in_gc_critical_region > 0) {
                MonoThreadInfo *cur = mono_thread_info_current();
                state = mono_thread_info_current_state(cur);
                assertion_fail("Expected GC Unsafe mode, but was in %s state", mono_thread_state_name(state));
index 83efd67c054899a2865326e8d65fb9a0b35e34d4..092ed1d3016ef7dd0d4685828a0bab7fc06b647c 100644 (file)
@@ -83,7 +83,7 @@ Functions that can be called from both coop or preept modes.
  * The GC critical region must only occur in unsafe mode.
  */
 #define MONO_PREPARE_GC_CRITICAL_REGION                                        \
-       MON_REQ_GC_UNSAFE_MODE                                          \
+       MONO_REQ_GC_UNSAFE_MODE                                         \
        do {                                                            \
                void* __critical_gc_region_cookie = critical_gc_region_begin()