[coop] Switch SGen gc_mutex to coop implementation
authorLudovic Henry <ludovic@xamarin.com>
Mon, 16 Nov 2015 16:53:40 +0000 (16:53 +0000)
committerLudovic Henry <ludovic@xamarin.com>
Thu, 19 Nov 2015 18:30:19 +0000 (18:30 +0000)
mono/metadata/gc.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h

index 3ad75204ae881ac218bd5822f204992f07eeae1b..7f1ce3492e9138059ce8ecf73adcac9ca57c8a1f 100644 (file)
@@ -335,11 +335,8 @@ object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*))
         * end up running them while or after the domain is being cleared, so
         * the objects will not be valid anymore.
         */
-       if (!mono_domain_is_unloading (domain)) {
-               MONO_TRY_BLOCKING;
+       if (!mono_domain_is_unloading (domain))
                mono_gc_register_for_finalization (obj, callback);
-               MONO_FINISH_TRY_BLOCKING;
-       }
 #endif
 }
 
index a5d14f783192b4fb9a9bd65f2dd0d1507d58e0c0..07af36570d1bf237f550e1961c6652ebfcfec1d3 100644 (file)
@@ -346,7 +346,7 @@ nursery_canaries_enabled (void)
  * ########  Global data.
  * ######################################################################
  */
-LOCK_DECLARE (gc_mutex);
+MonoCoopMutex gc_mutex;
 gboolean sgen_try_free_some_memory;
 
 #define SCAN_START_SIZE        SGEN_SCAN_START_SIZE
@@ -2807,7 +2807,7 @@ sgen_gc_init (void)
        mono_thread_smr_init ();
 #endif
 
-       LOCK_INIT (gc_mutex);
+       mono_coop_mutex_init (&gc_mutex);
 
        gc_debug_file = stderr;
 
@@ -3191,9 +3191,7 @@ sgen_get_nursery_clear_policy (void)
 void
 sgen_gc_lock (void)
 {
-       MONO_TRY_BLOCKING;
-       mono_os_mutex_lock (&gc_mutex);
-       MONO_FINISH_TRY_BLOCKING;
+       mono_coop_mutex_lock (&gc_mutex);
 }
 
 void
@@ -3201,7 +3199,7 @@ sgen_gc_unlock (void)
 {
        gboolean try_free = sgen_try_free_some_memory;
        sgen_try_free_some_memory = FALSE;
-       mono_os_mutex_unlock (&gc_mutex);
+       mono_coop_mutex_unlock (&gc_mutex);
        if (try_free)
                mono_thread_hazardous_try_free_some ();
 }
index d54253b2e9bca7538675f88b958670b8b0a89e72..d7a42ce91ee09289922fb81f8de69371cb7cb82e 100644 (file)
@@ -962,7 +962,7 @@ extern guint32 tlab_size;
 extern NurseryClearPolicy nursery_clear_policy;
 extern gboolean sgen_try_free_some_memory;
 
-extern LOCK_DECLARE (gc_mutex);
+extern MonoCoopMutex gc_mutex;
 
 /* Nursery helpers. */