[m-rev.] for review: add support for MPS GC

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Aug 21 21:18:47 AEST 2002


Here's a relative diff which addresses Simon's review comments
and a couple of additional problems that I discovered during testing.

With these changes, plus the changes to mps_gc that I just committed,
the compiler now bootchecks in grade hlc.mps -- though it took 12 days,
even on a 1.1GHz Athlon :-(

I will go ahead and commit these now.

--- CHANGES3.old	Wed Jul 31 10:50:43 2002
+++ CHANGES3	Wed Aug 21 21:06:09 2002
@@ -5,11 +5,25 @@
 	Include the MPS directories in the header file and library search
 	paths.
 
+tools/bootcheck:
+	Link the mps_gc directory into the stage2 and stage3 directories.
+
 Mmake.workspace:
 runtime/Mmakefile:
 scripts/ml.in:
 	For *.mps grades, link in mps.a.
 	(XXX ml.in is linking in libmps.a, which is wrong.)
+
+runtime/Mmakefile:
+trace/Mmakefile:
+	In the rule for `check_headers', which checks macro namespace
+	cleanliness, allow names to start with `MPS_' or `mps_'.
+
+runtime/RESERVED_MACRO_NAMES:
+	Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
+	for its header guard.  (Normally it would be better to use
+	uppercase for header guard macro names, but that would be
+	inconsistent with the coding style used in mps_gc/code.)
 
 scripts/canonical_grade.sh-subr:
 scripts/init_grade_options.sh-subr:

diff -u compiler/compile_target_code.m compiler/compile_target_code.m
--- compiler/compile_target_code.m
+++ compiler/compile_target_code.m
@@ -407,10 +407,10 @@
 	globals__io_get_gc_method(GC_Method),
 	{
 		GC_Method = boehm,
-		GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC"
+		GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC "
 	;
 		GC_Method = mps,
-		GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_MPS_GC"
+		GC_Opt = "-DMR_CONSERVATIVE_GC -DMR_MPS_GC "
 	;
 		GC_Method = accurate,
 		GC_Opt = "-DMR_NATIVE_GC "
diff -u compiler/mercury_compile.m compiler/mercury_compile.m
--- compiler/mercury_compile.m
+++ compiler/mercury_compile.m
@@ -170,8 +170,7 @@
 	gc_init(_IO0::di, _IO::uo),
 	[will_not_call_mercury, promise_pure, tabled_for_io],
 "
-#ifdef MR_CONSERVATIVE_GC
-  #ifndef MR_MPS_GC /* i.e. MR_BOEHM_GC */
+#ifdef MR_BOEHM_GC
 	/*
 	** Explicitly force the initial heap size to be at least 4 Mb.
 	**
@@ -184,7 +183,6 @@
 	** frequent garbage collection during start-up.
 	*/
 	GC_expand_hp(4 * 1024 * 1024);
-  #endif
 #endif
 ").
 
diff -u library/benchmarking.m library/benchmarking.m
--- library/benchmarking.m
+++ library/benchmarking.m
@@ -233,7 +233,8 @@
 			spare / 1024.0,
 			committed / 1024.0);
 	}
-  #else /* MR_BOEHM_GC */
+  #endif /* MR_MPS_GC */
+  #ifdef MR_BOEHM_GC
 	fprintf(stderr, 
 		""\\n#GCs: %lu, ""
 		""Heap used since last GC: %.3fk, Total used: %.3fk"",
@@ -247,7 +248,7 @@
 		""\\nHeap: %.3fk"",
 		((char *) MR_hp - (char *) eng->MR_eng_heap_zone->min) / 1024.0
 	);
-#endif
+#endif /* !MR_CONSERVATIVE_GC */
 
 #ifdef	MR_MPROF_PROFILE_MEMORY
 
diff -u runtime/Mmakefile runtime/Mmakefile
--- runtime/Mmakefile
+++ runtime/Mmakefile
@@ -301,8 +301,19 @@
 # and object files to make sure that they conform with our coding standards.
 #
 
+# Macro names must normally start with one of the prefixes associated
+# with the different components of our system:
+# 	`MR_' or `MERCURY_' for stuff in the Mercury runtime implementation
+# 		(the `runtime' and `trace' directories)
+# 	`GC_' for stuff in the Boehm et al conservative garbage collector
+# 		(the `boehm_gc' directory)
+# 	`MPS_' or `mps_' for stuff in the Memory Pool System toolkit
+# 		(the `mps_gc' directory, if present -- note that this
+# 		is in a separate CVS module and is not included in the
+# 		normal Mercury source distributions)
+# Exceptions to this policy must be listed in the RESERVED_MACRO_NAMES file.
 HEADER_CLEAN_FILTER = \
-	grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
+	grep -v -e '^MR_' -e '^MERCURY_' -e '^GC_' -e '^MPS_' -e '^mps_' | \
 	fgrep -v -x -f RESERVED_MACRO_NAMES
 
 .PHONY: check_headers_self_contained
diff -u runtime/mercury.h runtime/mercury.h
--- runtime/mercury.h
+++ runtime/mercury.h
@@ -37,7 +37,8 @@
 #ifdef MR_CONSERVATIVE_GC
   #ifdef MR_MPS_GC
     #include "mercury_mps.h"
-  #else /* MR_BOEHM_GC */
+  #endif
+  #ifdef MR_BOEHM_GC
     #include "gc.h"
     #ifdef MR_INLINE_ALLOC
       #include "gc_inl.h"
diff -u runtime/mercury_heap.h runtime/mercury_heap.h
--- runtime/mercury_heap.h
+++ runtime/mercury_heap.h
@@ -23,7 +23,8 @@
 
   #ifdef MR_MPS_GC
     #include "mercury_mps.h"
-  #else /* MR_BOEHM_GC */
+  #endif
+  #ifdef MR_BOEHM_GC
     #include "gc.h"
   #endif
 
diff -u runtime/mercury_init.h runtime/mercury_init.h
--- runtime/mercury_init.h
+++ runtime/mercury_init.h
@@ -41,8 +41,8 @@
 ** mercury_init() is defined in the <module>_init.c file.
 **
 ** The `argc' and `argv' parameters are as for main() in C.
-** The `stack_bottom' parameter should be the address of a variable
-** on the C stack.  The conservative garbage collector treats that
+** The `stack_bottom' parameter should be the address of a (word-aligned)
+** variable on the C stack.  The conservative garbage collector treats that
 ** address as the start of the stack, so anything older than that
 ** address won't get scanned; don't store pointers to GC'ed memory
 ** in local variables that are older than that.
@@ -51,7 +51,7 @@
 ** collector, sets some global variables, and then calls
 ** mercury_runtime_init().
 */
-extern	void	mercury_init(int argc, char **argv, char *stack_bottom);
+extern	void	mercury_init(int argc, char **argv, void *stack_bottom);
 
 /*
 ** mercury_call_main() is defined in the <module>_init.c file.
@@ -89,8 +89,9 @@
 
 #ifdef MR_CONSERVATIVE_GC
   #ifdef MR_MPS_GC
-    #include "mercury_mps.h"	/* XXX FIXME */
-  #else /* MR_BOEHM_GC */
+    #include "mercury_mps.h"	/* for GC_INIT(), GC_stack_bottom */
+  #endif
+  #ifdef MR_BOEHM_GC
     #include "gc.h"		/* for GC_INIT(), GC_stack_bottom */
   #endif
 #endif
diff -u runtime/mercury_memory.h runtime/mercury_memory.h
--- runtime/mercury_memory.h
+++ runtime/mercury_memory.h
@@ -29,7 +29,8 @@
 #if defined(MR_CONSERVATIVE_GC)
   #if defined(MR_MPS_GC)
     #include "mercury_mps.h"	/* for GC_FREE */
-  #else /* MR_BOEHM_GC */
+  #endif
+  #if defined(MR_BOEHM_GC)
     #include "gc.h"		/* for GC_FREE */
   #endif
 #endif
diff -u runtime/mercury_wrapper.c runtime/mercury_wrapper.c
--- runtime/mercury_wrapper.c
+++ runtime/mercury_wrapper.c
@@ -347,7 +347,10 @@
 	** our signal handler assumes that signals which it can't
 	** handle are fatal.
 	*/
+#if 1 /* XXX still some problems with this for MPS? -fjh */
+/* #ifndef MR_MPS_GC */
 	MR_setup_signals();
+#endif
 
 #ifdef MR_CONSERVATIVE_GC
 	MR_init_conservative_GC();
only in patch2:
--- util/mkinit.c	18 Feb 2002 07:01:33 -0000	1.86
+++ util/mkinit.c	4 Aug 2002 13:36:28 -0000
@@ -266,7 +266,7 @@
 	"#endif\n"
 	"\n"
 	"void\n"
-	"mercury_init(int argc, char **argv, char *stackbottom)\n"
+	"mercury_init(int argc, char **argv, void *stackbottom)\n"
 	"{\n"
 	"\n"
 	"#ifdef MR_CONSERVATIVE_GC\n"
@@ -385,7 +385,13 @@
 	"int\n"
 	"mercury_main(int argc, char **argv)\n"
 	"{\n"
-	"	char dummy;\n"
+		/*
+		** Note that the address we use for the stack base
+		** needs to be word-aligned (the MPS GC requires this).
+		** That's why we give dummy the type `void *' rather than
+		** e.g. `char'.
+		*/
+	"	void *dummy;\n"
 	"	mercury_init(argc, argv, &dummy);\n"
 	"	mercury_call_main();\n"
 	"	return mercury_terminate();\n"
only in patch2:
--- trace/Mmakefile	22 Jun 2002 19:16:15 -0000	1.31
+++ trace/Mmakefile	21 Aug 2002 08:35:35 -0000
@@ -72,7 +72,7 @@
 # whose changes don't usually require a make clean but which nevertheless
 # require the trace library to be recompiled.
 RUNTIME_HDRS	=	\
-			../runtime/mercury_stack_layout.h
+			$(RUNTIME_DIR)/mercury_stack_layout.h
 
 OBJS		= $(CFILES:.c=.$O)
 PIC_OBJS	= $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
@@ -145,7 +145,7 @@
 cs: $(CFILES)
 
 tags: $(CFILES) $(HDRS)
-	ctags $(CFILES) $(HDRS) ../runtime/*.c ../runtime/*.h
+	ctags $(CFILES) $(HDRS) $(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h
 
 #-----------------------------------------------------------------------------#
 #
@@ -153,9 +153,11 @@
 # and object files to make sure that they conform with our coding standards.
 #
 
+# This should match the definition of HEADER_CLEAN_FILTER in
+# runtime/Mmakefile.  See the documentation there.
 HEADER_CLEAN_FILTER = \
-	grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
-	fgrep -v -x -f ../runtime/RESERVED_MACRO_NAMES
+	grep -v -e '^MR_' -e '^MERCURY_' -e '^MPS_' -e '^mps_' -e '^GC_' | \
+	fgrep -v -x -f $(RUNTIME_DIR)/RESERVED_MACRO_NAMES
 
 .PHONY: check_headers_self_contained
 check_headers_self_contained: $(HDR_CHECK_OBJS)
only in patch2:
--- tools/bootcheck	25 Jul 2002 13:01:12 -0000	1.131
+++ tools/bootcheck	2 Aug 2002 09:28:53 -0000
@@ -514,6 +514,7 @@
 	else
 		$LN_S $root/boehm_gc .
 	fi
+	$LN_S $root/mps_gc .
 	$LN_S $root/bindist .
 	$LN_S $root/doc .
 	$LN_S $root/scripts .
@@ -700,6 +701,7 @@
 	cp $root/browser/Mmake* $root/browser/Mercury.options .
 	$LN_S $root/browser/$BROWSER_LIB_NAME.init .
 	cd $root/stage3
+	$LN_S $root/mps_gc .
 	$LN_S $root/boehm_gc .
 	$LN_S $root/bindist .
 	$LN_S $root/doc .
only in patch2:
--- scripts/mgnuc.in	30 May 2002 12:55:23 -0000	1.87
+++ scripts/mgnuc.in	30 Jul 2002 06:25:36 -0000
@@ -310,7 +310,9 @@
 
 case $gc_method in
 	accurate)	GC_OPTS="-DMR_NATIVE_GC" ;;
-	conservative)	GC_OPTS="-DMR_CONSERVATIVE_GC" ;;
+	boehm)		GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC" ;;
+	conservative)	GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC" ;;
+	mps)		GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_MPS_GC" ;;
 	none)		GC_OPTS="" ;;
 esac
 
only in patch2:
--- runtime/RESERVED_MACRO_NAMES	18 Feb 2002 07:01:12 -0000	1.11
+++ runtime/RESERVED_MACRO_NAMES	21 Aug 2002 08:22:40 -0000
@@ -49,6 +49,12 @@
 __GC
 _GC_H
 #-----------------------------------------------------------------------------#
+# This is defined by mps_gc/code/mercury_mps.h,
+# which uses this macro for its header guard.
+# Normally it would be better to use uppercase for header guard macro names,
+# but that would be inconsistent with the coding style used in mps_gc/code.
+mercury_mps_h
+#-----------------------------------------------------------------------------#
 # This is defined by mercury_getopt.h
 # That header file is NOT #included by any of the other
 # headers, so this doesn't cause any name space polution.
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list