[m-rev.] diff: support `hlc' and `hl' grades

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 22 22:30:59 AEDT 2001


Estimated hours taken: 8
Branches: main

Add support for `--gc none' to the MLDS->C back-end,
i.e. support the `hlc' and `hl' grades.

XXX We don't yet perform automatic heap reclamation
    on failure for these grades.

runtime/mercury_float.h:
	Extra some of the code from MR_float_to_word() out into
	a new macro MR_make_hp_float_aligned(), for use in
	MR_box_float().

runtime/mercury.h:
	If CONSERVATIVE_GC is not defined, include "mercury_regs.h" and
	"mercury_engine.h", so that we get the definition of MR_hp,
	and "mercury_overflow.h", for MR_heap_overflow_check().
	Define MR_new_object() and MR_box_float() correctly for
	the !CONSERVATIVE_GC case.

runtime/mercury_context.h:
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_debug.c:
runtime/mercury_thread.c:
runtime/mercury_stack_trace.c:
trace/mercury_trace_util.c:
	Add `#ifndef MR_HIGHLEVEL_CODE ... #endif' wrappers around
	sections of code that are specific to the LLDS back-end.

runtime/mercury_wrapper.c:
library/benchmarking.m:
	Initialize (in mercury_wrapper.c) and use (in benchmarking.m)
	the MercuryEngine struct in the !CONSERVATIVE_GC case, as well
	as in the !MR_HIGHLEVEL_CODE case.  The MercuryEngine struct
	is needed because that is where the heap pointer and heap zone
	are stored.

library/table_builtin.m:
	Use the correct names for type_ctor_infos when MR_HIGHLEVEL_CODE
	is enabled.  (Previously this was not an issue because these
	type_ctor_infos were only being used in the !CONSERVATIVE_GC case.)

tests/hard_coded/Mmakefile:
	For the test cases which use lots of memory, increase the heap
	size (using the MERCURY_OPTIONS environment variable) rather
	than compiling them with `--gc conservative'.  This avoids
	spurious test case failures when running the tests via
	`tools/bootcheck --grade hlc --no-bootcheck'.

Workspace: /home/earth/fjh/ws-earth3/mercury
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.43
diff -u -d -r1.43 benchmarking.m
--- library/benchmarking.m	18 Oct 2001 03:02:56 -0000	1.43
+++ library/benchmarking.m	22 Nov 2001 06:24:04 -0000
@@ -160,7 +160,7 @@
 ML_report_stats(void)
 {
 	int			time_at_prev_stat;
-#ifndef MR_HIGHLEVEL_CODE
+#if !defined(MR_HIGHLEVEL_CODE) || !defined(CONSERVATIVE_GC)
 	MercuryEngine		*eng;
 #endif
 #ifdef MR_MPROF_PROFILE_MEMORY
@@ -175,7 +175,7 @@
 	time_at_prev_stat = MR_time_at_last_stat;
 	MR_time_at_last_stat = MR_get_user_cpu_miliseconds();
 
-#ifndef MR_HIGHLEVEL_CODE
+#if !defined(MR_HIGHLEVEL_CODE) || !defined(CONSERVATIVE_GC)
 	eng = MR_get_engine();
 #endif
 
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.9
diff -u -d -r1.9 table_builtin.m
--- library/table_builtin.m	31 May 2001 06:00:08 -0000	1.9
+++ library/table_builtin.m	22 Nov 2001 06:58:33 -0000
@@ -1053,16 +1053,32 @@
 #include ""mercury_type_info.h""	/* for MR_TypeCtorInfo_Struct; */
 #include ""mercury_tabling.h""		/* for MR_TrieNode, etc. */
 
+#ifdef MR_HIGHLEVEL_CODE
+  #define MR_TYPE_CTOR_INFO_INT	      \
+  	mercury__builtin__builtin__type_ctor_info_int_0
+  #define MR_TYPE_CTOR_INFO_STRING    \
+  	mercury__builtin__builtin__type_ctor_info_string_0
+  #define MR_TYPE_CTOR_INFO_FLOAT     \
+  	mercury__builtin__builtin__type_ctor_info_float_0
+  #define MR_TYPE_CTOR_INFO_CHAR      \
+  	mercury__builtin__builtin__type_ctor_info_character_0
+  #define MR_TYPE_CTOR_INFO_IO_STATE  \
+  	mercury__io__io__type_ctor_info_state_0
+#else
+  #define MR_TYPE_CTOR_INFO_INT	      mercury_data___type_ctor_info_int_0
+  #define MR_TYPE_CTOR_INFO_STRING    mercury_data___type_ctor_info_string_0
+  #define MR_TYPE_CTOR_INFO_FLOAT     mercury_data___type_ctor_info_float_0
+  #define MR_TYPE_CTOR_INFO_CHAR      mercury_data___type_ctor_info_character_0
+  #define MR_TYPE_CTOR_INFO_IO_STATE  mercury_data_io__type_ctor_info_state_0
+#endif
+
+
 extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
-	mercury_data___type_ctor_info_int_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
-	mercury_data___type_ctor_info_string_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
-	mercury_data___type_ctor_info_float_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
-	mercury_data___type_ctor_info_character_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
-	mercury_data_io__type_ctor_info_state_0;
+	MR_TYPE_CTOR_INFO_INT,
+	MR_TYPE_CTOR_INFO_STRING,
+	MR_TYPE_CTOR_INFO_FLOAT,
+	MR_TYPE_CTOR_INFO_CHAR,
+	MR_TYPE_CTOR_INFO_IO_STATE;
 
 ").
 
@@ -1151,7 +1167,7 @@
 
 	table = (MR_TrieNode) T;
 	MR_TABLE_SAVE_ANSWER(table, Offset, I,
-		&mercury_data___type_ctor_info_int_0);
+		&MR_TYPE_CTOR_INFO_INT);
 ").
 
 :- pragma foreign_proc("C",
@@ -1161,7 +1177,7 @@
 
 	table = (MR_TrieNode) T;
 	MR_TABLE_SAVE_ANSWER(table, Offset, C,
-		&mercury_data___type_ctor_info_character_0);
+		&MR_TYPE_CTOR_INFO_CHAR);
 ").
 
 :- pragma foreign_proc("C",
@@ -1171,7 +1187,7 @@
 
 	table = (MR_TrieNode) T;
 	MR_TABLE_SAVE_ANSWER(table, Offset, (MR_Word) S,
-		&mercury_data___type_ctor_info_string_0);
+		&MR_TYPE_CTOR_INFO_STRING);
 ").
 
 :- pragma foreign_proc("C",
@@ -1183,11 +1199,11 @@
 #ifdef MR_HIGHLEVEL_CODE
 	MR_TABLE_SAVE_ANSWER(table, Offset,
 		(MR_Word) MR_box_float(F),
-		&mercury_data___type_ctor_info_float_0);
+		&MR_TYPE_CTOR_INFO_FLOAT);
 #else
 	MR_TABLE_SAVE_ANSWER(table, Offset,
 		MR_float_to_word(F),
-		&mercury_data___type_ctor_info_float_0);
+		&MR_TYPE_CTOR_INFO_FLOAT);
 #endif
 ").
 
@@ -1198,7 +1214,7 @@
 
 	table = (MR_TrieNode) T;
 	MR_TABLE_SAVE_ANSWER(table, Offset, (MR_Word) S,
-		&mercury_data_io__type_ctor_info_state_0);
+		&MR_TYPE_CTOR_INFO_IO_STATE);
 ").
 
 :- pragma foreign_proc("C", 
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.39
diff -u -d -r1.39 mercury.h
--- runtime/mercury.h	31 Oct 2001 17:59:03 -0000	1.39
+++ runtime/mercury.h	22 Nov 2001 11:18:09 -0000
@@ -39,6 +39,10 @@
   #ifdef INLINE_ALLOC
     #include "gc_inl.h"
   #endif
+#else
+  #include "mercury_regs.h"	/* for MR_hp */
+  #include "mercury_engine.h"	/* for MR_fake_reg (needed by MR_hp) */
+  #include "mercury_overflow.h"	/* for MR_heap_overflow_check() */
 #endif
 
 #if defined(MR_MPROF_PROFILE_CALLS) || defined(MR_MPROF_PROFILE_TIME)
@@ -229,11 +233,20 @@
 typedef struct MR_FO_PseudoTypeInfo_Struct9 MR_FO_PseudoTypeInfo_Struct9;
 typedef struct MR_FO_PseudoTypeInfo_Struct10 MR_FO_PseudoTypeInfo_Struct10;
 
+/* The chain of stack frames, used for accurate GC. */
+struct MR_StackChain {
+	struct MR_StackChain *prev;
+	void (*trace)(void *this_frame);
+};
+
 /*---------------------------------------------------------------------------*/
 /*
 ** Declarations of contants and variables
 */
 
+/* This points to the start of the MR_StackChain frame list. */
+extern void *mercury__private_builtin__stack_chain;
+
 /* declare MR_TypeCtorInfo_Structs for the builtin types */
 extern const MR_TypeCtorInfo_Struct
 	mercury__builtin__builtin__type_ctor_info_int_0,
@@ -318,16 +331,17 @@
 **	Allocates memory on the garbage-collected heap.
 */
 
-#ifdef INLINE_ALLOC
-  #ifndef __GNUC__
-    #error "INLINE_ALLOC requires GNU C"
-  #endif
-  /*
-  ** This must be a macro, not an inline function, because
-  ** GNU C's `__builtin_constant_p' does not work inside
-  ** inline functions
-  */
-  #define MR_GC_MALLOC_INLINE(bytes)                                    \
+#ifdef CONSERVATIVE_GC
+  #ifdef INLINE_ALLOC
+    #ifndef __GNUC__
+      #error "INLINE_ALLOC requires GNU C"
+    #endif
+    /*
+    ** This must be a macro, not an inline function, because
+    ** GNU C's `__builtin_constant_p' does not work inside
+    ** inline functions
+    */
+    #define MR_GC_MALLOC_INLINE(bytes)                                    \
         ( __extension__ __builtin_constant_p(bytes) &&			\
 	  (bytes) <= 16 * sizeof(MR_Word)				\
         ? ({    void * temp;                                            \
@@ -343,11 +357,42 @@
           })                                                            \
         : GC_MALLOC(bytes)                         			\
         )
-  #define MR_new_object(type, size, name) \
+    #define MR_new_object(type, size, name) \
   		((type *) MR_GC_MALLOC_INLINE(size))
-#else
-  #define MR_new_object(type, size, name) \
+  #else /* !INLINE_ALLOC */
+    #define MR_new_object(type, size, name) \
   		((type *) GC_MALLOC(size)) 
+  #endif /* !INLINE_ALLOC */
+
+#else /* !CONSERVATIVE_GC */
+
+  #ifndef __GNUC__
+    /*
+    ** We need GNU C's `({...})' expressions.
+    ** It's not worth worrying about compilers other than GNU C for
+    ** this obscure combination of options.
+    */
+    #error "For C compilers other than GNU C, `--high-level-code' requires `--gc conservative'"
+  #endif
+
+  /*
+  ** XXX Note that currently we don't need to worry about alignment here,
+  **     other than word alignment, because floating point fields will
+  **	 be boxed if they don't fit in a word.
+  **     This would need to change if we ever start using unboxed
+  **     fields whose alignment requirement is greater than one word.
+  */
+  #define MR_new_object(type, size, name)				\
+     ({ 								\
+        size_t MR_new_object_num_words;					\
+        MR_Word MR_new_object_ptr;					\
+									\
+	MR_new_object_num_words = 					\
+		((size) + sizeof(MR_Word) - 1) / sizeof(MR_Word);	\
+	MR_incr_hp(MR_new_object_ptr, MR_new_object_num_words);		\
+	/* return */ (type *) MR_new_object_ptr;			\
+      })
+
 #endif
 
 /*
@@ -359,7 +404,10 @@
 
 #if defined(__GNUC__) && !defined(MR_AVOID_MACROS)
   #define MR_box_float(f) ({						\
-	MR_Float *MR_box_float_ptr = (MR_Float *)			\
+	MR_Float *MR_box_float_ptr;					\
+									\
+	MR_make_hp_float_aligned();					\
+	MR_box_float_ptr = 						\
 		MR_new_object(MR_Float, sizeof(MR_Float), "float");	\
 	*MR_box_float_ptr = (f);					\
 	/* return */ (MR_Box) MR_box_float_ptr;				\
@@ -369,8 +417,10 @@
 
   MR_EXTERN_INLINE MR_Box
   MR_box_float(MR_Float f) {
-	MR_Float *ptr = (MR_Float *)
-		MR_new_object(MR_Float, sizeof(MR_Float), "float");
+	MR_Float *ptr;
+
+	MR_make_hp_float_aligned();
+	ptr = MR_new_object(MR_Float, sizeof(MR_Float), "float");
 	*ptr = f;
 	return (MR_Box) ptr;
   }
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.29
diff -u -d -r1.29 mercury_context.c
--- runtime/mercury_context.c	31 May 2001 06:00:11 -0000	1.29
+++ runtime/mercury_context.c	22 Nov 2001 05:06:44 -0000
@@ -92,6 +92,8 @@
 #ifdef	MR_THREAD_SAFE
 	c->MR_ctxt_owner_thread = (MercuryThread) NULL;
 #endif
+
+#ifndef MR_HIGHLEVEL_CODE
 	c->MR_ctxt_succip = MR_ENTRY(MR_do_not_reached);
 
 	if (c->MR_ctxt_detstack_zone != NULL) {
@@ -116,7 +118,8 @@
 	** minus one word, to the base address to get the maxfr/curfr pointer
 	** for the first frame on the nondet stack.
 	*/
-	c->MR_ctxt_maxfr = c->MR_ctxt_nondetstack_zone->min + MR_NONDET_FIXED_SIZE - 1;
+	c->MR_ctxt_maxfr = c->MR_ctxt_nondetstack_zone->min +
+		MR_NONDET_FIXED_SIZE - 1;
 	c->MR_ctxt_curfr = c->MR_ctxt_maxfr;
 	MR_redoip_slot(c->MR_ctxt_curfr) = MR_ENTRY(MR_do_not_reached);
 	MR_redofr_slot(c->MR_ctxt_curfr) = NULL;
@@ -124,11 +127,12 @@
 	MR_succip_slot(c->MR_ctxt_curfr) = MR_ENTRY(MR_do_not_reached);
 	MR_succfr_slot(c->MR_ctxt_curfr) = NULL;
 
-#ifdef	MR_USE_MINIMAL_MODEL
+  #ifdef MR_USE_MINIMAL_MODEL
 	if (c->MR_ctxt_generatorstack_zone != NULL) {
 		MR_reset_redzone(c->MR_ctxt_generatorstack_zone);
 	} else {
-		c->MR_ctxt_generatorstack_zone = MR_create_zone("generatorstack", 0,
+		c->MR_ctxt_generatorstack_zone = MR_create_zone(
+			"generatorstack", 0,
 			MR_generatorstack_size, MR_next_offset(),
 			MR_generatorstack_zone_size, MR_default_handler);
 	}
@@ -142,7 +146,8 @@
 			MR_cutstack_zone_size, MR_default_handler);
 	}
 	c->MR_ctxt_cut_next = 0;
-#endif
+  #endif /* MR_USE_MINIMAL_MODEL */
+#endif /* !MR_HIGHLEVEL_CODE */
 
 #ifdef MR_USE_TRAIL
 	if (c->MR_ctxt_trail_zone != NULL) {
@@ -169,8 +174,10 @@
 	if (free_context_list == NULL) {
 		MR_UNLOCK(free_context_list_lock, "create_context i");
 		c = MR_GC_NEW(MR_Context);
+#ifndef MR_HIGHLEVEL_CODE
 		c->MR_ctxt_detstack_zone = NULL;
 		c->MR_ctxt_nondetstack_zone = NULL;
+#endif
 #ifdef MR_USE_TRAIL
 		c->MR_ctxt_trail_zone = NULL;
 #endif
@@ -300,6 +307,8 @@
 	MR_UNLOCK(MR_runqueue_lock, "schedule");
 }
 
+#ifndef MR_HIGHLEVEL_CODE
+
 MR_define_extern_entry(MR_do_runnext);
 
 MR_BEGIN_MODULE(scheduler_module)
@@ -377,6 +386,8 @@
 
 MR_END_MODULE
 
+#endif /* !MR_HIGHLEVEL_CODE */
+
 /* forward decls to suppress gcc warnings */
 void mercury_sys_init_scheduler_wrapper_init(void);
 void mercury_sys_init_scheduler_wrapper_init_type_tables(void);
@@ -386,7 +397,9 @@
 
 void mercury_sys_init_scheduler_wrapper_init(void)
 {
+#ifndef MR_HIGHLEVEL_CODE
 	scheduler_module();
+#endif
 }
 
 void mercury_sys_init_scheduler_wrapper_init_type_tables(void)
Index: runtime/mercury_context.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.h,v
retrieving revision 1.18
diff -u -d -r1.18 mercury_context.h
--- runtime/mercury_context.h	8 Jun 2001 08:23:08 -0000	1.18
+++ runtime/mercury_context.h	22 Nov 2001 04:52:03 -0000
@@ -59,12 +59,6 @@
   #define MR_IF_THREAD_SAFE(x)
 #endif
 
-/*
-** The field names that correspond to virtual machine registers:
-** 	sp, maxfr & curfr
-** are prefixed with `context_' so that they don't get replaced
-** during macro expansion.
-*/
 typedef struct MR_Context_Struct MR_Context;
 struct MR_Context_Struct {
 	MR_Context	 *MR_ctxt_next;	
@@ -92,6 +86,7 @@
 		*/
 #endif
 
+#ifndef MR_HIGHLEVEL_CODE
 	MR_Code		*MR_ctxt_succip;
 		/* succip for this context */
 
@@ -106,7 +101,7 @@
 		/* saved maxfr pointer for this context */
 	MR_Word		*MR_ctxt_curfr;
 		/* saved curfr pointer for this context */
-#ifdef	MR_USE_MINIMAL_MODEL
+  #ifdef MR_USE_MINIMAL_MODEL
 	MR_MemoryZone	*MR_ctxt_genstack_zone;
 		/* pointer to the genstack_zone for this context */
 	MR_Integer	MR_ctxt_gen_next;
@@ -115,7 +110,8 @@
 		/* pointer to the cutstack_zone for this context */
 	MR_Integer	MR_ctxt_cut_next;
 		/* saved cut stack index for this context */
-#endif
+  #endif /* MR_USE_MINIMAL_MODEL */
+#endif /* !MR_HIGHLEVEL_CODE */
 
 #ifdef	MR_USE_TRAIL
 	MR_MemoryZone	*MR_ctxt_trail_zone;
@@ -227,11 +223,13 @@
 
 extern	void		MR_schedule(MR_Context *ctxt);
 
-MR_declare_entry(MR_do_runnext);
-#define MR_runnext()						\
+#ifndef MR_HIGHLEVEL_CODE
+  MR_declare_entry(MR_do_runnext);
+  #define MR_runnext()						\
 	do {							\
 		MR_GOTO(MR_ENTRY(MR_do_runnext));		\
-	} while (0)						\
+	} while (0)
+#endif
 
 #ifdef	MR_THREAD_SAFE
   #define MR_IF_MR_THREAD_SAFE(x)	x
@@ -239,14 +237,15 @@
   #define MR_IF_MR_THREAD_SAFE(x)
 #endif
 
-/*
-** fork_new_context(MR_Code *child, MR_Code *parent, int numslots):
-** create a new context to execute the code at `child', and
-** copy the topmost `numslots' from the current stackframe.
-** The new context gets put on the runqueue, and the current
-** context resumes at `parent'.
-*/
-#define MR_fork_new_context(child, parent, numslots) do {		\
+#ifndef MR_HIGHLEVEL_CODE
+  /*
+  ** fork_new_context(MR_Code *child, MR_Code *parent, int numslots):
+  ** create a new context to execute the code at `child', and
+  ** copy the topmost `numslots' from the current stackframe.
+  ** The new context gets put on the runqueue, and the current
+  ** context resumes at `parent'.
+  */
+  #define MR_fork_new_context(child, parent, numslots) do {		\
 		MR_Context	*f_n_c_context;				\
 		int		fork_new_context_i;			\
 		f_n_c_context = MR_create_context();			\
@@ -264,6 +263,7 @@
 		MR_schedule(f_n_c_context);				\
 		MR_GOTO(parent);					\
 	} while (0)
+#endif /* MR_HIGHLEVEL_CODE */
 
 #ifndef	CONSERVATIVE_GC
 
@@ -332,18 +332,26 @@
   #define MR_IF_USE_MINIMAL_MODEL(x)
 #endif
 
+#ifndef MR_HIGHLEVEL_CODE
+  #define MR_IF_NOT_HIGHLEVEL_CODE(x) x
+#else
+  #define MR_IF_NOT_HIGHLEVEL_CODE(x)
+#endif
+
 #define MR_load_context(cptr)						\
 	do {								\
 		MR_Context	*load_context_c;			\
 									\
 		load_context_c = (cptr);				\
-		MR_succip	= load_context_c->MR_ctxt_succip;	\
-		MR_sp		= load_context_c->MR_ctxt_sp;		\
-		MR_maxfr	= load_context_c->MR_ctxt_maxfr; 	\
-		MR_curfr	= load_context_c->MR_ctxt_curfr;	\
-		MR_IF_USE_MINIMAL_MODEL(				\
+		MR_IF_NOT_HIGHLEVEL_CODE(				\
+			MR_succip  = load_context_c->MR_ctxt_succip;	\
+			MR_sp	   = load_context_c->MR_ctxt_sp;	\
+			MR_maxfr   = load_context_c->MR_ctxt_maxfr; 	\
+			MR_curfr   = load_context_c->MR_ctxt_curfr;	\
+		  MR_IF_USE_MINIMAL_MODEL(				\
 			MR_gen_next = load_context_c->MR_ctxt_gen_next;	\
 			MR_cut_next = load_context_c->MR_ctxt_cut_next;	\
+		  )							\
 		)							\
 	        MR_IF_USE_TRAIL(					\
 			MR_trail_zone = load_context_c->MR_ctxt_trail_zone;\
@@ -353,14 +361,15 @@
 		    MR_ticket_high_water =				\
 				 load_context_c->MR_ctxt_ticket_high_water;\
 	    	)							\
-		MR_ENGINE(MR_eng_context).MR_ctxt_detstack_zone =	\
+		MR_IF_NOT_HIGHLEVEL_CODE(				\
+		  MR_ENGINE(MR_eng_context).MR_ctxt_detstack_zone =	\
 				load_context_c->MR_ctxt_detstack_zone;	\
-		MR_ENGINE(MR_eng_context).MR_ctxt_nondetstack_zone =	\
+		  MR_ENGINE(MR_eng_context).MR_ctxt_nondetstack_zone =	\
 				load_context_c->MR_ctxt_nondetstack_zone;\
-		MR_IF_USE_MINIMAL_MODEL(				\
-			MR_ENGINE(MR_eng_context).MR_ctxt_genstack_zone =\
+		  MR_IF_USE_MINIMAL_MODEL(				\
+		    MR_ENGINE(MR_eng_context).MR_ctxt_genstack_zone =   \
 				load_context_c->MR_ctxt_genstack_zone;	\
-			MR_ENGINE(MR_eng_context).MR_ctxt_cutstack_zone =\
+		    MR_ENGINE(MR_eng_context).MR_ctxt_cutstack_zone =   \
 				load_context_c->MR_ctxt_cutstack_zone;	\
 		    MR_gen_stack = (MR_GeneratorStackFrame *)		\
 				MR_ENGINE(MR_eng_context).		\
@@ -368,6 +377,7 @@
 		    MR_cut_stack = (MR_CutStackFrame *)			\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_cutstack_zone;		\
+	    	  )							\
 	    	)							\
 		MR_set_min_heap_reclamation_point(load_context_c);	\
 	} while (0)
@@ -377,13 +387,15 @@
 		MR_Context	*save_context_c;			\
 									\
 		save_context_c = (cptr);				\
-		save_context_c->MR_ctxt_succip	= MR_succip;		\
-		save_context_c->MR_ctxt_sp	= MR_sp;		\
-		save_context_c->MR_ctxt_maxfr   = MR_maxfr;		\
-		save_context_c->MR_ctxt_curfr   = MR_curfr;		\
-		MR_IF_USE_MINIMAL_MODEL(				\
+		MR_IF_NOT_HIGHLEVEL_CODE(				\
+			save_context_c->MR_ctxt_succip	= MR_succip;	\
+			save_context_c->MR_ctxt_sp	= MR_sp;	\
+			save_context_c->MR_ctxt_maxfr   = MR_maxfr;	\
+			save_context_c->MR_ctxt_curfr   = MR_curfr;	\
+		  MR_IF_USE_MINIMAL_MODEL(				\
 			save_context_c->MR_ctxt_gen_next = MR_gen_next;	\
 			save_context_c->MR_ctxt_cut_next = MR_cut_next;	\
+		  )							\
 		)							\
 		MR_IF_USE_TRAIL(					\
 			save_context_c->MR_ctxt_trail_zone = MR_trail_zone;\
@@ -393,25 +405,27 @@
 			save_context_c->MR_ctxt_ticket_high_water =	\
 						MR_ticket_high_water;	\
 		)							\
-		save_context_c->MR_ctxt_detstack_zone =			\
+		MR_IF_NOT_HIGHLEVEL_CODE(				\
+		  save_context_c->MR_ctxt_detstack_zone =		\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_detstack_zone;		\
-		save_context_c->MR_ctxt_nondetstack_zone =		\
+		  save_context_c->MR_ctxt_nondetstack_zone =		\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_nondetstack_zone;	\
-		MR_IF_USE_MINIMAL_MODEL(				\
-			save_context_c->MR_ctxt_genstack_zone =		\
+		  MR_IF_USE_MINIMAL_MODEL(				\
+		    save_context_c->MR_ctxt_genstack_zone =		\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_genstack_zone;		\
-			save_context_c->MR_ctxt_cutstack_zone =		\
+		    save_context_c->MR_ctxt_cutstack_zone =		\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_cutstack_zone;		\
-			assert(MR_gen_stack == (MR_GeneratorStackFrame *)\
+		    assert(MR_gen_stack == (MR_GeneratorStackFrame *)	\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_genstack_zone);		\
 		    assert(MR_cut_stack == (MR_CutStackFrame *)		\
 				MR_ENGINE(MR_eng_context).		\
 					MR_ctxt_cutstack_zone);		\
+		  )							\
 		)							\
 		MR_save_hp_in_context(save_context_c);			\
 	} while (0)
Index: runtime/mercury_debug.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.c,v
retrieving revision 1.5
diff -u -d -r1.5 mercury_debug.c
--- runtime/mercury_debug.c	31 May 2001 06:00:11 -0000	1.5
+++ runtime/mercury_debug.c	22 Nov 2001 05:14:46 -0000
@@ -338,6 +338,8 @@
 
 #endif /* defined(MR_DEBUG_GOTOS) */
 
+#ifndef MR_HIGHLEVEL_CODE
+
 static void 
 MR_printdetslot_as_label(const MR_Integer offset)
 {
@@ -394,6 +396,8 @@
 		(long) (MR_Integer)
 			(s - MR_CONTEXT(MR_ctxt_nondetstack_zone)->min));
 }
+
+#endif /* !MR_HIGHLEVEL_CODE */
 
 void 
 MR_print_heapptr(FILE *fp, const MR_Word *s)
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.35
diff -u -d -r1.35 mercury_engine.c
--- runtime/mercury_engine.c	8 Jun 2001 08:23:09 -0000	1.35
+++ runtime/mercury_engine.c	22 Nov 2001 04:28:30 -0000
@@ -58,7 +58,7 @@
 
 	MR_init_memory();
 
-#ifndef USE_GCC_NONLOCAL_GOTOS
+#if !defined(USE_GCC_NONLOCAL_GOTOS) && !defined(MR_HIGHLEVEL_CODE)
 	{
 		static bool made_engine_done_label = FALSE;
 		if (!made_engine_done_label) {
@@ -110,7 +110,7 @@
 #endif
 
 	/*
-	** Finally, allocate an initialize context (Mercury thread)
+	** Finally, allocate an initial context (Mercury thread)
 	** in the engine and initialize the per-context stuff.
 	*/
 	eng->MR_eng_this_context = MR_create_context();
Index: runtime/mercury_float.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_float.h,v
retrieving revision 1.11
diff -u -d -r1.11 mercury_float.h
--- runtime/mercury_float.h	23 Nov 2000 02:00:28 -0000	1.11
+++ runtime/mercury_float.h	22 Nov 2001 11:24:24 -0000
@@ -13,9 +13,9 @@
 #include "mercury_types.h"	/* for `MR_Word' */
 
 #ifdef USE_SINGLE_PREC_FLOAT
-typedef float MR_Float;
+  typedef float MR_Float;
 #else
-typedef double MR_Float;
+  typedef double MR_Float;
 #endif
 
 #ifdef BOXED_FLOAT 
@@ -26,19 +26,26 @@
 					/ sizeof(MR_Word))
 
 #ifdef CONSERVATIVE_GC
-#define MR_float_to_word(f) ( \
+  #define MR_float_to_word(f) ( \
 		MR_hp_alloc_atomic(MR_FLOAT_WORDS), \
 		* (MR_Float *) (void *) (MR_hp - MR_FLOAT_WORDS) = (f), \
 		/* return */ (MR_Word) (MR_hp - MR_FLOAT_WORDS) \
 	)
+  #define MR_make_hp_float_aligned() ((void)0)
 #else
-/*
-** we need to ensure that what we allocated on the heap is properly
-** aligned
-*/
-#define MR_float_to_word(f) ( \
+  /*
+  ** We need to ensure that what we allocated on the heap is properly
+  ** aligned for a floating-point value, by rounding MR_hp up to the
+  ** nearest float-aligned boundary.
+  ** XXX This code assumes that sizeof(MR_Float) is a power of two,
+  ** and not greater than 2 * sizeof(MR_Word).
+  */
+  #define MR_make_hp_float_aligned() ( \
 		( (MR_Word) MR_hp & (sizeof(MR_Float) - 1) ? \
-			MR_hp_alloc_atomic(1) : (void)0 ), \
+			MR_hp_alloc_atomic(1) : (void)0 ) \
+	)
+  #define MR_float_to_word(f) ( \
+		MR_make_hp_float_aligned(), \
 		MR_hp_alloc_atomic(MR_FLOAT_WORDS), \
 		* (MR_Float *) (void *)(MR_hp - MR_FLOAT_WORDS) = (f), \
 		/* return */ (MR_Word) (MR_hp - MR_FLOAT_WORDS) \
@@ -46,38 +53,38 @@
 #endif
 
 #ifdef __GNUC__
-#define MR_float_const(f) ({ static const MR_Float d = f; (MR_Word) &d; })
+  #define MR_float_const(f) ({ static const MR_Float d = f; (MR_Word) &d; })
 #else
-#define MR_float_const(f) MR_float_to_word(f)	/* inefficient */
+  #define MR_float_const(f) MR_float_to_word(f)	/* inefficient */
 #endif
 
 #else /* not BOXED_FLOAT */
 
-/* unboxed float means we can assume sizeof(MR_Float) == sizeof(MR_Word) */
+  /* unboxed float means we can assume sizeof(MR_Float) == sizeof(MR_Word) */
 
-union MR_Float_Word {
+  union MR_Float_Word {
 	MR_Float f;
 	MR_Word w;
-};
+  };
 
-#define MR_float_const(f) MR_float_to_word(f)
+  #define MR_float_const(f) MR_float_to_word(f)
 
-#ifdef __GNUC__
+  #ifdef __GNUC__
 
-/* GNU C allows you to cast to a union type */
-#define MR_float_to_word(f) (__extension__ \
+    /* GNU C allows you to cast to a union type */
+    #define MR_float_to_word(f) (__extension__ \
 				((union MR_Float_Word)(MR_Float)(f)).w)
-#define MR_word_to_float(w) (__extension__ \
+    #define MR_word_to_float(w) (__extension__ \
 				((union MR_Float_Word)(MR_Word)(w)).f)
 
-#else /* not __GNUC__ */
+  #else /* not __GNUC__ */
 
-static MR_Word MR_float_to_word(MR_Float f)
+    static MR_Word MR_float_to_word(MR_Float f)
 	{ union MR_Float_Word tmp; tmp.f = f; return tmp.w; }
-static MR_Float MR_word_to_float(MR_Word w)
+    static MR_Float MR_word_to_float(MR_Word w)
 	{ union MR_Float_Word tmp; tmp.w = w; return tmp.f; }
 
-#endif /* not __GNUC__ */
+  #endif /* not __GNUC__ */
 
 #endif /* not BOXED_FLOAT */
 
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.42
diff -u -d -r1.42 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	31 May 2001 06:00:16 -0000	1.42
+++ runtime/mercury_stack_trace.c	22 Nov 2001 08:46:17 -0000
@@ -224,6 +224,8 @@
 void
 MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *base_maxfr)
 {
+#ifndef MR_HIGHLEVEL_CODE
+
 	int	frame_size;
 
 	MR_do_init_modules();
@@ -275,6 +277,8 @@
 
 		base_maxfr = MR_prevfr_slot(base_maxfr);
 	}
+
+#endif /* !MR_HIGHLEVEL_CODE */
 }
 
 static	const MR_Proc_Layout	*prev_entry_layout;
Index: runtime/mercury_thread.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.17
diff -u -d -r1.17 mercury_thread.c
--- runtime/mercury_thread.c	31 May 2001 06:00:17 -0000	1.17
+++ runtime/mercury_thread.c	22 Nov 2001 05:22:59 -0000
@@ -106,8 +106,12 @@
 
 	switch (when_to_use) {
 		case MR_use_later :
+#ifdef MR_HIGHLEVEL_CODE
+			MR_fatal_error("Sorry, not implemented: "
+				"--high-level-code and multiple engines");
+#else
 			(void) MR_call_engine(MR_ENTRY(MR_do_runnext), FALSE);
-
+#endif
 			MR_destroy_engine(eng);
 			return FALSE;
 
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.90
diff -u -d -r1.90 mercury_wrapper.c
--- runtime/mercury_wrapper.c	4 Jul 2001 06:01:53 -0000	1.90
+++ runtime/mercury_wrapper.c	22 Nov 2001 07:43:35 -0000
@@ -342,7 +342,7 @@
 
 	(*MR_address_of_mercury_init_io)();
 
-#ifdef MR_HIGHLEVEL_CODE
+#if defined(MR_HIGHLEVEL_CODE) && defined(CONSERVATIVE_GC)
 	MR_init_memory();
   #ifdef MR_USE_TRAIL
 	/* initialize the trail */
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.134
diff -u -d -r1.134 Mmakefile
--- tests/hard_coded/Mmakefile	12 Nov 2001 11:08:17 -0000	1.134
+++ tests/hard_coded/Mmakefile	22 Nov 2001 08:33:59 -0000
@@ -255,12 +255,6 @@
 # tracking it down.
 MLFLAGS-mode_choice = --no-strip
 
-# these tests run out of memory unless we have GC
-GRADEFLAGS-integer_test		=	--gc conservative
-GRADEFLAGS-integer_test_init	=	--gc conservative
-GRADEFLAGS-rational_test 	=	--gc conservative
-GRADEFLAGS-rational_test_init	=	--gc conservative
-
 C2INITFLAGS-parse		= 	--trace
 MLFLAGS-parse			=	--trace --static
 
@@ -282,6 +276,15 @@
 			< $@.tmp > $@; \
 		rm -f $@.tmp; \
 	fi
+
+# These tests run out of memory in non-GC grades
+# unless we increase the heap size from the default 4M.
+# The sizes specified here (70 Mb and 20 Mb respectively)
+# are sufficient for running these tests on 64-bit systems.
+integer_test.out: integer_test
+	MERCURY_OPTIONS="--heap-size 70000" ./integer_test > $@ 2>&1
+rational_test.out: rational_test
+	MERCURY_OPTIONS="--heap-size 20000" ./rational_test > $@ 2>&1
 
 #-----------------------------------------------------------------------------#
 
Index: trace/mercury_trace_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_util.c,v
retrieving revision 1.5
diff -u -d -r1.5 mercury_trace_util.c
--- trace/mercury_trace_util.c	10 Dec 2000 20:59:01 -0000	1.5
+++ trace/mercury_trace_util.c	22 Nov 2001 07:12:49 -0000
@@ -38,6 +38,7 @@
 void
 MR_print_stack_regs(FILE *fp, MR_Word *saved_regs)
 {
+#ifndef MR_HIGHLEVEL_CODE
 	fprintf(fp, "sp = ");
 	MR_print_detstackptr(fp, MR_saved_sp(saved_regs));
 	fprintf(fp, "\ncurfr = ");
@@ -45,11 +46,13 @@
 	fprintf(fp, "\nmaxfr = ");
 	MR_print_nondstackptr(fp, MR_saved_maxfr(saved_regs));
 	fprintf(fp, "\n");
+#endif
 }
 
 void
 MR_print_heap_regs(FILE *fp, MR_Word *saved_regs)
 {
+#ifndef MR_CONSERVATIVE_GC
 	fprintf(fp, "hp = ");
 	MR_print_heapptr(fp, MR_saved_hp(saved_regs));
 	fprintf(fp, "\nsol_hp = ");
@@ -59,26 +62,32 @@
 	fprintf(fp, "\nglobal_hp = ");
 	MR_print_heapptr(fp, MR_saved_global_hp(saved_regs));
 	fprintf(fp, "\n");
+#endif
 }
 
 void
 MR_print_tabling_regs(FILE *fp, MR_Word *saved_regs)
 {
+#ifdef MR_USE_MINIMAL_MODEL
 	fprintf(fp, "gen_next = %ld\n", (long) MR_saved_gen_next(saved_regs));
 	fprintf(fp, "cut_next = %ld\n", (long) MR_saved_cut_next(saved_regs));
+#endif
 }
 
 void
 MR_print_succip_reg(FILE *fp, MR_Word *saved_regs)
 {
+#ifndef MR_HIGHLEVEL_CODE
 	fprintf(fp, "succip = ");
 	MR_print_label(fp, MR_saved_succip(saved_regs));
 	fprintf(fp, "\n");
+#endif
 }
 
 void
 MR_print_r_regs(FILE *fp, MR_Word *saved_regs)
 {
+#ifndef MR_HIGHLEVEL_CODE
 	fprintf(fp, "r1 = %ld (%lx)\n",
 		(long) MR_saved_reg(saved_regs, 1),
 		(long) MR_saved_reg(saved_regs, 1));
@@ -94,4 +103,5 @@
 	fprintf(fp, "r5 = %ld (%lx)\n",
 		(long) MR_saved_reg(saved_regs, 5),
 		(long) MR_saved_reg(saved_regs, 5));
+#endif
 }

-- 
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