[m-rev.] for review: fix deep profiling test case failures

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Oct 31 15:40:09 AEDT 2002


For review by anyone.

Zoltan.

Fix several occurrences of a bug that prevented the compiler from passing
all the tests in deep profiling grades. We now pass all the tests in deep
profiling grades.

Some additional changes were useful in tracking this bug down. Using C types
to represent deep profiling data structures allowed us to delete a bunch of
casts and thus eliminate them as potential bug locations. Another was to fix
some bugs in low level debugging support.

In light of the fragility of the deep profiling invariants, always check them
when writing out deep profiling data files. Since mdprof depends on these
invariants, they have to be checked somewhere, and we already have code for the
checks in the runtime.

Reenable tail recursion support in deep profiling grades, since it now works.
(The bug this change fixes used to occur most in tail recursive procedures,
which is why previously I turned it off.)

compiler/options.m:
	Reenable tail recursion support in deep profiling grades.

runtime/mercury_unify_compare_body.h:
	Fix the bug that prevented us from passing all the tests with
	invariants checked and tail recursion support enabled. The bug was
	that in several cases, the code in mercury_unify_compare_body.h
	did not invoke the appropriate deep profiling routines and thus
	did not fill in the deep profiling data structure they were supposed to
	fill in, breaking an invariant.

	There were several instances of this bug: unify, compare and
	compare_representation on tuples, and compare_representation on
	functions, predicates and user-defined types.

	These oversights were possible because the actions of returning an
	answer and filling in the deep profiling data structures (in deep
	profiling grades) were separate. If one omitted the latter, tests could
	still work in all grades except deep profiling grades.

	The fix therefore uses one macro (return_compare_answer or return
	unify_answer, depending on the the operation) to fill in the deep
	profiling data structure (in deep profiling grades) and return the
	answer, making it impossible to forget to do the former.

	The new approach treats compare_representation the same as compare,
	and gathers the same information for it.

runtime/mercury_ho_call.c:
	Factor out some commonalities in the definitions of the MR_ProcStatic
	data structures used by the code in mercury_unify_compare_body.h.

	Change a macro name to support the changes in
	mercury_unify_compare_body.h.

	Change the module name of compare_representation/3 from std_util to
	builtin, to match unify/2 and compare/3.

compiler/deep_profiling.m:
	Treat compare_representation/3 the same way as we treat compare/3.

library/builtin.m
library/std_util.m
	Move the declaration of compare_representation/3 from std_util to
	builtin, to make it easier to handle it the same way as compare/3.
	Since it is just a variant of compare/3 and is at least as built
	into the implementation, it belongs there anyway.

library/profiling_builtin.m:
	Use C types to represent deep profiling data structures.
	Delete the casts that are redundant after this change.

	Fix formatting of foreign_procs.

runtime/mercury_deep_profiling.c:
	As mentioned above, always check the invariants of the deep profiling
	data structures when writing them out.

runtime/mercury_deep_profiling.h:
	Avoid a warning about nested declarations of variable "i".

runtime/mercury_deep_rec_depth_body.h:
	Delete a bunch of casts we don't need anymore.

runtime/mercury_wrapper.[ch]:
	Initialize a couple of predicate names in the low level debug support
	to "" instead of NULL. The code that accesses these variables passes
	them to strcmp directly, which lead to core dumps. We could change the
	accessing code to test for NULL, but since that code is executed on
	every call when low level debugging is enabled, that would lead to
	even greater slowdowns, which we can do without.

	To avoid a warning about casting away const, make the variables
	involved "const char *" instead of plain "char *"; we don't want
	to update the pointed-to strings anyway.

tools/bootcheck:
	In profiling grades, write out profiling data files by default, and
	require the use of an option to turn them off. This is needed to make
	sure that the deep profiling invariants are checked by default.

tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.m:
	Avoid hard-coding the name of the module defining
	compare_representation/3.

cvs diff: Diffing .
cvs diff: Diffing bench
cvs diff: Diffing bench/progs
cvs diff: Diffing bench/progs/compress
cvs diff: Diffing bench/progs/icfp2000
cvs diff: Diffing bench/progs/icfp2001
cvs diff: Diffing bench/progs/nuc
cvs diff: Diffing bench/progs/ray
cvs diff: Diffing bench/progs/tree234
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.11
diff -u -b -r1.11 deep_profiling.m
--- compiler/deep_profiling.m	14 Aug 2002 06:41:26 -0000	1.11
+++ compiler/deep_profiling.m	29 Oct 2002 05:23:45 -0000
@@ -1428,7 +1428,8 @@
 :- type call_class
 			% For normal first order calls
 	--->	normal(pred_proc_id)
-			% For calls to unify/2 and compare/3
+			% For calls to unify/2, compare/3 and
+			% compare_representation/3
 	;	special(pred_proc_id, prog_var)
 			% For higher order and typeclass method calls
 	;	generic(generic_call).
@@ -1449,6 +1450,13 @@
 		;
 			predicate_table_search_pred_m_n_a(PredTable,
 				MercuryBuiltin, "compare", 3, [PredId]),
+			Args = [TypeInfoVar | _]
+		->
+			Class = special(proc(PredId, ProcId), TypeInfoVar)
+		;
+			predicate_table_search_pred_m_n_a(PredTable,
+				MercuryBuiltin, "compare_representation", 3,
+				[PredId]),
 			Args = [TypeInfoVar | _]
 		->
 			Class = special(proc(PredId, ProcId), TypeInfoVar)
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.391
diff -u -b -r1.391 options.m
--- compiler/options.m	30 Oct 2002 13:31:49 -0000	1.391
+++ compiler/options.m	31 Oct 2002 01:36:12 -0000
@@ -792,8 +792,8 @@
 				-	bool(yes),
 	use_lots_of_ho_specialization
 				-	bool(no),
-	deep_profile_tail_recursion	-	bool(no),
-					% XXX doesn't work at the moment
+	deep_profile_tail_recursion
+				-	bool(yes),
 		% (c) Miscellaneous optional features
 	gc			-	string("boehm"),
 	parallel		-	bool(no),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.80
diff -u -b -r1.80 builtin.m
--- library/builtin.m	24 Sep 2002 06:55:16 -0000	1.80
+++ library/builtin.m	29 Oct 2002 05:23:08 -0000
@@ -259,6 +259,27 @@
 :-        mode get_one_solution_io(pred(out, di, uo) is cc_multi,
 		out, di, uo) is det.
 
+% compare_representation(Result, X, Y)
+%
+% compare_representation is similar to the builtin predicate
+% compare/3, except that it does not abort when asked to compare
+% non-canonical terms.
+%
+% The declarative semantics of compare_representation for unequal
+% non-canonical terms is that the result is either (<) or (>).  For
+% equal non-canonical terms the result can be anything.
+%
+% Operationally, the result of compare_representation for
+% non-canonical terms is the same as that for comparing the internal
+% representations of the terms, where the internal representation is
+% that which would be produced by deconstruct__cc.
+%
+% XXX This predicate is not yet implemented for highlevel code.  This
+% is the reason it is not in the official part of the interface.
+
+:- pred compare_representation(comparison_result, T, T).
+:- mode compare_representation(uo, in, in) is cc_multi.
+
 :- implementation.
 :- import_module require, string, std_util, int, float, char, string, list.
 
@@ -334,6 +355,7 @@
 
 :- external(unify/2).
 :- external(compare/3).
+:- external(compare_representation/3).
 
 %-----------------------------------------------------------------------------%
 
Index: library/profiling_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/profiling_builtin.m,v
retrieving revision 1.12
diff -u -b -r1.12 profiling_builtin.m
--- library/profiling_builtin.m	26 Aug 2002 06:00:53 -0000	1.12
+++ library/profiling_builtin.m	3 Oct 2002 12:59:16 -0000
@@ -235,6 +235,16 @@
 :- type proc_dynamic		---> proc_dynamic(c_pointer).
 :- type call_site_dynamic	---> call_site_dynamic(c_pointer).
 
+:- pragma foreign_type("C", proc_static, 	"MR_ProcStatic *").
+:- pragma foreign_type("C", proc_dynamic,	"MR_ProcDynamic *").
+:- pragma foreign_type("C", call_site_dynamic,	"MR_CallSiteDynamic *").
+
+% The IL type definitions are dummies. They are needed to compile the library
+% in IL grades, but deep profiling is not (yet) supported in IL grades.
+:- pragma foreign_type(il, proc_static,       "class [mscorlib]System.Object").
+:- pragma foreign_type(il, proc_dynamic,      "class [mscorlib]System.Object").
+:- pragma foreign_type(il, call_site_dynamic, "class [mscorlib]System.Object").
+
 :- pragma foreign_decl("C", "
 #ifndef	MR_DEEP_PROFILING_GUARD
 #define	MR_DEEP_PROFILING_GUARD
@@ -281,8 +291,10 @@
 % Procedures that prepare for calls
 %---------------------------------------------------------------------------%
 
-:- pragma foreign_proc("C", prepare_for_normal_call(N::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	prepare_for_normal_call(N::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
@@ -316,8 +328,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", prepare_for_special_call(CSN::in, TypeInfo::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	prepare_for_special_call(CSN::in, TypeInfo::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
@@ -362,12 +376,15 @@
 
 	MR_leave_instrumentation();
 #else
-	MR_fatal_error(""prepare_for_special_call: deep profiling not enabled"");
+	MR_fatal_error(
+		""prepare_for_special_call: deep profiling not enabled"");
 #endif
 }").
 
-:- pragma foreign_proc("C", prepare_for_ho_call(CSN::in, Closure::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	prepare_for_ho_call(CSN::in, Closure::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
@@ -420,7 +437,8 @@
 
 :- pragma foreign_proc("C",
 	prepare_for_method_call(CSN::in, TypeClassInfo::in, MethodNum::in),
-		[thread_safe, will_not_call_mercury], "{
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
@@ -465,8 +483,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", prepare_for_callback(CSN::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	prepare_for_callback(CSN::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
@@ -489,8 +509,10 @@
 % Procedures needed for handling tail recursive procedures
 %---------------------------------------------------------------------------%
 
-:- pragma foreign_proc("C", prepare_for_tail_call(CSN::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	prepare_for_tail_call(CSN::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*child_csd;
 	MR_CallSiteDynamic	*csd;
@@ -535,7 +557,8 @@
 
 :- pragma foreign_proc("C",
 	save_and_zero_activation_info_ac(Count::out, Ptr::out),
-		[thread_safe, will_not_call_mercury], "{
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -551,7 +574,7 @@
 
 	Count = ps->MR_ps_activation_count;
 	ps->MR_ps_activation_count = 0;
-	Ptr = (MR_Word) ps->MR_ps_outermost_activation_ptr;
+	Ptr = ps->MR_ps_outermost_activation_ptr;
 	ps->MR_ps_outermost_activation_ptr = NULL;
 	MR_leave_instrumentation();
   #else
@@ -562,8 +585,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", save_and_zero_activation_info_sr(Ptr::out),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	save_and_zero_activation_info_sr(Ptr::out),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -577,7 +602,7 @@
 	MR_deep_assert(csd, NULL, pd != NULL);
 	ps = pd->MR_pd_proc_static;
 
-	Ptr = (MR_Word) ps->MR_ps_outermost_activation_ptr;
+	Ptr = ps->MR_ps_outermost_activation_ptr;
 	ps->MR_ps_outermost_activation_ptr = NULL;
 	MR_leave_instrumentation();
   #else
@@ -588,8 +613,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", rezero_activation_info_ac,
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	rezero_activation_info_ac,
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -614,8 +641,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", rezero_activation_info_sr,
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	rezero_activation_info_sr,
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -639,8 +668,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", reset_activation_info_ac(Count::in, Ptr::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	reset_activation_info_ac(Count::in, Ptr::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -655,7 +686,7 @@
 	ps = pd->MR_pd_proc_static;
 
 	ps->MR_ps_activation_count = Count;
-	ps->MR_ps_outermost_activation_ptr = (MR_ProcDynamic *) Ptr;
+	ps->MR_ps_outermost_activation_ptr = Ptr;
 	MR_leave_instrumentation();
   #else
 	MR_fatal_error(""reset_activation_info_ac called when not using activation counts!"");
@@ -665,8 +696,10 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", reset_activation_info_sr(Ptr::in),
-		[thread_safe, will_not_call_mercury], "{
+:- pragma foreign_proc("C",
+	reset_activation_info_sr(Ptr::in),
+	[thread_safe, will_not_call_mercury],
+"{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
@@ -680,7 +713,7 @@
 	MR_deep_assert(csd, NULL, pd != NULL);
 	ps = pd->MR_pd_proc_static;
 
-	ps->MR_ps_outermost_activation_ptr = (MR_ProcDynamic *) Ptr;
+	ps->MR_ps_outermost_activation_ptr = Ptr;
 	MR_leave_instrumentation();
   #else
 	MR_fatal_error(""reset_activation_info_sr called when using activation counts!"");
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.272
diff -u -b -r1.272 std_util.m
--- library/std_util.m	21 Jun 2002 13:26:50 -0000	1.272
+++ library/std_util.m	29 Oct 2002 05:22:30 -0000
@@ -721,27 +721,6 @@
 	%
 :- pred dynamic_cast(T1::in, T2::out) is semidet.
 
-	% compare_representation(Result, X, Y)
-	%
-	% compare_representation is similar to the builtin predicate
-	% compare/3, except that it does not abort when asked to compare
-	% non-canonical terms.
-	%
-	% The declarative semantics of compare_representation for unequal
-	% non-canonical terms is that the result is either (<) or (>).  For
-	% equal non-canonical terms the result can be anything.
-	%
-	% Operationally, the result of compare_representation for
-	% non-canonical terms is the same as that for comparing the internal
-	% representations of the terms, where the internal representation is
-	% that which would be produced by deconstruct__cc.
-	%
-	% XXX This predicate is not yet implemented for highlevel code.  This
-	% is the reason it is not in the official part of the interface.
-	%
-:- pred compare_representation(comparison_result, T, T).
-:- mode compare_representation(uo, in, in) is cc_multi.
-
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -1698,8 +1677,6 @@
 det_named_argument_cc(Type, Name, ArgumentUniv) :-
 	deconstruct__det_named_arg(Type, include_details_cc, Name, Argument),
 	type_to_univ(Argument, ArgumentUniv).
-
-:- external(compare_representation/3).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_deep_profiling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.c,v
retrieving revision 1.9
diff -u -b -r1.9 mercury_deep_profiling.c
--- runtime/mercury_deep_profiling.c	14 Aug 2002 06:41:33 -0000	1.9
+++ runtime/mercury_deep_profiling.c	1 Oct 2002 18:38:49 -0000
@@ -10,6 +10,9 @@
 **	Authors: conway, zs
 */
 
+/* turn on assertions, to protect the integrity of the generated data files */
+#define	MR_DEEP_CHECKS
+
 #include "mercury_imp.h"
 #include "mercury_ho_call.h"
 #include "mercury_stack_layout.h"
Index: runtime/mercury_deep_profiling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.h,v
retrieving revision 1.9
diff -u -b -r1.9 mercury_deep_profiling.h
--- runtime/mercury_deep_profiling.h	14 Aug 2002 06:41:33 -0000	1.9
+++ runtime/mercury_deep_profiling.h	3 Oct 2002 06:04:10 -0000
@@ -201,7 +201,7 @@
 
 #define	MR_new_proc_dynamic(pd, ps)					\
 	do {								\
-		int	i;						\
+		int	npdi;						\
 									\
 		(pd) = MR_PROFILING_MALLOC(MR_ProcDynamic);		\
 		(pd)->MR_pd_proc_static = (ps);				\
@@ -209,8 +209,8 @@
 			MR_PROFILING_MALLOC_ARRAY(MR_CallSiteDynamic *,	\
 				(ps)->MR_ps_num_call_sites);		\
 									\
-		for (i = 0; i < (ps)->MR_ps_num_call_sites; i++) {	\
-			(pd)->MR_pd_call_site_ptr_ptrs[i] = NULL;	\
+		for (npdi = 0; npdi < (ps)->MR_ps_num_call_sites; npdi++) { \
+			(pd)->MR_pd_call_site_ptr_ptrs[npdi] = NULL;	\
 		}							\
 	} while (0)
 
Index: runtime/mercury_deep_rec_depth_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_rec_depth_body.h,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_deep_rec_depth_body.h
--- runtime/mercury_deep_rec_depth_body.h	14 Aug 2002 06:41:34 -0000	1.3
+++ runtime/mercury_deep_rec_depth_body.h	2 Oct 2002 18:14:04 -0000
@@ -32,7 +32,7 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
+	csd = CSD;
 	MR_deep_assert(csd, NULL, csd == MR_current_call_site_dynamic);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(csd, NULL, pd != NULL);
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.57
diff -u -b -r1.57 mercury_ho_call.c
--- runtime/mercury_ho_call.c	9 Aug 2002 05:26:49 -0000	1.57
+++ runtime/mercury_ho_call.c	30 Oct 2002 14:44:10 -0000
@@ -78,41 +78,29 @@
 		MR_proc_static_user_builtin_name(predname, 3, 0),	\
 		MR_own_exits)
 
-  MR_proc_static_user_builtin_empty(integer_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(integer_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(float_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(float_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(string_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(string_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(c_pointer_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(c_pointer_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typeinfo_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typeinfo_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typectorinfo_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typectorinfo_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typedesc_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typedesc_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typectordesc_unify, 2, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-  MR_proc_static_user_builtin_empty(typectordesc_compare, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
-
-  MR_proc_static_user_empty(std_util, compare_representation, 3, 0,
-	"mercury_ho_call.c", 0, MR_TRUE);
+  #define MR_define_unify_compare_proc_statics(builtin)			\
+	MR_proc_static_user_builtin_empty(				\
+		MR_PASTE2(builtin, _unify), 2, 0,			\
+		"mercury_ho_call.c", 0, MR_TRUE);			\
+	MR_proc_static_user_builtin_empty(				\
+		MR_PASTE2(builtin, _compare), 3, 0,			\
+		"mercury_ho_call.c", 0, MR_TRUE);			\
+	MR_proc_static_user_builtin_empty(				\
+		MR_PASTE2(builtin, _compare_representation), 3, 0,	\
+		"mercury_ho_call.c", 0, MR_TRUE)
+
+  MR_define_unify_compare_proc_statics(user);
+  MR_define_unify_compare_proc_statics(integer);
+  MR_define_unify_compare_proc_statics(float);
+  MR_define_unify_compare_proc_statics(string);
+  MR_define_unify_compare_proc_statics(c_pointer);
+  MR_define_unify_compare_proc_statics(typeinfo);
+  MR_define_unify_compare_proc_statics(typectorinfo);
+  MR_define_unify_compare_proc_statics(typedesc);
+  MR_define_unify_compare_proc_statics(typectordesc);
+  MR_define_unify_compare_proc_statics(tuple);
+  MR_define_unify_compare_proc_statics(func);
+  MR_define_unify_compare_proc_statics(pred);
 
 #endif
 
@@ -335,7 +323,7 @@
 }
 
 void MR_CALL
-mercury__std_util__compare_representation_3_p_0(MR_Mercury_Type_Info ti,
+mercury__builtin__compare_representation_3_p_0(MR_Mercury_Type_Info ti,
 	MR_Comparison_Result *res, MR_Box x, MR_Box y)
 {
 	MR_SORRY("compare_representation/3 for HIGHLEVEL_CODE");
@@ -400,7 +388,7 @@
 MR_define_extern_entry(mercury__compare_3_2);
 MR_define_extern_entry(mercury__compare_3_3);
 MR_declare_label(mercury__compare_3_0_i1);
-MR_define_extern_entry(mercury__std_util__compare_representation_3_0);
+MR_define_extern_entry(mercury__compare_representation_3_0);
 
 MR_BEGIN_MODULE(call_module)
 	MR_init_entry_an(mercury__do_call_closure);
@@ -410,7 +398,7 @@
 	MR_init_entry_an(mercury__compare_3_1);
 	MR_init_entry_an(mercury__compare_3_2);
 	MR_init_entry_an(mercury__compare_3_3);
-	MR_init_entry_an(mercury__std_util__compare_representation_3_0);
+	MR_init_entry_an(mercury__compare_representation_3_0);
 MR_BEGIN_CODE
 
 /*
@@ -543,7 +531,7 @@
 		saved_succip = MR_succip;				\
 	} while(0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_r1 = (answer);					\
 		MR_succip = saved_succip;				\
@@ -564,7 +552,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	tailcall_user_pred
 #undef	start_label
 #undef	call_user_code_label
@@ -616,7 +604,7 @@
 		saved_succip = MR_succip;				\
 	} while(0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_r1 = (answer);					\
 		MR_succip = saved_succip;				\
@@ -638,7 +626,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	tailcall_user_pred
 #undef	start_label
 #undef	call_user_code_label
@@ -650,12 +638,12 @@
 }
 
 /*
-** mercury__std_util__compare_representation_3_0 is called as
+** mercury__compare_representation_3_0 is called as
 ** `compare_representation(TypeInfo, Result, X, Y)' in the mode
 ** `compare_representation(in, uo, in, in) is cc_multi'.
 */
 
-MR_define_entry(mercury__std_util__compare_representation_3_0);
+MR_define_entry(mercury__compare_representation_3_0);
 {
 
 #define	DECLARE_LOCALS							\
@@ -672,7 +660,7 @@
 		saved_succip = MR_succip;				\
 	} while(0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_r1 = (answer);					\
 		MR_succip = saved_succip;				\
@@ -691,7 +679,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	start_label
 #undef	call_user_code_label
 #undef	type_stat_struct
@@ -716,7 +704,7 @@
 		MR_restore_transient_registers();			\
 	} while (0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_save_transient_registers();				\
 		return (answer);					\
@@ -740,7 +728,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	tailcall_user_pred
 #undef	start_label
 #undef	call_user_code_label
@@ -759,7 +747,7 @@
 		MR_restore_transient_registers();			\
 	} while (0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_save_transient_registers();				\
 		return (answer);					\
@@ -784,7 +772,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	tailcall_user_pred
 #undef	start_label
 #undef	call_user_code_label
@@ -804,7 +792,7 @@
 		MR_restore_transient_registers();			\
 	} while (0)
 
-#define return_answer(answer)						\
+#define raw_return_answer(answer)					\
 	do {								\
 		MR_save_transient_registers();				\
 		return (answer);					\
@@ -821,7 +809,7 @@
 
 #undef	DECLARE_LOCALS
 #undef	initialize
-#undef	return_answer
+#undef	raw_return_answer
 #undef	start_label
 #undef	call_user_code_label
 #undef	type_stat_struct
Index: runtime/mercury_ho_call.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ho_call.h,v
retrieving revision 1.7
diff -u -b -r1.7 mercury_ho_call.h
--- runtime/mercury_ho_call.h	9 Aug 2002 05:26:49 -0000	1.7
+++ runtime/mercury_ho_call.h	29 Oct 2002 05:56:58 -0000
@@ -135,7 +135,7 @@
 	MR_Comparison_Result *, MR_Box, MR_Box);
 void MR_CALL mercury__builtin__compare_3_p_3(MR_Mercury_Type_Info,
 	MR_Comparison_Result *, MR_Box, MR_Box);
-void MR_CALL mercury__std_util__compare_representation_3_p_0(
+void MR_CALL mercury__builtin__compare_representation_3_p_0(
 	MR_Mercury_Type_Info, MR_Comparison_Result *, MR_Box, MR_Box);
 
 #else	/* ! MR_HIGHLEVEL_CODE */
@@ -145,7 +145,7 @@
 MR_declare_entry(mercury__compare_3_1);
 MR_declare_entry(mercury__compare_3_2);
 MR_declare_entry(mercury__compare_3_3);
-MR_declare_entry(mercury__std_util__compare_representation_3_0);
+MR_declare_entry(mercury__compare_representation_3_0);
 
 #endif	/* MR_HIGHLEVEL_CODE */
 
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.26
diff -u -b -r1.26 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h	1 Aug 2002 11:52:29 -0000	1.26
+++ runtime/mercury_unify_compare_body.h	30 Oct 2002 14:50:03 -0000
@@ -43,6 +43,42 @@
 ** they support unifications but not comparisons. Since we cannot do it
 ** for such types, it is simplest not to do it for any types.
 */
+#ifdef  select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+    #ifdef include_compare_rep_code
+      #define return_compare_answer(kind, answer)                           \
+        do {                                                                \
+            compare_call_exit_code(MR_PASTE2(kind, _compare_representation)); \
+            raw_return_answer(answer);                                      \
+        } while (0)
+    #else
+      #define return_compare_answer(kind, answer)                           \
+        do {                                                                \
+            compare_call_exit_code(MR_PASTE2(kind, _compare));              \
+            raw_return_answer(answer);                                      \
+        } while (0)
+    #endif
+  #else
+    #define return_compare_answer(kind, answer)                             \
+        raw_return_answer(answer)
+  #endif
+#else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+    #define return_unify_answer(kind, answer)                               \
+        do {                                                                \
+            if (answer) {                                                   \
+                unify_call_exit_code(MR_PASTE2(kind, _unify));              \
+                raw_return_answer(MR_TRUE);                                 \
+            } else {                                                        \
+                unify_call_fail_code(MR_PASTE2(kind, _unify));              \
+                raw_return_answer(MR_FALSE);                                \
+            }                                                               \
+        } while (0)
+  #else
+    #define return_unify_answer(kind, answer)                               \
+        raw_return_answer(answer)
+  #endif
+#endif
 
     DECLARE_LOCALS
     initialize();
@@ -176,9 +212,9 @@
                     if (x_functor_desc->MR_du_functor_ordinal <
                         y_functor_desc->MR_du_functor_ordinal)
                     {
-                        return_answer(MR_COMPARE_LESS);
+                        return_compare_answer(user, MR_COMPARE_LESS);
                     } else {
-                        return_answer(MR_COMPARE_GREATER);
+                        return_compare_answer(user, MR_COMPARE_GREATER);
                     }
                 }
 
@@ -188,7 +224,7 @@
                 y_ptag = MR_tag(y);
 
                 if (x_ptag != y_ptag) {
-                    return_answer(MR_FALSE);
+                    return_unify_answer(user, MR_FALSE);
                 }
 
                 ptaglayout = &MR_type_ctor_layout(type_ctor_info).
@@ -202,7 +238,7 @@
                         y_sectag = MR_unmkbody(y_data_value);
 
                         if (x_sectag != y_sectag) {
-                            return_answer(MR_FALSE);
+                            return_unify_answer(user, MR_FALSE);
                         }
 
                         break;
@@ -212,7 +248,7 @@
                         y_sectag = y_data_value[0];
 
                         if (x_sectag != y_sectag) {
-                            return_answer(MR_FALSE);
+                            return_unify_answer(user, MR_FALSE);
                         }
 
                         break;
@@ -271,9 +307,9 @@
                         MR_restore_transient_registers();
                         if (result != MR_COMPARE_EQUAL) {
   #ifdef  select_compare_code
-                            return_answer(result);
+                            return_compare_answer(user, result);
   #else
-                            return_answer(MR_FALSE);
+                            return_unify_answer(user, MR_FALSE);
   #endif
                         }
                     }
@@ -306,7 +342,7 @@
     #endif
                     MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
-                        return_answer(result);
+                        return_compare_answer(user, result);
                     }
   #else
                     MR_save_transient_registers();
@@ -314,16 +350,16 @@
                         x_data_value[cur_slot], y_data_value[cur_slot]);
                     MR_restore_transient_registers();
                     if (! result) {
-                        return_answer(MR_FALSE);
+                        return_unify_answer(user, MR_FALSE);
                     }
   #endif
                     cur_slot++;
                 }
 
   #ifdef  select_compare_code
-                return_answer(MR_COMPARE_EQUAL);
+                return_compare_answer(user, MR_COMPARE_EQUAL);
   #else
-                return_answer(MR_TRUE);
+                return_unify_answer(user, MR_TRUE);
   #endif
             }
 
@@ -426,7 +462,7 @@
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
                     MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
-                        return_answer(result);
+                        return_compare_answer(tuple, result);
                     }
 #else
                     MR_save_transient_registers();
@@ -434,14 +470,14 @@
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
                     MR_restore_transient_registers();
                     if (! result) {
-                        return_answer(MR_FALSE);
+                        return_unify_answer(tuple, MR_FALSE);
                     }
 #endif
                 }
 #ifdef  select_compare_code
-                return_answer(MR_COMPARE_EQUAL);
+                return_compare_answer(tuple, MR_COMPARE_EQUAL);
 #else
-                return_answer(MR_TRUE);
+                return_unify_answer(tuple, MR_TRUE);
 #endif
             }
 
@@ -454,28 +490,15 @@
         case MR_TYPECTOR_REP_CHAR:
 
 #ifdef  select_compare_code
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-            compare_call_exit_code(integer_compare);
-  #endif
             if ((MR_Integer) x == (MR_Integer) y) {
-                return_answer(MR_COMPARE_EQUAL);
+                return_compare_answer(integer, MR_COMPARE_EQUAL);
             } else if ((MR_Integer) x < (MR_Integer) y) {
-                return_answer(MR_COMPARE_LESS);
+                return_compare_answer(integer, MR_COMPARE_LESS);
             } else {
-                return_answer(MR_COMPARE_GREATER);
+                return_compare_answer(integer, MR_COMPARE_GREATER);
             }
 #else
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-            if ((MR_Integer) x == (MR_Integer) y) {
-                unify_call_exit_code(integer_unify);
-                return_answer(MR_TRUE);
-            } else {
-                unify_call_fail_code(integer_unify);
-                return_answer(MR_FALSE);
-            }
-  #else
-            return_answer((MR_Integer) x == (MR_Integer) y);
-  #endif
+            return_unify_answer(integer, (MR_Integer) x == (MR_Integer) y);
 #endif
 
         case MR_TYPECTOR_REP_FLOAT:
@@ -485,28 +508,15 @@
                 fx = MR_word_to_float(x);
                 fy = MR_word_to_float(y);
 #ifdef  select_compare_code
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(float_compare);
-  #endif
                 if (fx == fy) {
-                    return_answer(MR_COMPARE_EQUAL);
+                    return_compare_answer(float, MR_COMPARE_EQUAL);
                 } else if (fx < fy) {
-                    return_answer(MR_COMPARE_LESS);
+                    return_compare_answer(float, MR_COMPARE_LESS);
                 } else {
-                    return_answer(MR_COMPARE_GREATER);
+                    return_compare_answer(float, MR_COMPARE_GREATER);
                 }
 #else
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (fx == fy) {
-                    unify_call_exit_code(float_unify);
-                    return_answer(MR_TRUE);
-                } else {
-                    unify_call_fail_code(float_unify);
-                    return_answer(MR_FALSE);
-                }
-  #else
-                return_answer(fx == fy);
-  #endif
+                return_unify_answer(float, fx == fy);
 #endif
             }
 
@@ -517,55 +527,29 @@
                 result = strcmp((char *) x, (char *) y);
 
 #ifdef  select_compare_code
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(string_compare);
-  #endif
                 if (result == 0) {
-                    return_answer(MR_COMPARE_EQUAL);
+                    return_compare_answer(string, MR_COMPARE_EQUAL);
                 } else if (result < 0) {
-                    return_answer(MR_COMPARE_LESS);
+                    return_compare_answer(string, MR_COMPARE_LESS);
                 } else {
-                    return_answer(MR_COMPARE_GREATER);
+                    return_compare_answer(string, MR_COMPARE_GREATER);
                 }
 #else
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (result == 0) {
-                    unify_call_exit_code(string_unify);
-                    return_answer(MR_TRUE);
-                } else {
-                    unify_call_fail_code(string_unify);
-                    return_answer(MR_FALSE);
-                }
-  #else
-                return_answer(result == 0);
-  #endif
+                return_unify_answer(string, result == 0);
 #endif
             }
 
         case MR_TYPECTOR_REP_C_POINTER:
 #ifdef  select_compare_code
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-            compare_call_exit_code(c_pointer_compare);
-  #endif
             if ((void *) x == (void *) y) {
-                return_answer(MR_COMPARE_EQUAL);
+                return_compare_answer(c_pointer, MR_COMPARE_EQUAL);
             } else if ((void *) x < (void *) y) {
-                return_answer(MR_COMPARE_LESS);
+                return_compare_answer(c_pointer, MR_COMPARE_LESS);
             } else {
-                return_answer(MR_COMPARE_GREATER);
+                return_compare_answer(c_pointer, MR_COMPARE_GREATER);
             }
 #else
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-            if ((void *) x == (void *) y) {
-                unify_call_exit_code(c_pointer_unify);
-                return_answer(MR_TRUE);
-            } else {
-                unify_call_fail_code(c_pointer_unify);
-                return_answer(MR_FALSE);
-            }
-  #else
-            return_answer((void *) x == (void *) y);
-  #endif
+            return_unify_answer(c_pointer, (void *) x == (void *) y);
 #endif
 
         case MR_TYPECTOR_REP_TYPEINFO:
@@ -577,10 +561,7 @@
                 result = MR_compare_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(typeinfo_compare);
-  #endif
-                return_answer(result);
+                return_compare_answer(typeinfo, result);
 #else
                 MR_bool result;
 
@@ -588,14 +569,7 @@
                 result = MR_unify_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (result) {
-                    unify_call_exit_code(typeinfo_unify);
-                } else {
-                    unify_call_fail_code(typeinfo_unify);
-                }
-  #endif
-                return_answer(result);
+                return_unify_answer(typeinfo, result);
 #endif
             }
 
@@ -613,10 +587,7 @@
                 result = MR_compare_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(typedesc_compare);
-  #endif
-                return_answer(result);
+                return_compare_answer(typedesc, result);
 #else
                 MR_bool result;
 
@@ -624,14 +595,7 @@
                 result = MR_unify_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (result) {
-                    unify_call_exit_code(typedesc_unify);
-                } else {
-                    unify_call_fail_code(typedesc_unify);
-                }
-  #endif
-                return_answer(result);
+                return_unify_answer(typedesc, result);
 #endif
             }
 
@@ -644,10 +608,7 @@
                 result = MR_compare_type_ctor_info(
                     (MR_TypeCtorInfo) x, (MR_TypeCtorInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(typectorinfo_compare);
-  #endif
-                return_answer(result);
+                return_compare_answer(typectorinfo, result);
 #else
                 MR_bool result;
 
@@ -655,14 +616,7 @@
                 result = MR_unify_type_ctor_info(
                     (MR_TypeCtorInfo) x, (MR_TypeCtorInfo) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (result) {
-                    unify_call_exit_code(typectorinfo_unify);
-                } else {
-                    unify_call_fail_code(typectorinfo_unify);
-                }
-  #endif
-                return_answer(result);
+                return_unify_answer(typectorinfo, result);
 #endif
             }
 
@@ -675,10 +629,7 @@
                 result = MR_compare_type_ctor_desc(
                     (MR_TypeCtorDesc) x, (MR_TypeCtorDesc) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                compare_call_exit_code(typectordesc_compare);
-  #endif
-                return_answer(result);
+                return_compare_answer(typectordesc, result);
 #else
                 MR_bool result;
 
@@ -686,14 +637,7 @@
                 result = MR_unify_type_ctor_desc(
                     (MR_TypeCtorDesc) x, (MR_TypeCtorDesc) y);
                 MR_restore_transient_registers();
-  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-                if (result) {
-                    unify_call_exit_code(typectordesc_unify);
-                } else {
-                    unify_call_fail_code(typectordesc_unify);
-                }
-  #endif
-                return_answer(result);
+                return_unify_answer(typectordesc, result);
 #endif
             }
 
@@ -710,7 +654,12 @@
                 result = MR_compare_closures((MR_Closure *) x,
                             (MR_Closure *) y);
                 MR_restore_transient_registers();
-                return_answer(result);
+
+                if (MR_type_ctor_rep(type_ctor_info) == MR_TYPECTOR_REP_FUNC) {
+                    return_compare_answer(func, result);
+                } else {
+                    return_compare_answer(pred, result);
+                }
 #else
                 MR_fatal_error(attempt_msg "higher-order terms");
 #endif
@@ -731,3 +680,9 @@
         default:
             MR_fatal_error(attempt_msg "terms of unknown representation");
     }
+
+#ifdef  select_compare_code
+  #undef    return_compare_answer
+#else
+  #undef    return_unify_answer
+#endif
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.113
diff -u -b -r1.113 mercury_wrapper.c
--- runtime/mercury_wrapper.c	30 Oct 2002 16:18:12 -0000	1.113
+++ runtime/mercury_wrapper.c	31 Oct 2002 02:39:34 -0000
@@ -151,7 +151,7 @@
 MR_CallSiteDynamic
 		*MR_watch_csd_addr = NULL;
 MR_bool		MR_watch_csd_started = MR_FALSE;
-char		*MR_watch_csd_start_name = NULL;
+const char	*MR_watch_csd_start_name = "";	/* must not be NULL */
 
 unsigned long	MR_lld_cur_call = 0;
 MR_bool		MR_lld_print_enabled = MR_FALSE;
@@ -159,7 +159,7 @@
 MR_bool		MR_lld_print_csd_enabled = MR_FALSE;
 MR_bool		MR_lld_print_region_enabled = MR_FALSE;
 
-char		*MR_lld_start_name = NULL;
+const char	*MR_lld_start_name = "";	/* must not be NULL */
 unsigned	MR_lld_start_block = 100;	/* by default, print stuff */
 						/* for a block of 100 calls */
 unsigned long	MR_lld_start_until = (unsigned long) -1;
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.55
diff -u -b -r1.55 mercury_wrapper.h
--- runtime/mercury_wrapper.h	25 Sep 2002 07:54:13 -0000	1.55
+++ runtime/mercury_wrapper.h	3 Oct 2002 04:57:23 -0000
@@ -227,7 +227,7 @@
 extern	MR_CallSiteDynamic
 			*MR_watch_csd_addr;
 extern	MR_bool		MR_watch_csd_started;
-extern	char		*MR_watch_csd_start_name;
+extern	const char	*MR_watch_csd_start_name;
 
 extern	unsigned long	MR_lld_cur_call;
 extern	MR_bool		MR_lld_print_enabled;
@@ -235,7 +235,7 @@
 extern	MR_bool		MR_lld_print_csd_enabled;
 extern	MR_bool		MR_lld_print_region_enabled;
 
-extern	char		*MR_lld_start_name;
+extern	const char	*MR_lld_start_name;
 extern	unsigned	MR_lld_start_block;
 extern	unsigned long	MR_lld_start_until;
 extern	unsigned long	MR_lld_csd_until;
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
Index: tests/hard_coded/compare_rep_usereq.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/compare_rep_usereq.m,v
retrieving revision 1.1
diff -u -b -r1.1 compare_rep_usereq.m
--- tests/hard_coded/compare_rep_usereq.m	25 Apr 2002 09:31:59 -0000	1.1
+++ tests/hard_coded/compare_rep_usereq.m	29 Oct 2002 15:13:28 -0000
@@ -30,8 +30,7 @@
 	io__nl,
 	io__write_string(SB),
 	io__nl,
-	{ std_util__compare_representation(Res, A, B) },
+	{ compare_representation(Res, A, B) },
 	io__write_string("Result = "),
 	io__write(Res),
 	io__write_string(".\n\n").
-
Index: tests/hard_coded/compare_representation.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/compare_representation.m,v
retrieving revision 1.1
diff -u -b -r1.1 compare_representation.m
--- tests/hard_coded/compare_representation.m	25 Apr 2002 09:31:59 -0000	1.1
+++ tests/hard_coded/compare_representation.m	29 Oct 2002 15:13:35 -0000
@@ -38,8 +38,7 @@
 	io__nl,
 	io__write_string(SB),
 	io__nl,
-	{ std_util__compare_representation(Res, A, B) },
+	{ compare_representation(Res, A, B) },
 	io__write_string("Result = "),
 	io__write(Res),
 	io__write_string(".\n\n").
-
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/typeclasses
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.141
diff -u -b -r1.141 bootcheck
--- tools/bootcheck	23 Oct 2002 16:46:23 -0000	1.141
+++ tools/bootcheck	29 Oct 2002 10:36:59 -0000
@@ -90,12 +90,11 @@
 	--compile-times
 		Report information about compilation times in the stage 2
 		library and compiler directories.
-	--write-out-profile-data
-		When doing bootcheck in a deep profiling grade, enable the
-		writing out of profile data files. Since all compilations save
-		their profiling data in the same file, this is useful mainly to
-		check that we don't get fatal errors during the writing out
-		process.
+	--no-write-out-profile-data
+		When doing bootcheck in a deep profiling grade, disable the
+		writing out of profile data files. This makes the bootcheck
+		faster, but avoiding writing out the profiling data also avoids
+		the checks on its integrity.
 	--type-stats TYPE_STATS_FILE_NAME
 		Collect statistics about the builtin operations (unify, index
 		and compare) performed on various types. The argument of this
@@ -156,7 +155,7 @@
 fi
 use_mmc_make=no
 compile_times=false
-write_out_profile_data=false
+write_out_profile_data=true
 type_stats=""
 
 if test -r .KEEP_OBJS
@@ -169,9 +168,9 @@
 	grade=`cat .BOOT_GRADE`
 fi
 
-if test -f .WRITE_DEEP
+if test -f .NO_WRITE_DEEP
 then
-	write_out_profile_data=true
+	write_out_profile_data=false
 fi
 
 # If you change these, you will also need to change scripts/ml.in,
@@ -286,8 +285,8 @@
 	--no-compile-times)
 		compile_times=false ;;
 
-	--write-out-profile-data)
-		write_out_profile_data=true ;;
+	--no-write-out-profile-data)
+		write_out_profile_data=false ;;
 
 	--type-stats)
 		type_stats="$2"; shift ;;
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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