[m-rev.] diff: Don't disable Boehm GC during startup.

Peter Wang novalazy at gmail.com
Tue Sep 24 17:34:35 AEST 2024


I've also updated Boehm GC after this patch.
---

Don't call GC_disable() before GC_INIT(), which we did to avoid GC
during early runtime initialisation. This once had a small benefit,
but will not work after we upgrade to Boehm GC with commit 52a538ff
"Fix handling of GC_gc_no counter wrap in GC_clear_stack".

runtime/mercury_wrapper.c:
    As above.

diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index e6ba7bc4f..d4c6b2906 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -1,7 +1,7 @@
 // vim: ts=4 sw=4 expandtab ft=c
 
 // Copyright (C) 1994-2011 The University of Melbourne.
-// Copyright (C) 2014-2016, 2018, 2020-2023 The Mercury team.
+// Copyright (C) 2014-2016, 2018, 2020-2024 The Mercury team.
 // This file is distributed under the terms specified in COPYING.LIB.
 
 // file: mercury_wrapper.c
@@ -545,10 +545,6 @@ mercury_runtime_init(int argc, char **argv)
 
     MR_setup_signals();
 
-#ifdef MR_BOEHM_GC
-    // Disable GC during startup, when little or no garbage is created.
-    GC_disable();
-#endif
 #ifdef MR_CONSERVATIVE_GC
     MR_init_conservative_GC();
 #endif
@@ -672,9 +668,8 @@ mercury_runtime_init(int argc, char **argv)
 #endif // ! 0
 
 #ifdef MR_BOEHM_GC
-    // We keep GC disabled during startup. Enable it now unless forced off.
-    if (! MR_gc_disable) {
-        GC_enable();
+    if (MR_gc_disable) {
+        GC_disable();
     }
 #endif
 
-- 
2.46.0


More information about the reviews mailing list