[m-dev.] diff: split out GC initialization code for use by MLDS back-end

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Mar 9 19:36:08 AEDT 2000


Estimated hours taken: 0.5

runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
	Split the code to initialize the conservative
	garbage collector out into a separate function,
	for use by the --high-level-code back-end.

Workspace: /d-drive/home/hg/fjh/mercury
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.54
diff -u -d -r1.54 mercury_wrapper.c
--- runtime/mercury_wrapper.c	2000/02/08 02:08:06	1.54
+++ runtime/mercury_wrapper.c	2000/03/09 08:32:37
@@ -248,37 +248,7 @@
 #endif
 
 #ifdef CONSERVATIVE_GC
-	GC_quiet = TRUE;
-
-	/*
-	** Call GC_INIT() to tell the garbage collector about this DLL.
-	** (This is necessary to support Windows DLLs using gnu-win32.)
-	*/
-	GC_INIT();
-
-	/*
-	** call the init_gc() function defined in <foo>_init.c,
-	** which calls GC_INIT() to tell the GC about the main program.
-	** (This is to work around a Solaris 2.X (X <= 4) linker bug,
-	** and also to support Windows DLLs using gnu-win32.)
-	*/
-	(*address_of_init_gc)();
-
-	/*
-	** Double-check that the garbage collector knows about
-	** global variables in shared libraries.
-	*/
-	GC_is_visible(&MR_runqueue_head);
-
-	/* The following code is necessary to tell the conservative */
-	/* garbage collector that we are using tagged pointers */
-	{
-		int i;
-
-		for (i = 1; i < (1 << TAGBITS); i++) {
-			GC_REGISTER_DISPLACEMENT(i);
-		}
-	}
+	MR_init_conservative_GC();
 #endif
 
 	/*
@@ -354,6 +324,44 @@
 
 } /* end runtime_mercury_init() */
 
+#ifdef CONSERVATIVE_GC
+void
+MR_init_conservative_GC(void)
+{
+	GC_quiet = TRUE;
+
+	/*
+	** Call GC_INIT() to tell the garbage collector about this DLL.
+	** (This is necessary to support Windows DLLs using gnu-win32.)
+	*/
+	GC_INIT();
+
+	/*
+	** call the init_gc() function defined in <foo>_init.c,
+	** which calls GC_INIT() to tell the GC about the main program.
+	** (This is to work around a Solaris 2.X (X <= 4) linker bug,
+	** and also to support Windows DLLs using gnu-win32.)
+	*/
+	(*address_of_init_gc)();
+
+	/*
+	** Double-check that the garbage collector knows about
+	** global variables in shared libraries.
+	*/
+	GC_is_visible(&MR_runqueue_head);
+
+	/* The following code is necessary to tell the conservative */
+	/* garbage collector that we are using tagged pointers */
+	{
+		int i;
+
+		for (i = 1; i < (1 << TAGBITS); i++) {
+			GC_REGISTER_DISPLACEMENT(i);
+		}
+	}
+}
+#endif /* CONSERVATIVE_GC */
+
 void 
 do_init_modules(void)
 {
@@ -698,9 +706,9 @@
 				MR_gotodebug    = TRUE;
 			else if (streq(MR_optarg, "G"))
 #ifdef CONSERVATIVE_GC
-			GC_quiet = FALSE;
+				GC_quiet = FALSE;
 #else
-			; /* ignore inapplicable option */
+				; /* ignore inapplicable option */
 #endif
 			else if (streq(MR_optarg, "h"))
 				MR_heapdebug    = TRUE;
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.28
diff -u -d -r1.28 mercury_wrapper.h
--- runtime/mercury_wrapper.h	2000/02/08 02:08:07	1.28
+++ runtime/mercury_wrapper.h	2000/03/09 08:35:00
@@ -47,6 +47,17 @@
 extern	int	MR_load_aditi_rl_code(void);
 
 /*
+** MR_init_conservative_GC() initializes the Boehm (et al)
+** conservative collector.  For the LLDS back-end, it is normally
+** called from mercury_runtime_init(), but for the MLDS
+** (--high-level-code) back-end, it may be called directly
+** from main().
+*/
+#ifdef CONSERVATIVE_GC
+  extern void	MR_init_conservative_GC(void);
+#endif
+
+/*
 ** The following global variables are set by mercury_init() on startup.
 ** The entry points are set based on the options to mkinit.c.
 ** The address_of_foo pointers are set to the address of

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list