typedef struct {
GPtrArray *transitions;
- gboolean in_gc_critical_region;
+ guint32 in_gc_critical_region;
} CheckState;
typedef struct {
critical_gc_region_begin(void)
{
CheckState *state = get_state ();
- state->in_gc_critical_region = TRUE;
+ state->in_gc_critical_region++;
return state;
}
{
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) {
- 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));
+ if (state->in_gc_critical_region > 0) {
+ assertion_fail("Expected GC Unsafe mode, but was in %s state", mono_thread_state_name (mono_thread_info_current_state (mono_thread_info_current ())));
}
}
+void
+assert_in_gc_critical_region (void)
+{
+ CheckState *state = get_state();
+ if (state->in_gc_critical_region == 0)
+ assertion_fail("Expected GC critical region");
+}
+
// check_metadata_store et al: The goal of these functions is to verify that if there is a pointer from one mempool into
// another, that the pointed-to memory is protected by the reference count mechanism for MonoImages.
//