[sgen] Transition to GC Unsafe in mono_gc_wait_for_bridge_processing (#55681)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Thu, 15 Jul 2021 03:12:52 +0000 (23:12 -0400)
committerGitHub <noreply@github.com>
Thu, 15 Jul 2021 03:12:52 +0000 (23:12 -0400)
* [sgen] Transition to GC Unsafe in mono_gc_wait_for_bridge_processing

Mark it as an external only API.  In the runtime, use
mono_gc_wait_for_bridge_processing_internal.

src/mono/mono/metadata/sgen-bridge.c
src/mono/mono/metadata/sgen-bridge.h
src/mono/mono/metadata/sgen-client-mono.h
src/mono/mono/metadata/sgen-mono.c

index 18aa1c2c5a3a127acf7859ab6df5f6e368fe71ea..35146dd2d2e67d2e307b6bef637bd9696f8608e3 100644 (file)
@@ -54,6 +54,14 @@ volatile gboolean mono_bridge_processing_in_progress = FALSE;
  */
 void
 mono_gc_wait_for_bridge_processing (void)
+{
+       MONO_ENTER_GC_UNSAFE;
+       mono_gc_wait_for_bridge_processing_internal ();
+       MONO_EXIT_GC_UNSAFE;
+}
+
+void
+mono_gc_wait_for_bridge_processing_internal (void)
 {
        if (!mono_bridge_processing_in_progress)
                return;
@@ -738,6 +746,11 @@ mono_gc_wait_for_bridge_processing (void)
 {
 }
 
+void
+mono_gc_wait_for_bridge_processing_internal (void)
+{
+}
+
 MonoGCBridgeObjectKind
 sgen_bridge_class_kind (MonoClass *klass)
 {
index c131f3066914e0c334f3a7bbb7f947f307bd1aca..3f11c11bcb09f335c464d97e41e4eb16e7b679cb 100644 (file)
@@ -103,7 +103,7 @@ typedef struct {
  */
 MONO_API void mono_gc_register_bridge_callbacks (MonoGCBridgeCallbacks *callbacks);
 
-MONO_API void mono_gc_wait_for_bridge_processing (void);
+MONO_API MONO_RT_EXTERNAL_ONLY void mono_gc_wait_for_bridge_processing (void);
 
 MONO_END_DECLS
 
index 211d9ed554984287058bb65dff8a77548588d8a7..f69e05904f6df481021488aca2b95a685e5f357f 100644 (file)
@@ -250,10 +250,13 @@ sgen_client_bridge_processing_stw_step (void)
        sgen_bridge_processing_stw_step ();
 }
 
+void
+mono_gc_wait_for_bridge_processing_internal (void);
+
 static void G_GNUC_UNUSED
 sgen_client_bridge_wait_for_processing (void)
 {
-       mono_gc_wait_for_bridge_processing ();
+       mono_gc_wait_for_bridge_processing_internal ();
 }
 
 static void G_GNUC_UNUSED
index ff3bca77b8cd6db3643e789b9ca1f6799edd5877..c04e5dba6a57f6edf878729b04a5af3ad937ce87 100644 (file)
@@ -2848,7 +2848,7 @@ sgen_client_ensure_weak_gchandles_accessible (void)
         * should wait for bridge processing but would fail to do so.
         */
        if (G_UNLIKELY (mono_bridge_processing_in_progress))
-               mono_gc_wait_for_bridge_processing ();
+               mono_gc_wait_for_bridge_processing_internal ();
 }
 
 void*