Change some GC defines to runtime checks in metadata/.
authorZoltan Varga <vargaz@gmail.com>
Sat, 16 Jun 2012 18:48:57 +0000 (20:48 +0200)
committerZoltan Varga <vargaz@gmail.com>
Sat, 16 Jun 2012 18:49:09 +0000 (20:49 +0200)
mono/metadata/boehm-gc.c
mono/metadata/gc-internal.h
mono/metadata/null-gc.c
mono/metadata/sgen-gc.c
mono/metadata/string-icalls.c
mono/metadata/threads.c

index 2799dffb9a56285e315c3a3d203e9d93d71a702e..67561c6a0aeb331a4dd0fb085d5bc05514f495ca 100644 (file)
@@ -1296,4 +1296,23 @@ mono_gc_register_altstack (gpointer stack, gint32 stack_size, gpointer altstack,
 #endif
 }
 
+int
+mono_gc_get_los_limit (void)
+{
+       return G_MAXINT;
+}
+
+gboolean
+mono_gc_user_markers_supported (void)
+{
+       return FALSE;
+}
+
+void *
+mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
 #endif /* no Boehm GC */
index e3a4cbf682715be2bb4d9854591ccb5441cfd13f..0974ba2e8620bccbf6b7d073c2c29db3617a2ca5 100644 (file)
@@ -157,6 +157,9 @@ typedef void (*MonoGCRootMarkFunc) (void *addr, MonoGCMarkFunc mark_func);
 /* Create a descriptor with a user defined marking function */
 void *mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker);
 
+/* Return whenever user defined marking functions are supported */
+gboolean mono_gc_user_markers_supported (void) MONO_INTERNAL;
+
 /* desc is the result from mono_gc_make_descr*. A NULL value means
  * all the words might contain GC pointers.
  * The memory is non-moving and it will be explicitly deallocated.
index 26856e0c41c8f325f4894bab5199c6f3359bfbc7..0500aa10792aa3beb9e4c91f49abe9c9067c05a2 100644 (file)
@@ -388,6 +388,25 @@ mono_gc_set_stack_end (void *stack_end)
 {
 }
 
+int
+mono_gc_get_los_limit (void)
+{
+       return G_MAXINT;
+}
+
+gboolean
+mono_gc_user_markers_supported (void)
+{
+       return FALSE;
+}
+
+void *
+mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
 #ifndef HOST_WIN32
 
 int
index a4b3260aea34a550689dff5a6ec5053073bd3720..9af442a6223d2e36a3e5d109c1c7846baec91c1b 100644 (file)
@@ -4611,6 +4611,12 @@ mono_gc_get_los_limit (void)
        return MAX_SMALL_OBJ_SIZE;
 }
 
+gboolean
+mono_gc_user_markers_supported (void)
+{
+       return TRUE;
+}
+
 gboolean
 mono_object_is_alive (MonoObject* o)
 {
index b0eeb32585b15e4c2880499ee691b79deb6dec55..0927141e7925f92d753c6579aa0905c816131f22 100644 (file)
@@ -63,11 +63,7 @@ ves_icall_System_String_InternalIsInterned (MonoString *str)
 int
 ves_icall_System_String_GetLOSLimit (void)
 {
-#ifdef HAVE_SGEN_GC
        int limit = mono_gc_get_los_limit ();
 
        return (limit - 2 - sizeof (MonoString)) / 2;
-#else
-       return G_MAXINT;
-#endif
 }
index b2f2db1eabd93ea79b156e11b28812181bf9a552..f01f5a97cbb9f867bff5737ade0b41da9f30efe9 100644 (file)
@@ -614,12 +614,10 @@ static guint32 WINAPI start_wrapper_internal(void *data)
 
 static guint32 WINAPI start_wrapper(void *data)
 {
-#ifdef HAVE_SGEN_GC
        volatile int dummy;
 
        /* Avoid scanning the frames above this frame during a GC */
        mono_gc_set_stack_end ((void*)&dummy);
-#endif
 
        return start_wrapper_internal (data);
 }
@@ -3516,7 +3514,6 @@ static const int static_data_size [NUM_STATIC_DATA_IDX] = {
 
 static uintptr_t* static_reference_bitmaps [NUM_STATIC_DATA_IDX];
 
-#ifdef HAVE_SGEN_GC
 static void
 mark_tls_slots (void *addr, MonoGCMarkFunc mark_func)
 {
@@ -3542,7 +3539,6 @@ mark_tls_slots (void *addr, MonoGCMarkFunc mark_func)
                }
        }
 }
-#endif
 
 /*
  *  mono_alloc_static_data
@@ -3558,10 +3554,8 @@ mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, gboolean thr
        gpointer* static_data = *static_data_ptr;
        if (!static_data) {
                static void* tls_desc = NULL;
-#ifdef HAVE_SGEN_GC
-               if (!tls_desc)
+               if (mono_gc_user_markers_supported () && !tls_desc)
                        tls_desc = mono_gc_make_root_descr_user (mark_tls_slots);
-#endif
                static_data = mono_gc_alloc_fixed (static_data_size [0], threadlocal?tls_desc:NULL);
                *static_data_ptr = static_data;
                static_data [0] = static_data;
@@ -3570,11 +3564,10 @@ mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, gboolean thr
        for (i = 1; i <= idx; ++i) {
                if (static_data [i])
                        continue;
-#ifdef HAVE_SGEN_GC
-               static_data [i] = threadlocal?g_malloc0 (static_data_size [i]):mono_gc_alloc_fixed (static_data_size [i], NULL);
-#else
-               static_data [i] = mono_gc_alloc_fixed (static_data_size [i], NULL);
-#endif
+               if (mono_gc_user_markers_supported () && threadlocal)
+                       static_data [i] = g_malloc0 (static_data_size [i]);
+               else
+                       static_data [i] = mono_gc_alloc_fixed (static_data_size [i], NULL);
        }
 }
 
@@ -3585,14 +3578,10 @@ mono_free_static_data (gpointer* static_data, gboolean threadlocal)
        for (i = 1; i < NUM_STATIC_DATA_IDX; ++i) {
                if (!static_data [i])
                        continue;
-#ifdef HAVE_SGEN_GC
-               if (threadlocal)
+               if (mono_gc_user_markers_supported () && threadlocal)
                        g_free (static_data [i]);
                else
                        mono_gc_free_fixed (static_data [i]);
-#else
-               mono_gc_free_fixed (static_data [i]);
-#endif
        }
        mono_gc_free_fixed (static_data);
 }