[m-rev.] fix deep profiling (part 2 of 2)

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed May 19 15:33:25 AEST 2004


Index: library/profiling_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/profiling_builtin.m,v
retrieving revision 1.13
diff -u -b -r1.13 profiling_builtin.m
--- library/profiling_builtin.m	8 Nov 2002 00:44:24 -0000	1.13
+++ library/profiling_builtin.m	19 May 2004 03:54:29 -0000
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 2001-2002 The University of Melbourne.
+% Copyright (C) 2001-2003 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -20,7 +20,7 @@
 
 :- interface.
 
-:- type proc_static.
+:- type proc_layout.
 :- type proc_dynamic.
 :- type call_site_dynamic.
 
@@ -36,10 +36,10 @@
 
 :- impure pred prepare_for_tail_call(int::in) is det.
 
-:- impure pred det_call_port_code_ac(proc_static::in,
+:- impure pred det_call_port_code_ac(proc_layout::in,
 	call_site_dynamic::out, call_site_dynamic::out) is det.
 
-:- impure pred det_call_port_code_sr(proc_static::in, call_site_dynamic::out,
+:- impure pred det_call_port_code_sr(proc_layout::in, call_site_dynamic::out,
 	call_site_dynamic::out, proc_dynamic::out) is det.
 
 :- impure pred det_exit_port_code_ac(call_site_dynamic::in,
@@ -48,10 +48,10 @@
 :- impure pred det_exit_port_code_sr(call_site_dynamic::in,
 	call_site_dynamic::in, proc_dynamic::in) is det.
 
-:- impure pred semi_call_port_code_ac(proc_static::in,
+:- impure pred semi_call_port_code_ac(proc_layout::in,
 	call_site_dynamic::out, call_site_dynamic::out) is det.
 
-:- impure pred semi_call_port_code_sr(proc_static::in, call_site_dynamic::out,
+:- impure pred semi_call_port_code_sr(proc_layout::in, call_site_dynamic::out,
 	call_site_dynamic::out, proc_dynamic::out) is det.
 
 :- impure pred semi_exit_port_code_ac(call_site_dynamic::in,
@@ -66,10 +66,10 @@
 :- impure pred semi_fail_port_code_sr(call_site_dynamic::in,
 	call_site_dynamic::in, proc_dynamic::in) is failure.
 
-:- impure pred non_call_port_code_ac(proc_static::in, call_site_dynamic::out,
+:- impure pred non_call_port_code_ac(proc_layout::in, call_site_dynamic::out,
 	call_site_dynamic::out, proc_dynamic::out) is det.
 
-:- impure pred non_call_port_code_sr(proc_static::in, call_site_dynamic::out,
+:- impure pred non_call_port_code_sr(proc_layout::in, call_site_dynamic::out,
 	call_site_dynamic::out, proc_dynamic::out, proc_dynamic::out) is det.
 
 :- impure pred non_exit_port_code_ac(call_site_dynamic::in,
@@ -231,17 +231,17 @@
 
 :- implementation.
 
-:- type proc_static		---> proc_static(c_pointer).
+:- type proc_layout		---> proc_layout(c_pointer).
 :- 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_layout, 	"MR_Proc_Layout *").
 :- 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_layout,       "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").
 
@@ -292,7 +292,7 @@
 %---------------------------------------------------------------------------%
 
 :- pragma foreign_proc("C",
-	prepare_for_normal_call(N::in),
+	prepare_for_normal_call(CSN::in),
 	[thread_safe, will_not_call_mercury],
 "{
 #ifdef MR_DEEP_PROFILING
@@ -301,12 +301,20 @@
 	MR_CallSiteDynamic	*child_csd;
 
 	MR_enter_instrumentation();
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	if (MR_calldebug && MR_lld_print_enabled) {
+		MR_print_deep_prof_vars(stdout, ""prepare_for_normal_call"");
+		printf(""call site number: %d\\n"", CSN);
+	}
+  #endif
+
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
-	child_csd = pd->MR_pd_call_site_ptr_ptrs[N];
+	child_csd = pd->MR_pd_call_site_ptr_ptrs[CSN];
 
   #ifdef MR_DEEP_PROFILING_STATISTICS
 	if (child_csd == NULL) {
@@ -318,7 +326,7 @@
 
 	if (child_csd == NULL) {
 		MR_new_call_site_dynamic(child_csd);
-		pd->MR_pd_call_site_ptr_ptrs[N] = child_csd;
+		pd->MR_pd_call_site_ptr_ptrs[CSN] = child_csd;
 	}
 
 	MR_next_call_site_dynamic = child_csd;
@@ -344,10 +352,24 @@
 	void			*void_key;
 
 	MR_enter_instrumentation();
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	if (MR_calldebug && MR_lld_print_enabled) {
+		MR_print_deep_prof_vars(stdout, ""prepare_for_special_call"");
+		printf(""call site number: %d\\n"", CSN);
+		type_info = (MR_TypeInfo) TypeInfo;
+		type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
+		printf(""type constructor: %s:%s/%d\\n"",
+			type_ctor_info->MR_type_ctor_module_name,
+			type_ctor_info->MR_type_ctor_name,
+			type_ctor_info->MR_type_ctor_arity);
+	}
+  #endif
+
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
 	type_info = (MR_TypeInfo) TypeInfo;
 	type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
@@ -396,11 +418,23 @@
   #endif
 
 	MR_enter_instrumentation();
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	if (MR_calldebug && MR_lld_print_enabled) {
+		MR_print_deep_prof_vars(stdout, ""prepare_for_ho_call"");
+		printf(""call site number: %d\\n"", CSN);
+		closure = (MR_Closure *) Closure;
+		printf(""closure: layout %p, code %p\\n"",
+			(void *) closure->MR_closure_layout,
+			(void *) closure->MR_closure_code);
+	}
+  #endif
+
 	closure = (MR_Closure *) Closure;
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
   #ifdef MR_DEEP_PROFILING_KEY_USES_ID
 	void_key = (void *) (closure->MR_closure_layout);
@@ -449,10 +483,18 @@
   #endif
 
 	MR_enter_instrumentation();
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	if (MR_calldebug && MR_lld_print_enabled) {
+		MR_print_deep_prof_vars(stdout, ""prepare_for_method_call"");
+		printf(""call site number: %d\\n"", CSN);
+	}
+  #endif
+
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
 	void_key = (void *)
 		MR_typeclass_info_class_method(TypeClassInfo, MethodNum);
@@ -492,10 +534,18 @@
 	MR_ProcDynamic		*pd;
 
 	MR_enter_instrumentation();
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	if (MR_calldebug && MR_lld_print_enabled) {
+		MR_print_deep_prof_vars(stdout, ""prepare_for_callback"");
+		printf(""call site number: %d\\n"", CSN);
+	}
+  #endif
+
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
 	MR_current_callback_site = (MR_CallSiteDynList **)
 		&(pd->MR_pd_call_site_ptr_ptrs[CSN]);
@@ -521,15 +571,16 @@
 	MR_enter_instrumentation();
 
   #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
-	if (MR_calldebug) {
+	if (MR_calldebug && MR_lld_print_enabled) {
 		MR_print_deep_prof_vars(stdout, ""prepare_for_tail_call"");
+		printf(""call site number: %d\\n"", CSN);
 	}
   #endif
 
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
 
 	child_csd = pd->MR_pd_call_site_ptr_ptrs[CSN];
 
@@ -563,14 +614,18 @@
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	Count = ps->MR_ps_activation_count;
 	ps->MR_ps_activation_count = 0;
@@ -593,14 +648,18 @@
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	Ptr = ps->MR_ps_outermost_activation_ptr;
 	ps->MR_ps_outermost_activation_ptr = NULL;
@@ -621,14 +680,18 @@
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	ps->MR_ps_activation_count = 0;
 	ps->MR_ps_outermost_activation_ptr = NULL;
@@ -649,14 +712,18 @@
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	ps->MR_ps_outermost_activation_ptr = NULL;
 	MR_leave_instrumentation();
@@ -676,14 +743,18 @@
   #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	ps->MR_ps_activation_count = Count;
 	ps->MR_ps_outermost_activation_ptr = Ptr;
@@ -704,14 +775,18 @@
   #ifndef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	MR_deep_assert(csd, NULL, csd != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	ps->MR_ps_outermost_activation_ptr = Ptr;
 	MR_leave_instrumentation();
cvs server: Diffing profiler
cvs server: Diffing robdd
cvs server: Diffing runtime
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.109
diff -u -b -r1.109 Mmakefile
--- runtime/Mmakefile	19 Feb 2004 23:09:34 -0000	1.109
+++ runtime/Mmakefile	19 May 2004 03:54:29 -0000
@@ -27,6 +27,7 @@
 			mercury_array_macros.h	\
 			mercury_bootstrap.h	\
 			mercury_builtin_types.h	\
+			mercury_builtin_types_proc_layouts.h	\
 			mercury_calls.h		\
 			mercury_conf.h		\
 			mercury_conf_bootstrap.h \
Index: runtime/mercury_builtin_types.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_builtin_types.c,v
retrieving revision 1.10
diff -u -b -r1.10 mercury_builtin_types.c
--- runtime/mercury_builtin_types.c	5 Jan 2004 09:04:33 -0000	1.10
+++ runtime/mercury_builtin_types.c	19 May 2004 03:54:29 -0000
@@ -35,39 +35,10 @@
 #include "mercury_deep_profiling_hand.h"
 #include "mercury_profiling_builtin.h"
 #include "mercury_builtin_types.h"
+#include "mercury_builtin_types_proc_layouts.h"
 
 /*---------------------------------------------------------------------------*/
 
-#ifdef	MR_DEEP_PROFILING
-
-MR_DEFINE_PROC_STATICS(builtin, int, 0);
-MR_DEFINE_PROC_STATICS(builtin, string, 0);
-MR_DEFINE_PROC_STATICS(builtin, float, 0);
-MR_DEFINE_PROC_STATICS(builtin, character, 0);
-MR_DEFINE_PROC_STATICS(builtin, void, 0);
-MR_DEFINE_PROC_STATICS(builtin, c_pointer, 0);
-MR_DEFINE_PROC_STATICS(builtin, pred, 0);
-MR_DEFINE_PROC_STATICS(builtin, func, 0);
-MR_DEFINE_PROC_STATICS(builtin, tuple, 0);
-MR_DEFINE_PROC_STATICS(builtin, succip, 0);
-MR_DEFINE_PROC_STATICS(builtin, hp, 0);
-MR_DEFINE_PROC_STATICS(builtin, curfr, 0);
-MR_DEFINE_PROC_STATICS(builtin, maxfr, 0);
-MR_DEFINE_PROC_STATICS(builtin, redofr, 0);
-MR_DEFINE_PROC_STATICS(builtin, redoip, 0);
-MR_DEFINE_PROC_STATICS(builtin, trailptr, 0);
-MR_DEFINE_PROC_STATICS(builtin, ticket, 0);
-MR_DEFINE_PROC_STATICS(private_builtin, heap_pointer, 0);
-MR_DEFINE_PROC_STATICS(private_builtin, ref, 1);
-MR_DEFINE_PROC_STATICS(private_builtin, type_ctor_info, 1);
-MR_DEFINE_PROC_STATICS(private_builtin, type_info, 1);
-MR_DEFINE_PROC_STATICS(private_builtin, base_typeclass_info, 1);
-MR_DEFINE_PROC_STATICS(private_builtin, typeclass_info, 1);
-MR_DEFINE_PROC_STATICS(type_desc, type_ctor_desc, 0);
-MR_DEFINE_PROC_STATICS(type_desc, type_desc, 0);
-
-#endif
-
 /*
 ** Define MR_TypeCtorInfos for the builtin types
 */
@@ -704,55 +675,202 @@
 
 MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc mercury_builtin_types;
 
-MR_UNIFY_COMPARE_DEFNS(builtin, int, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, string, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, float, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, character, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, void, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, c_pointer, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, pred, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, func, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, tuple, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, succip, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, hp, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, curfr, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, maxfr, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, redofr, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, redoip, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, trailptr, 0)
-MR_UNIFY_COMPARE_DEFNS(builtin, ticket, 0)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, heap_pointer, 0)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, ref, 1)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, type_ctor_info, 1)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, type_info, 1)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, base_typeclass_info, 1)
-MR_UNIFY_COMPARE_DEFNS(private_builtin, typeclass_info, 1)
-MR_UNIFY_COMPARE_DEFNS(type_desc, type_ctor_desc, 0)
-MR_UNIFY_COMPARE_DEFNS(type_desc, type_desc, 0)
+  #define MR_UNIFY_COMPARE_REP_DEFNS(m, n, a)				\
+    MR_define_extern_entry(MR_proc_entry_uci_name(m, __Unify__, n, a, 0)); \
+    MR_define_extern_entry(MR_proc_entry_uci_name(m, __Compare__, n, a, 0)); \
+    MR_define_extern_entry(MR_proc_entry_uci_name(m, __CompareRep__, n, a, 0));
+
+  #ifdef MR_DEEP_PROFILING
+
+    #define MR_UNIFY_COMPARE_REP_DECLS(m, n, a)				\
+      MR_declare_entry(MR_proc_entry_uci_name(m, __Unify__, n, a, 0));	\
+      MR_declare_entry(MR_proc_entry_uci_name(m, __Compare__, n, a, 0)); \
+      MR_declare_entry(MR_proc_entry_uci_name(m, __CompareRep__, n, a, 0)); \
+      MR_declare_label(MR_label_uci_name(m, __Unify__, n, a, 0, 1));	\
+      MR_declare_label(MR_label_uci_name(m, __Unify__, n, a, 0, 2));	\
+      MR_declare_label(MR_label_uci_name(m, __Unify__, n, a, 0, 3));	\
+      MR_declare_label(MR_label_uci_name(m, __Unify__, n, a, 0, 4));	\
+      MR_declare_label(MR_label_uci_name(m, __Compare__, n, a, 0, 1));	\
+      MR_declare_label(MR_label_uci_name(m, __Compare__, n, a, 0, 2));	\
+      MR_declare_label(MR_label_uci_name(m, __CompareRep__, n, a, 0, 1)); \
+      MR_declare_label(MR_label_uci_name(m, __CompareRep__, n, a, 0, 2));
+
+    #define MR_UNIFY_COMPARE_REP_LABELS(m, n, a)			\
+      MR_init_entry(MR_proc_entry_uci_name(m, __Unify__, n, a, 0));	\
+      MR_init_entry(MR_proc_entry_uci_name(m, __Compare__, n, a, 0));	\
+      MR_init_entry(MR_proc_entry_uci_name(m, __CompareRep__, n, a, 0));\
+      MR_init_label(MR_label_uci_name(m, __Unify__, n, a, 0, 1));	\
+      MR_init_label(MR_label_uci_name(m, __Unify__, n, a, 0, 2));	\
+      MR_init_label(MR_label_uci_name(m, __Unify__, n, a, 0, 3));	\
+      MR_init_label(MR_label_uci_name(m, __Unify__, n, a, 0, 4));	\
+      MR_init_label(MR_label_uci_name(m, __Compare__, n, a, 0, 1));	\
+      MR_init_label(MR_label_uci_name(m, __Compare__, n, a, 0, 2));	\
+      MR_init_label(MR_label_uci_name(m, __CompareRep__, n, a, 0, 1));	\
+      MR_init_label(MR_label_uci_name(m, __CompareRep__, n, a, 0, 2));
+
+  #else  /* ! MR_DEEP_PROFILING */
+
+    #define MR_UNIFY_COMPARE_REP_DECLS(m, n, a)				\
+      MR_declare_entry(MR_proc_entry_uci_name(m, __Unify__, n, a, 0));	\
+      MR_declare_entry(MR_proc_entry_uci_name(m, __Compare__, n, a, 0)); \
+      MR_declare_entry(MR_proc_entry_uci_name(m, __CompareRep__, n, a, 0));
+
+    #define MR_UNIFY_COMPARE_REP_LABELS(m, n, a)			\
+      MR_init_entry(MR_proc_entry_uci_name(m, __Unify__, n, a, 0));	\
+      MR_init_entry(MR_proc_entry_uci_name(m, __Compare__, n, a, 0));	\
+      MR_init_entry(MR_proc_entry_uci_name(m, __CompareRep__, n, a, 0));
+
+  #endif /* MR_DEEP_PROFILING */
+
+MR_UNIFY_COMPARE_REP_DECLS(builtin, int, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, string, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, float, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, character, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, void, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, c_pointer, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, pred, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, func, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, tuple, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, succip, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, hp, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, curfr, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, maxfr, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, redofr, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, redoip, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, trailptr, 0)
+MR_UNIFY_COMPARE_REP_DECLS(builtin, ticket, 0)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, heap_pointer, 0)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, ref, 1)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, type_ctor_info, 1)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, type_info, 1)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, base_typeclass_info, 1)
+MR_UNIFY_COMPARE_REP_DECLS(private_builtin, typeclass_info, 1)
+MR_UNIFY_COMPARE_REP_DECLS(type_desc, type_ctor_desc, 0);
+MR_UNIFY_COMPARE_REP_DECLS(type_desc, type_desc, 0);
+MR_UNIFY_COMPARE_REP_DECLS(builtin, user_by_rtti, 0);
+
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, int, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, string, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, float, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, character, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, void, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, c_pointer, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, pred, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, func, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, tuple, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, succip, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, hp, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, curfr, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, maxfr, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, redofr, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, redoip, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, trailptr, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, ticket, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, heap_pointer, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, ref, 1)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, type_ctor_info, 1)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, type_info, 1)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, base_typeclass_info, 1)
+MR_UNIFY_COMPARE_REP_DEFNS(private_builtin, typeclass_info, 1)
+MR_UNIFY_COMPARE_REP_DEFNS(type_desc, type_ctor_desc, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(type_desc, type_desc, 0)
+MR_UNIFY_COMPARE_REP_DEFNS(builtin, user_by_rtti, 0)
+
+  #ifdef MR_DEEP_PROFILING
+
+/*
+** The generic unify, compare and compare_rep predicates do different things
+** for different kinds of type constructors, but these things all fall into
+** one of two categories: either the implementation is entirely in C code,
+** or the implementation is a tailcall to a Mercury predicate. In neither
+** case do the generic predicates allocate a stack frame, which is why
+** the stack traversal component of the procedure layouts won't ever be
+** referenced.
+*/
+
+    #define MR_DEFINE_PROC_STATIC_LAYOUTS(mod, tname, tarity)		\
+      MR_proc_static_uci_no_site(mod, __Unify__, tname, tarity, 0,	\
+	  MR_STRINGIFY(mod) ".m", 0, MR_TRUE);				\
+      MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(				\
+	  MR_DETISM_SEMI, 0, MR_LONG_LVAL_TYPE_UNKNOWN,			\
+	  mod, __Unify__, tname, tarity, 0);				\
+      MR_proc_static_uci_no_site(mod, __Compare__, tname, tarity, 0,	\
+	  MR_STRINGIFY(mod) ".m", 0, MR_TRUE);				\
+      MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(				\
+	  MR_DETISM_DET, 0, MR_LONG_LVAL_TYPE_UNKNOWN,			\
+	  mod, __Compare__, tname, tarity, 0);				\
+      MR_proc_static_uci_no_site(mod, __CompareRep__, tname, tarity, 0,	\
+	  MR_STRINGIFY(mod) ".m", 0, MR_TRUE);				\
+      MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(				\
+	  MR_DETISM_DET, 0, MR_LONG_LVAL_TYPE_UNKNOWN,			\
+	  mod, __CompareRep__, tname, tarity, 0);
+
+    #define MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, m, n, a)		\
+      do {								\
+	  MR_write_out_uci_proc_static(fp,				\
+	    &MR_proc_layout_uci_name(m, __Unify__, n, a, 0));		\
+	  MR_write_out_uci_proc_static(fp,				\
+	    &MR_proc_layout_uci_name(m, __Compare__, n, a, 0));		\
+	  MR_write_out_uci_proc_static(fp,				\
+	    &MR_proc_layout_uci_name(m, __CompareRep__, n, a, 0));	\
+      } while (0)
+
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, int, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, string, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, float, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, character, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, void, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, c_pointer, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, pred, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, func, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, tuple, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, succip, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, hp, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, curfr, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, maxfr, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, redofr, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, redoip, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, trailptr, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, ticket, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, heap_pointer, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, ref, 1);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, type_ctor_info, 1);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, type_info, 1);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, base_typeclass_info, 1);
+MR_DEFINE_PROC_STATIC_LAYOUTS(private_builtin, typeclass_info, 1);
+MR_DEFINE_PROC_STATIC_LAYOUTS(type_desc, type_ctor_desc, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(type_desc, type_desc, 0);
+MR_DEFINE_PROC_STATIC_LAYOUTS(builtin, user_by_rtti, 0);
+
+#endif
 
 MR_BEGIN_MODULE(mercury_builtin_types)
-	MR_UNIFY_COMPARE_LABELS(builtin, int, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, string, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, float, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, character, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, void, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, c_pointer, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, pred, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, func, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, tuple, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, succip, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, hp, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, curfr, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, maxfr, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, redofr, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, trailptr, 0)
-	MR_UNIFY_COMPARE_LABELS(builtin, ticket, 0)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, heap_pointer, 0)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, ref, 1)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, type_ctor_info, 1)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, type_info, 1)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, base_typeclass_info, 1)
-	MR_UNIFY_COMPARE_LABELS(private_builtin, typeclass_info, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, int, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, string, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, float, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, character, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, void, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, c_pointer, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, pred, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, func, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, tuple, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, succip, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, hp, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, curfr, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, maxfr, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, redofr, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, redoip, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, trailptr, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, ticket, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, heap_pointer, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, ref, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, type_ctor_info, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, type_info, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, base_typeclass_info, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(private_builtin, typeclass_info, 1)
+	MR_UNIFY_COMPARE_REP_LABELS(type_desc, type_ctor_desc, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(type_desc, type_desc, 0)
+	MR_UNIFY_COMPARE_REP_LABELS(builtin, user_by_rtti, 0)
 MR_BEGIN_CODE
 
 /*****************************************************************************/
@@ -1333,6 +1451,33 @@
 
 /*****************************************************************************/
 
+/*
+** We need a proc_static structure with which to record profiling information
+** about compare_representation when it compares the representations of
+** user-defined types. The proc_layout structure which contains the proc_static
+** structure also needs a procedure label. The simplest way to provide one
+** is to define unify, compare and compare_rep procedures, all of which are
+** designed to be unused (if they *are* called, they will abort).
+*/
+
+#define	module		builtin
+#define	type		user_by_rtti
+#define	arity		0
+#define	unify_code	MR_fatal_error(					\
+				"called unify/2 for `user_by_rtti' type");
+#define	compare_code	MR_fatal_error(					\
+				"called compare/3 for `user_by_rtti' type");
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef	module
+#undef	type
+#undef	arity
+#undef	unify_code
+#undef	compare_code
+
+/*****************************************************************************/
+
 MR_END_MODULE
 
 #endif /* ! MR_HIGHLEVEL_CODE */
@@ -1453,31 +1598,31 @@
 void
 mercury_sys_init_mercury_builtin_types_write_out_proc_statics(FILE *fp)
 {
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, int, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, string, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, float, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, character, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, void, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, c_pointer, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, pred, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, func, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, tuple, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, succip, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, hp, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, curfr, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, maxfr, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, redofr, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, redoip, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, trailptr, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, builtin, ticket, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, heap_pointer, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, ref, 1);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, type_ctor_info, 1);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, type_info, 1);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, base_typeclass_info, 1);
-	MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, typeclass_info, 1);
-	MR_WRITE_OUT_PROC_STATICS(fp, type_desc, type_ctor_desc, 0);
-	MR_WRITE_OUT_PROC_STATICS(fp, type_desc, type_desc, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, int, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, string, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, float, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, character, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, void, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, c_pointer, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, pred, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, func, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, tuple, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, succip, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, hp, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, curfr, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, maxfr, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, redofr, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, redoip, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, trailptr, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, builtin, ticket, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, heap_pointer, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, ref, 1);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, type_ctor_info, 1);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, type_info, 1);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, base_typeclass_info, 1);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, private_builtin, typeclass_info, 1);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, type_desc, type_ctor_desc, 0);
+	MR_WRITE_OUT_PROC_STATIC_LAYOUTS(fp, type_desc, type_desc, 0);
 }
 #endif
 
Index: runtime/mercury_builtin_types_proc_layouts.h
===================================================================
RCS file: runtime/mercury_builtin_types_proc_layouts.h
diff -N runtime/mercury_builtin_types_proc_layouts.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ runtime/mercury_builtin_types_proc_layouts.h	19 May 2004 03:54:29 -0000
@@ -0,0 +1,70 @@
+/*
+** Copyright (C) 2004 The University of Melbourne.
+** This file may only be copied under the terms of the GNU Library General
+** Public License - see the file COPYING.LIB in the Mercury distribution.
+*/
+
+/*
+** mercury_builtin_types_proc_layouts.h
+**
+** Declares the proc layout structures of the unify, compare and
+** compare_representation procedures of the builtin types.
+**
+** You should not include this header file in any source file in the trace 
+** or browser directories, or in any file includes from there. The reason
+** is that this file contains extern declarations for the global variables
+** holding the procedure layout structure of the unify, compare and
+** compare_representation procedures of the builtin types, and the C compiler
+** handles such declarations as Fortran style "common blocks", which it can
+** use as *definitions* of the symbols rather than simply their uses if
+** the program contains no unequivocal definitions of those symbols at all.
+** If one of these symbols is undefined when the linker considers whether the
+** trace or browser library should be linked in, and those libraries contain
+** a common block reference to these symbols, the linker will pull in those
+** libraries, even though the actual definition of those symbols is in the
+** runtime library (in mercury_builtin_types.o) which comes later on the link
+** command line. Pulling in the trace and/or browser libraries will then
+** cause a link failure, due to the absence from the link command line of
+** system libraries required by the debugger, such as the dynamic link
+** library -ldl. We could in theory fix the link error by *always* linking
+** in all the libraries required by the debugger, but that would cause
+** significant unnecessary bloat in executable sizes.
+*/
+
+#ifndef MERCURY_BUILTIN_TYPES_PROC_LAYOUTS_H
+#define MERCURY_BUILTIN_TYPES_PROC_LAYOUTS_H
+
+#include "mercury_stack_layout.h"
+
+#ifdef	MR_DEEP_PROFILING
+
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, int, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, string, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, float, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, character, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, void, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, c_pointer, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, pred, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, func, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, tuple, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, succip, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, hp, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, curfr, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, maxfr, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, redofr, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, redoip, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, trailptr, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, ticket, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, heap_pointer, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, ref, 1);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, type_ctor_info, 1);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, type_info, 1);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, base_typeclass_info, 1);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(private_builtin, typeclass_info, 1);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(type_desc, type_ctor_desc, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(type_desc, type_desc, 0);
+MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(builtin, user_by_rtti, 0);
+
+#endif
+
+#endif	/* MERCURY_BUILTIN_TYPES_PROC_LAYOUTS_H */
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.76
diff -u -b -r1.76 mercury_conf_param.h
--- runtime/mercury_conf_param.h	9 Mar 2004 03:47:55 -0000	1.76
+++ runtime/mercury_conf_param.h	19 May 2004 03:54:29 -0000
@@ -141,16 +141,14 @@
 **
 ** MR_STACK_TRACE
 **	Require the inclusion of the layout information needed by error/1
-**	and the debugger to print stack traces. This effect is achieved by
-**	including MR_STACK_TRACE in the mangled grade (see mercury_grade.h).
+**	and the debugger to print stack traces. Set from the values of
+**	MR_EXEC_TRACE and MR_DEEP_PROFILING.
 **
-** MR_REQUIRE_TRACING
+** MR_EXEC_TRACE
 **	Require that all Mercury procedures linked in should be compiled
 **	with at least interface tracing.  This effect is achieved
-**	by including MR_REQUIRE_TRACING in the mangled grade
+**	by including MR_EXEC_TRACE in the mangled grade
 **	(see mercury_grade.h).
-**	Note that MR_REQUIRE_TRACING is talking about execution tracing,
-**	not stack tracing; these are two independently configurable features.
 **
 ** MR_DECL_DEBUG
 **	Require that all Mercury procedures linked in should be compiled
@@ -158,8 +156,7 @@
 **	is achieved by including MR_DECL_DEBUG in the mangled grade
 **	(see mercury_grade.h).
 **
-**	Setting MR_DECL_DEBUG requires MR_REQUIRE_TRACING and MR_STACK_TRACE
-**	to be set also.
+**	Setting MR_DECL_DEBUG requires MR_EXEC_TRACE to be set also.
 **
 ** MR_LOWLEVEL_DEBUG
 **	Enables various low-level debugging stuff,
@@ -168,6 +165,19 @@
 **	Causes the generated code to become VERY big and VERY inefficient.
 **	Slows down compilation a LOT.
 **
+** MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+**	Enables the debugging of the code that builds the deep profiling graph.
+**
+** MR_DEEP_PROFILING_DEBUG
+**	Enables the debugging of the code that writes out deep profiling data
+**	files by also printing out the same information in a human readable
+**	form.
+**
+** MR_DEEP_PROFILING_DETAIL_DEBUG
+**	Enables the debugging of the code that writes out the atomic components
+**	(integers, strings, pointers, etc) of the deep profiling data
+**	structures.
+**
 ** MR_DEBUG_DD_BACK_END
 **	Enables low-level debugging messages on the operation of the
 **	declarative debugging back end.
@@ -222,7 +232,8 @@
 ** MR_DEBUG_LABEL_NAMES
 ** 	Registers labels and their names, enabling label addresses to be
 ** 	converted back to a form in which they are usable by a developer.
-** 	Implied by MR_TABLE_DEBUG and MR_DEBUG_RETRY.
+** 	Implied by MR_DEEP_PROFILING_LOWLEVEL_DEBUG, MR_TABLE_DEBUG, and
+** 	MR_DEBUG_RETRY.
 **
 ** MR_DEBUG_LABEL_GOAL_PATHS
 ** 	When printing label names, print the goal path of the label as well,
@@ -252,6 +263,29 @@
 **	representations of all the terms reachable from the stack.
 */
 
+/*
+** Execution tracing and deep profiling both need stack traces, e.g.
+** simulate exits from calls between an exception being thrown and being
+** caught. Stack tracing is therefore automatically enabled in debugging and
+** deep profiling grades.
+**
+** In theory, we could allow stack traces to be enabled even in non-debug,
+** non-deep-profiling grades. However, if you try to do a stack trace, you
+** would find it doesn't work very well unless all modules are compiled
+** with stack tracing. We could define a grade for situations in which
+** MR_STACK_TRACE is defined but MR_EXEC_TRACE and MR_DEEP_PROFILING aren't,
+** but such a grade wouldn't be very useful. We therefore ensure that
+** MR_STACK_TRACE is set iff at least one of MR_EXEC_TRACE and
+** MR_DEEP_PROFILING is set.
+*/
+
+#ifdef MR_STACK_TRACE
+  #error "MR_STACK_TRACE set independently"
+#endif
+#if defined(MR_EXEC_TRACE) || defined(MR_DEEP_PROFILING)
+  #define MR_STACK_TRACE
+#endif
+
 #ifdef	MR_HIGHLEVEL_CODE
   #ifdef MR_LOWLEVEL_DEBUG
     #error "MR_HIGHLEVEL_CODE and MR_LOWLEVEL_DEBUG are not supported together"
@@ -318,6 +352,14 @@
 ** to record term sizes as the number of heap words. Meaningful only if
 ** MR_RECORD_TERM_SIZES is defined. For implementors only.
 **
+** MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS
+** If defined, we explicitly record the number of calls in each
+** call_site_dynamic, instead of computing it from the other port counts.
+** Useful only for measuring the overhead of the recording. Defining this macro
+** makes the generated Deep.data files incompatible with the assumptions
+** of read_profile.m and measurements.m in the deep_profiler directory.
+** For implementors only.
+**
 ** MR_DEEP_PROFILING_PERF_TEST
 ** Allows the selective performance testing of various aspects of deep
 ** profiling. For implementors only.
@@ -564,7 +606,8 @@
 */
 
 /* MR_TABLE_DEBUG and MR_DEBUG_RETRY imply MR_DEBUG_LABEL_NAMES */
-#if defined(MR_TABLE_DEBUG) || defined(MR_DEBUG_RETRY)
+#if defined(MR_DEEP_PROFILING_LOWLEVEL_DEBUG) || defined(MR_TABLE_DEBUG) \
+	|| defined(MR_DEBUG_RETRY)
   #define MR_DEBUG_LABEL_NAMES
 #endif
 
Index: runtime/mercury_debug.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.c,v
retrieving revision 1.20
diff -u -b -r1.20 mercury_debug.c
--- runtime/mercury_debug.c	9 Mar 2004 03:47:55 -0000	1.20
+++ runtime/mercury_debug.c	19 May 2004 03:54:29 -0000
@@ -930,6 +930,11 @@
 	if (csd == NULL) {
 		fprintf(fp, "\n");
 	} else {
+		const MR_ProcDynamic	*pd;
+		const MR_Proc_Layout	*pl;
+		const MR_ProcStatic	*ps;
+		const MR_Proc_Id	*proc_id;
+
 		fprintf(fp, ", depth %d,",
 			csd->MR_csd_depth_count);
 
@@ -942,29 +947,28 @@
 			csd->MR_csd_own.MR_own_fails,
 			csd->MR_csd_own.MR_own_redos);
 
-		fprintf(fp, "  pd: %p", csd->MR_csd_callee_ptr);
-		if (csd->MR_csd_callee_ptr == NULL) {
+		pd = csd->MR_csd_callee_ptr;
+		fprintf(fp, "  pd: %p", pd);
+		if (pd == NULL) {
 			fprintf(fp, "\n");
-		} else if (csd->MR_csd_callee_ptr->MR_pd_proc_static == NULL) {
-			fprintf(fp, ", ps is NULL\n");
+		} else if (pd->MR_pd_proc_layout == NULL) {
+			fprintf(fp, ", pl is NULL\n");
 		} else {
-			MR_ProcStatic	*ps;
-			MR_Proc_Id	*proc_id;
-
-			ps = csd->MR_csd_callee_ptr->MR_pd_proc_static;
-			fprintf(fp, ", ps: %p\n", ps);
-			proc_id = &ps->MR_ps_proc_id;
+			pl = pd->MR_pd_proc_layout;
+			ps = pl->MR_sle_proc_static;
+			fprintf(fp, ", pl: %p, ps: %p\n", pl, ps);
+			proc_id = &pl->MR_sle_proc_id;
 			if (MR_PROC_ID_COMPILER_GENERATED(*proc_id)) {
 				fprintf(fp, "  %s:%s %s/%d-%d\n  ",
-					proc_id->MR_proc_comp.
-						MR_comp_type_module,
-					proc_id->MR_proc_comp.
-						MR_comp_type_name,
-					proc_id->MR_proc_comp.
-						MR_comp_pred_name,
-					proc_id->MR_proc_comp.
-						MR_comp_type_arity,
-					proc_id->MR_proc_comp.MR_comp_mode);
+					proc_id->MR_proc_uci.
+						MR_uci_type_module,
+					proc_id->MR_proc_uci.
+						MR_uci_type_name,
+					proc_id->MR_proc_uci.
+						MR_uci_pred_name,
+					proc_id->MR_proc_uci.
+						MR_uci_type_arity,
+					proc_id->MR_proc_uci.MR_uci_mode);
 			} else {
 				fprintf(fp, "  %s.%s/%d-%d\n  ",
 					proc_id->MR_proc_user.
Index: runtime/mercury_deep_call_port_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_call_port_body.h,v
retrieving revision 1.4
diff -u -b -r1.4 mercury_deep_call_port_body.h
--- runtime/mercury_deep_call_port_body.h	14 Aug 2002 06:41:33 -0000	1.4
+++ runtime/mercury_deep_call_port_body.h	19 May 2004 03:54:29 -0000
@@ -20,7 +20,7 @@
 **
 ** The code including this file should have the following variables in scope:
 **
-** ProcStatic:			The proc_static of the procedure whose call
+** ProcLayout:			The proc_layout of the procedure whose call
 **				port we are at.
 ** MiddleCSD:			The id of the current csd.
 ** TopCSD:			The id of the parent's csd.
@@ -35,8 +35,14 @@
 #ifdef MR_DEEP_PROFILING
 {
 	MR_CallSiteDynamic	*csd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
+  #ifdef MR_EXEC_TRACE
+  	if (! MR_disable_deep_profiling_in_debugger) {
+	/* The matching parenthesis is at the end of the file */
+  #endif
+
 	MR_enter_instrumentation();
 
   #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
@@ -47,6 +53,10 @@
 
 	TopCSD = (MR_Word) MR_current_call_site_dynamic;
 	MiddleCSD = (MR_Word) MR_next_call_site_dynamic;
+
+	MR_deep_assert(NULL, NULL, NULL, MR_current_call_site_dynamic != NULL);
+	MR_deep_assert(NULL, NULL, NULL, MR_next_call_site_dynamic != NULL);
+
 	csd = MR_next_call_site_dynamic;
 	MR_current_call_site_dynamic = csd;
   #ifdef MR_DEEP_PROFILING_PORT_COUNTS
@@ -63,7 +73,10 @@
 	MR_next_call_site_dynamic = NULL;
   #endif
 
-	ps = (MR_ProcStatic *) ProcStatic;
+	pl = (const MR_Proc_Layout *) ProcLayout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
   #ifdef MR_VERSION_SR
 	OldOutermostActivationPtr =
 		(MR_Word) ps->MR_ps_outermost_activation_ptr;
@@ -71,7 +84,7 @@
 
   #if defined(MR_VERSION_AC)
     #ifdef MR_USE_ACTIVATION_COUNTS
-	MR_deep_assert(csd, ps, ps->MR_ps_activation_count == 0
+	MR_deep_assert(csd, pl, ps, ps->MR_ps_activation_count == 0
 		|| ps->MR_ps_outermost_activation_ptr != NULL);
 
       #ifdef MR_DEEP_PROFILING_STATISTICS
@@ -94,7 +107,7 @@
 	} else {
 		MR_ProcDynamic	*pd;
 
-		MR_new_proc_dynamic(pd, ps);
+		MR_new_proc_dynamic(pd, pl);
 		csd->MR_csd_callee_ptr = pd;
 		ps->MR_ps_outermost_activation_ptr = pd;
 	}
@@ -122,7 +135,7 @@
 	} else {
 		MR_ProcDynamic	*pd;
 
-		MR_new_proc_dynamic(pd, ps);
+		MR_new_proc_dynamic(pd, pl);
 		csd->MR_csd_callee_ptr = pd;
 		ps->MR_ps_outermost_activation_ptr = csd->MR_csd_callee_ptr;
 	}
@@ -139,6 +152,11 @@
   #endif
 
 	MR_leave_instrumentation();
+
+  #ifdef MR_EXEC_TRACE
+	/* The matching parenthesis is at the start of the file */
+	}
+  #endif
 }
 #else
 	MR_fatal_error(MR_PROCNAME ": deep profiling not enabled");
Index: runtime/mercury_deep_leave_port_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_leave_port_body.h,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_deep_leave_port_body.h
--- runtime/mercury_deep_leave_port_body.h	14 Aug 2002 06:41:33 -0000	1.3
+++ runtime/mercury_deep_leave_port_body.h	19 May 2004 03:54:29 -0000
@@ -25,17 +25,27 @@
 ** OldOutermostActivationPtr:	The id of the outermost activation of the
 **				current user procedure before the current call
 **				to it. Needed only with MR_VERSION_SR.
+**
+** Note that the code in ML_trace_throw() in library/exception.m is based
+** on the logic of this file, so if you make any changes here, you should
+** consider similar changes there.
 */
 
 #ifdef MR_DEEP_PROFILING
 {
 	MR_CallSiteDynamic	*csd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
+  #ifdef MR_EXEC_TRACE
+  	if (! MR_disable_deep_profiling_in_debugger) {
+	/* The matching parenthesis is at the end of the file */
+  #endif
+
 	MR_enter_instrumentation();
 
 	csd = (MR_CallSiteDynamic *) MiddleCSD;
-	MR_deep_assert(csd, NULL, csd == MR_current_call_site_dynamic);
+	MR_deep_assert(csd, NULL, NULL, csd == MR_current_call_site_dynamic);
 
   #ifdef MR_DEEP_PROFILING_PORT_COUNTS
 	/* increment exit/fail count */
@@ -48,15 +58,17 @@
     #endif
   #endif
 
-	MR_deep_assert(csd, NULL, csd->MR_csd_callee_ptr != NULL);
-	ps = csd->MR_csd_callee_ptr->MR_pd_proc_static;
-	MR_deep_assert(csd, ps, ps != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd->MR_csd_callee_ptr != NULL);
+	pl = csd->MR_csd_callee_ptr->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
   #if defined(MR_VERSION_AC)
     #ifdef MR_USE_ACTIVATION_COUNTS
 	/* decrement activation count */
 	ps->MR_ps_activation_count--;
-	MR_deep_assert(csd, ps, ps->MR_ps_activation_count >= 0);
+	MR_deep_assert(csd, pl, ps, ps->MR_ps_activation_count >= 0);
     #else
 	MR_fatal_error(MR_PROCNAME ": MR_USE_ACTIVATION_COUNTS not enabled");
     #endif
@@ -81,6 +93,11 @@
 	** For MR_FAIL_PORT code, the failure we should execute here
 	** is handled by code inserted by the compiler.
 	*/
+
+  #ifdef MR_EXEC_TRACE
+	/* The matching parenthesis is at the start of the file */
+	}
+  #endif
 }
 #else
 	MR_fatal_error(MR_PROCNAME ": deep profiling not enabled");
Index: runtime/mercury_deep_profiling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.c,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_deep_profiling.c
--- runtime/mercury_deep_profiling.c	1 Mar 2004 05:06:03 -0000	1.12
+++ runtime/mercury_deep_profiling.c	19 May 2004 03:54:29 -0000
@@ -23,21 +23,24 @@
 #include "mercury_prof_time.h"
 #include "mercury_runtime_util.h"	/* for strerror() on some systems */
 #include "mercury_deep_profiling.h"
+#include "mercury_deep_profiling_hand.h"
 
 #ifdef MR_DEEP_PROFILING
 
 #include <stdio.h>
 #include <errno.h>
 
+#ifdef	MR_EXEC_TRACE
+MR_bool	MR_disable_deep_profiling_in_debugger = MR_FALSE;
+#endif
+
 MR_CallSiteStatic	MR_main_parent_call_site_statics[1] =
 {
 	{ MR_callback, NULL, NULL, "Mercury runtime", 0, "" }
 };
 
-MR_User_ProcStatic	MR_main_parent_proc_static =
+MR_ProcStatic	MR_main_parent_proc_static =
 {
-	{ MR_PREDICATE, "Mercury runtime", "Mercury runtime",
-	  "Mercury runtime", 0, 0 },
 	"Mercury runtime",
 	0,
 	MR_TRUE,
@@ -46,7 +49,19 @@
 #ifdef	MR_USE_ACTIVATION_COUNTS
 	0,
 #endif
-	NULL
+	NULL,
+	-1,
+	-1,
+	-1
+};
+
+MR_Proc_Layout_User	MR_main_parent_proc_layout =
+{
+	{ MR_do_not_reached, MR_DETISM_DET, -1, MR_LONG_LVAL_TYPE_UNKNOWN },
+	{ MR_PREDICATE, "Mercury runtime", "Mercury runtime",
+	  "Mercury runtime", 0, 0 },
+	NULL,
+	&MR_main_parent_proc_static
 };
 
 MR_CallSiteDynamic	*MR_main_parent_call_site_dynamics[1] =
@@ -56,7 +71,7 @@
 
 MR_ProcDynamic		MR_main_parent_proc_dynamic =
 {
-	(MR_ProcStatic *) &MR_main_parent_proc_static,
+	(MR_Proc_Layout *) &MR_main_parent_proc_layout,
 	&MR_main_parent_call_site_dynamics[0]
 };
 
@@ -66,11 +81,11 @@
 	{
 #ifdef MR_DEEP_PROFILING_PORT_COUNTS
   #ifdef MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS
-	0,
+	1,
   #else
 	/* the call count is computed from the other counts */
   #endif
-	1, 0, 0,
+	1, 0, 0, 0,
 #endif
 #ifdef MR_DEEP_PROFILING_TIMING
 	0,
@@ -125,8 +140,9 @@
 #endif	/* MR_DEEP_PROFILING_STATISTICS */
 
 void
-MR_deep_assert_failed(const MR_CallSiteDynamic *csd, const MR_ProcStatic *ps,
-	const char *cond, const char *filename, int linenumber)
+MR_deep_assert_failed(const MR_CallSiteDynamic *csd, const MR_Proc_Layout *pl,
+	const MR_ProcStatic *ps, const char *cond,
+	const char *filename, int linenumber)
 {
 	char	buf[1024];
 	char	bufcsd[1024];
@@ -138,6 +154,12 @@
 		strcpy(bufcsd, "");
 	}
 
+	if (pl != NULL) {
+		sprintf(bufps, ", pl %p\n", pl);
+	} else {
+		strcpy(bufps, "");
+	}
+
 	if (ps != NULL) {
 		sprintf(bufps, ", ps %p\n", ps);
 	} else {
@@ -328,10 +350,12 @@
 	}
 
 #ifdef	MR_DEEP_PROFILING_DEBUG
+	if (MR_deep_prof_debug_file_flag) {
 	debug_fp = fopen("Deep.debug", "w");
 	if (debug_fp == NULL) {
 		debug_fp = stderr;
 	}
+	}
 #endif
 
 	MR_write_out_id_string(fp);
@@ -365,17 +389,18 @@
 	}
 
 #ifdef MR_DEEP_PROFILING_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "root = %p, %d\n",
 		&MR_main_parent_proc_dynamic, root_pd_id);
+	}
 #endif
 
 	MR_write_ptr(fp, kind_pd, root_pd_id);
 
 	MR_write_out_proc_dynamic(fp, &MR_main_parent_proc_dynamic);
 
-	MR_write_out_proc_static(fp,
-		(MR_ProcStatic *) &MR_main_parent_proc_static);
-	MR_deep_assert(NULL, NULL,
+	MR_write_out_user_proc_static(fp, &MR_main_parent_proc_layout);
+	MR_deep_assert(NULL, NULL, NULL,
 		MR_address_of_write_out_proc_statics != NULL);
 	(*MR_address_of_write_out_proc_statics)(fp);
 
@@ -579,97 +604,112 @@
 static void
 MR_write_out_id_string(FILE *fp)
 {
-	/* This string must match id_string deep_profiler/read_profile.m */
-	const char	*id_string = "Mercury deep profiler data";
+	/* Must be the same as id_string in deep_profiler/read_profile.m */
+	const char	*id_string = "Mercury deep profiler data version 1\n";
 
 	fputs(id_string, fp);
 }
 
 void
-MR_write_out_proc_static(FILE *fp, const MR_ProcStatic *ps)
+MR_write_out_user_proc_static(FILE *fp, const MR_Proc_Layout_User *proc_layout)
 {
+	MR_write_out_proc_static(fp, (const MR_Proc_Layout *) proc_layout);
+}
+
+void
+MR_write_out_uci_proc_static(FILE *fp, const MR_Proc_Layout_UCI *proc_layout)
+{
+	MR_write_out_proc_static(fp, (const MR_Proc_Layout *) proc_layout);
+}
+
+void
+MR_write_out_proc_static(FILE *fp, const MR_Proc_Layout *proc_layout)
+{
+	const MR_ProcStatic	*ps;
+	const MR_Proc_Id	*procid;
 	int	ps_id;
 	int	css_id;
 	MR_bool	already_written;
 	int	i;
 
+	if (proc_layout == NULL) {
+		MR_fatal_error("MR_write_out_proc_static: null proc_layout");
+	}
+
+	ps = proc_layout->MR_sle_proc_static;
 	if (ps == NULL) {
 		MR_fatal_error("MR_write_out_proc_static: null ps");
 	}
 
-	(void) MR_hash_table_insert(MR_proc_static_table, ps,
+	(void) MR_hash_table_insert(MR_proc_static_table, proc_layout,
 		&ps_id, &already_written, MR_TRUE);
 
 #ifdef MR_DEEP_PROFILING_DEBUG
-	fprintf(debug_fp, "proc_static %p/%d\n", ps, ps_id);
+	if (debug_fp != NULL) {
+		fprintf(debug_fp, "proc_static %p/%p/%d\n",
+			proc_layout, ps, ps_id);
 	fprintf(debug_fp, "  filename \"%s\", linenumber %d, "
 			"interface %d, %d call sites\n",
 		ps->MR_ps_file_name, ps->MR_ps_line_number,
 		ps->MR_ps_is_in_interface, ps->MR_ps_num_call_sites);
+	}
 #endif
 
 	if (already_written) {
 		MR_fatal_error("MR_write_out_proc_static: seen ps");
 	}
 
-	MR_hash_table_flag_written(MR_proc_static_table, ps);
+	MR_hash_table_flag_written(MR_proc_static_table, proc_layout);
 
 	MR_write_byte(fp, MR_deep_token_proc_static);
 	MR_write_ptr(fp, kind_ps, ps_id);
 
-	if (MR_PROC_ID_COMPILER_GENERATED(ps->MR_ps_proc_id)) {
+	procid = &proc_layout->MR_sle_proc_id;
+	if (MR_PROC_ID_COMPILER_GENERATED(*procid)) {
 #ifdef MR_DEEP_PROFILING_DEBUG
+		if (debug_fp != NULL) {
 		fprintf(debug_fp, "  compiler %s/%s/%s/%s/%d/%d\n",
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_name,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_module,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_def_module,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_pred_name,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_arity,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_mode);
+				procid->MR_proc_uci.MR_uci_type_name,
+				procid->MR_proc_uci.MR_uci_type_module,
+				procid->MR_proc_uci.MR_uci_def_module,
+				procid->MR_proc_uci.MR_uci_pred_name,
+				procid->MR_proc_uci.MR_uci_type_arity,
+				procid->MR_proc_uci.MR_uci_mode);
+		}
 #endif
 
-		MR_write_byte(fp, MR_deep_token_isa_compiler_generated);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_name);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_module);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_def_module);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_pred_name);
-		MR_write_num(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_arity);
-		MR_write_num(fp,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_mode);
+		MR_write_byte(fp, MR_deep_token_isa_uci_pred);
+		MR_write_string(fp, procid->MR_proc_uci.MR_uci_type_name);
+		MR_write_string(fp, procid->MR_proc_uci.MR_uci_type_module);
+		MR_write_string(fp, procid->MR_proc_uci.MR_uci_def_module);
+		MR_write_string(fp, procid->MR_proc_uci.MR_uci_pred_name);
+		MR_write_num(fp, procid->MR_proc_uci.MR_uci_type_arity);
+		MR_write_num(fp, procid->MR_proc_uci.MR_uci_mode);
 	} else {
 #ifdef MR_DEEP_PROFILING_DEBUG
+		if (debug_fp != NULL) {
 		fprintf(debug_fp, "  user %d/%s/%s/%s/%d/%d\n",
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_pred_or_func,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_decl_module,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_def_module,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_name,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_type_arity,
-			ps->MR_ps_proc_id.MR_proc_comp.MR_comp_mode);
+				procid->MR_proc_user.MR_user_pred_or_func,
+				procid->MR_proc_user.MR_user_decl_module,
+				procid->MR_proc_user.MR_user_def_module,
+				procid->MR_proc_user.MR_user_name,
+				procid->MR_proc_user.MR_user_arity,
+				procid->MR_proc_user.MR_user_mode);
+		}
 #endif
 
-		if (ps->MR_ps_proc_id.MR_proc_user.MR_user_pred_or_func
-			== MR_PREDICATE)
+		if (procid->MR_proc_user.MR_user_pred_or_func == MR_PREDICATE)
 		{
 			MR_write_byte(fp, MR_deep_token_isa_predicate);
 		} else {
 			MR_write_byte(fp, MR_deep_token_isa_function);
 		}
 
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_decl_module);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_def_module);
-		MR_write_string(fp,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_name);
-		MR_write_num(fp,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_arity);
-		MR_write_num(fp,
-			ps->MR_ps_proc_id.MR_proc_user.MR_user_mode);
+		MR_write_string(fp, procid->MR_proc_user.MR_user_decl_module);
+		MR_write_string(fp, procid->MR_proc_user.MR_user_def_module);
+		MR_write_string(fp, procid->MR_proc_user.MR_user_name);
+		MR_write_num(fp, procid->MR_proc_user.MR_user_arity);
+		MR_write_num(fp, procid->MR_proc_user.MR_user_mode);
 	}
 
 	MR_write_string(fp, ps->MR_ps_file_name);
@@ -682,9 +722,12 @@
 			&ps->MR_ps_call_sites[i], &css_id, NULL, MR_FALSE);
 
 #ifdef MR_DEEP_PROFILING_DEBUG
+		if (debug_fp != NULL) {
 		fprintf(debug_fp,
-			"call site id %d in proc_static %p/%d -> %d\n",
-			i, ps, ps_id, css_id);
+				"call site id %d in "
+				"proc_static %p/%p/%d -> %d\n",
+				i, proc_layout, ps, ps_id, css_id);
+		}
 #endif
 
 		MR_write_ptr(fp, kind_css, css_id);
@@ -692,8 +735,11 @@
 
 	for (i = 0; i < ps->MR_ps_num_call_sites; i++) {
 #ifdef MR_DEEP_PROFILING_DEBUG
-		fprintf(debug_fp, "in proc_static %p/%d, call site %d\n",
-			ps, ps_id, i);
+		if (debug_fp != NULL) {
+			fprintf(debug_fp,
+				"in proc_static %p/%p/%d, call site %d\n",
+				proc_layout, ps, ps_id, i);
+		}
 #endif
 
 		MR_write_out_call_site_static(fp, &ps->MR_ps_call_sites[i]);
@@ -721,11 +767,14 @@
 	MR_hash_table_flag_written(MR_call_site_static_table, css);
 
 #ifdef MR_DEEP_PROFILING_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "call_site_static %p/%d\n", css, css_id);
 	fprintf(debug_fp,
-		"  filename \"%s\", linenum %d, goal path %s, kind %d\n",
+			"  filename \"%s\", linenum %d, "
+			"goal path %s, kind %d\n",
 		css->MR_css_file_name, css->MR_css_line_number,
 		css->MR_css_goal_path, css->MR_css_kind);
+	}
 #endif
 
 	MR_write_byte(fp, MR_deep_token_call_site_static);
@@ -736,8 +785,10 @@
 			css->MR_css_callee_ptr_if_known,
 			&ps_id, NULL, MR_FALSE);
 #ifdef MR_DEEP_PROFILING_DEBUG
+		if (debug_fp != NULL) {
 		fprintf(debug_fp, "  callee %p/%d\n",
 			css->MR_css_callee_ptr_if_known, ps_id);
+		}
 #endif
 		MR_write_num(fp, ps_id);
 		if (css->MR_css_type_subst_if_known != NULL) {
@@ -767,11 +818,14 @@
 	MR_deep_num_csd_nodes++;
 #endif
 
-	MR_deep_assert(csd, NULL, csd->MR_csd_callee_ptr != NULL);
+	MR_deep_assert(csd, NULL, NULL, csd->MR_csd_callee_ptr != NULL);
 
 #ifdef MR_DEEP_PROFILING_DEBUG
-	fprintf(debug_fp, "call_site_dynamic %p: callee proc_dynamic %p\n",
+	if (debug_fp != NULL) {
+		fprintf(debug_fp,
+			"call_site_dynamic %p: callee proc_dynamic %p\n",
 		csd, csd->MR_csd_callee_ptr);
+	}
 #endif
 
 	MR_write_byte(fp, MR_deep_token_call_site_dynamic);
@@ -792,6 +846,11 @@
 
 	MR_write_ptr(fp, kind_pd, pd_id);
 
+	/*
+	** The masks here must exactly correspond with the masks in
+	** predicate read_profile in deep_profiler/read_profile.m.
+	*/
+
 #ifdef MR_DEEP_PROFILING_PORT_COUNTS
   #ifdef MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS
 	if (csd->MR_csd_own.MR_own_calls != 0)
@@ -803,16 +862,18 @@
 		bitmask |= 0x0004;
 	if (csd->MR_csd_own.MR_own_redos != 0)
 		bitmask |= 0x0008;
+	if (csd->MR_csd_own.MR_own_excps != 0)
+		bitmask |= 0x0010;
 #endif
 #ifdef MR_DEEP_PROFILING_TIMING
 	if (csd->MR_csd_own.MR_own_quanta != 0)
-		bitmask |= 0x0010;
+		bitmask |= 0x0020;
 #endif
 #ifdef MR_DEEP_PROFILING_MEMORY
 	if (csd->MR_csd_own.MR_own_allocs != 0)
-		bitmask |= 0x0020;
-	if (csd->MR_csd_own.MR_own_words != 0)
 		bitmask |= 0x0040;
+	if (csd->MR_csd_own.MR_own_words != 0)
+		bitmask |= 0x0080;
 #endif
 
 	MR_write_num(fp, bitmask);
@@ -828,6 +889,8 @@
 		MR_write_num(fp, csd->MR_csd_own.MR_own_fails);
 	if (csd->MR_csd_own.MR_own_redos != 0)
 		MR_write_num(fp, csd->MR_csd_own.MR_own_redos);
+	if (csd->MR_csd_own.MR_own_excps != 0)
+		MR_write_num(fp, csd->MR_csd_own.MR_own_excps);
 #endif
 
 #ifdef MR_DEEP_PROFILING_TIMING
@@ -848,10 +911,11 @@
 static void
 MR_write_out_proc_dynamic(FILE *fp, const MR_ProcDynamic *pd)
 {
-	int	i;
+	const MR_ProcStatic	*ps;
 	int	pd_id;
 	int	ps_id;
 	MR_bool	already_written;
+	int			i;
 
 	if (pd == NULL) {
 		/*
@@ -872,36 +936,42 @@
 		return;
 	}
 
+	ps = pd->MR_pd_proc_layout->MR_sle_proc_static;
+
 	MR_hash_table_flag_written(MR_proc_dynamic_table, pd);
-	(void) MR_hash_table_insert(MR_proc_static_table,
-		pd->MR_pd_proc_static, &ps_id, NULL, MR_FALSE);
+	(void) MR_hash_table_insert(MR_proc_static_table, ps, &ps_id,
+		NULL, MR_FALSE);
 
 #ifdef MR_DEEP_PROFILING_STATISTICS
 	MR_deep_num_pd_nodes++;
-	MR_deep_num_pd_array_slots +=
-		pd->MR_pd_proc_static->MR_ps_num_call_sites;
+	MR_deep_num_pd_array_slots += ps->MR_ps_num_call_sites;
 #endif
 
 	MR_write_byte(fp, MR_deep_token_proc_dynamic);
 	MR_write_ptr(fp, kind_pd, pd_id);
 	MR_write_ptr(fp, kind_ps, ps_id);
-	MR_write_num(fp, pd->MR_pd_proc_static->MR_ps_num_call_sites);
+	MR_write_num(fp, ps->MR_ps_num_call_sites);
 
 #ifdef MR_DEEP_PROFILING_DEBUG
-	fprintf(debug_fp, "proc_dynamic %p/%d, proc_static %p/%d\n",
-		pd, pd_id, pd->MR_pd_proc_static, ps_id);
+	if (debug_fp != NULL) {
+		fprintf(debug_fp, "proc_dynamic %p/%d, proc_static %p/%p/%d\n",
+			pd, pd_id, pd->MR_pd_proc_layout, ps, ps_id);
+	}
 #endif
 
-	for (i = 0; i < pd->MR_pd_proc_static->MR_ps_num_call_sites; i++) {
-		MR_write_kind(fp, pd->MR_pd_proc_static->
-			MR_ps_call_sites[i].MR_css_kind);
-		switch (pd->MR_pd_proc_static->MR_ps_call_sites[i].MR_css_kind)
+	for (i = 0; i < ps->MR_ps_num_call_sites; i++) {
+		MR_write_kind(fp, ps->MR_ps_call_sites[i].MR_css_kind);
+		switch (ps->MR_ps_call_sites[i].MR_css_kind)
 		{
 			case MR_normal_call:
 #ifdef MR_DEEP_PROFILING_DEBUG
+				if (debug_fp != NULL) {
 				fprintf(debug_fp,
-					"  normal call from pd %p to pd %p\n",
-					pd, pd->MR_pd_call_site_ptr_ptrs[i]);
+						"  normal call from pd %p "
+						"to pd %p\n",
+						pd, pd->
+						MR_pd_call_site_ptr_ptrs[i]);
+				}
 #endif
 				MR_write_csd_ptr(fp,
 					pd->MR_pd_call_site_ptr_ptrs[i]);
@@ -918,8 +988,8 @@
 		}
 	}
 
-	for (i = 0; i < pd->MR_pd_proc_static->MR_ps_num_call_sites; i++) {
-		switch (pd->MR_pd_proc_static->MR_ps_call_sites[i].MR_css_kind)
+	for (i = 0; i < ps->MR_ps_num_call_sites; i++) {
+		switch (ps->MR_ps_call_sites[i].MR_css_kind)
 		{
 			case MR_normal_call:
 				MR_write_out_call_site_dynamic(fp,
@@ -947,8 +1017,10 @@
 		MR_deep_num_dynlist_nodes++;
 #endif
 #ifdef MR_DEEP_PROFILING_DEBUG
+		if (debug_fp != NULL) {
 		fprintf(debug_fp, "  multi call from pd %p to pd %p\n",
 			pd, dynlist->MR_csdlist_call_site);
+		}
 #endif
 		MR_write_csd_ptr(fp, dynlist->MR_csdlist_call_site);
 		dynlist = dynlist->MR_csdlist_next;
@@ -985,7 +1057,9 @@
 MR_write_ptr(FILE *fp, MR_NodeKind kind, int node_id)
 {
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "ptr: %d\n", node_id);
+	}
 #endif
 
 	/* MR_write_byte(fp, (int) kind); */
@@ -998,7 +1072,9 @@
 	int	byte;
 
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "call_site_kind: %d\n", (int) kind);
+	}
 #endif
 
 	/* convert from a MR_CallSite_Kind to an MR_Profiling_Encoding_Token */
@@ -1017,7 +1093,9 @@
 MR_write_byte(FILE *fp, const char byte)
 {
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "byte: %d\n", (int) byte);
+	}
 #endif
 	putc(byte, fp);
 }
@@ -1036,10 +1114,12 @@
 	int		i;
 
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "num: %ld\n", num);
+	}
 #endif
 
-	MR_deep_assert(NULL, NULL, (int) num >= 0);
+	MR_deep_assert(NULL, NULL, NULL, (int) num >= 0);
 
 	i = 0;
 	do {
@@ -1062,10 +1142,12 @@
 	int	i;
 
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "fixed_size_int: %ld\n", num);
+	}
 #endif
 
-	MR_deep_assert(NULL, NULL, (int) num >= 0);
+	MR_deep_assert(NULL, NULL, NULL, (int) num >= 0);
 
 	for (i = 0; i < MR_FIXED_SIZE_INT_BYTES; i++) {
 		putc(num & ((1 << 8) - 1), fp);
@@ -1079,7 +1161,9 @@
 	int	i, len;
 
 #ifdef	MR_DEEP_PROFILING_DETAIL_DEBUG
+	if (debug_fp != NULL) {
 	fprintf(debug_fp, "string: <%s>\n", ptr);
+	}
 #endif
 
 	len = strlen(ptr);
Index: runtime/mercury_deep_profiling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.h,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_deep_profiling.h
--- runtime/mercury_deep_profiling.h	1 Mar 2004 05:06:03 -0000	1.12
+++ runtime/mercury_deep_profiling.h	19 May 2004 03:54:29 -0000
@@ -15,7 +15,6 @@
 #define MERCURY_DEEP_PROFILING_H
 
 #include "mercury_types.h"		/* for MR_ConstString etc */
-#include "mercury_proc_id.h"		/* for MR_Proc_Id */
 #include "mercury_ho_call.h"
 #include <stdio.h>
 
@@ -37,6 +36,7 @@
 	unsigned				MR_own_exits;
 	unsigned				MR_own_fails;
 	unsigned				MR_own_redos;
+	unsigned				MR_own_excps;
 #endif
 #ifdef MR_DEEP_PROFILING_TIMING
 	volatile unsigned			MR_own_quanta;
@@ -54,7 +54,7 @@
 
 struct MR_CallSiteStatic_Struct {
     	MR_CallSite_Kind			MR_css_kind;
-	MR_ProcStatic				*MR_css_callee_ptr_if_known;
+	MR_Proc_Layout				*MR_css_callee_ptr_if_known;
 	MR_ConstString				MR_css_type_subst_if_known;
 	MR_ConstString				MR_css_file_name;
 	int					MR_css_line_number;
@@ -62,33 +62,6 @@
 };
 
 struct MR_ProcStatic_Struct {
-	MR_Proc_Id				MR_ps_proc_id;
-	MR_ConstString				MR_ps_file_name;
-	int					MR_ps_line_number;
-	int					MR_ps_is_in_interface;
-	int					MR_ps_num_call_sites;
-	const MR_CallSiteStatic			*MR_ps_call_sites;
-#ifdef MR_USE_ACTIVATION_COUNTS
-	int					MR_ps_activation_count;
-#endif
-	MR_ProcDynamic				*MR_ps_outermost_activation_ptr;
-};
-
-struct MR_User_ProcStatic_Struct {
-	MR_User_Proc_Id				MR_ps_proc_id;
-	MR_ConstString				MR_ps_file_name;
-	int					MR_ps_line_number;
-	int					MR_ps_is_in_interface;
-	int					MR_ps_num_call_sites;
-	const MR_CallSiteStatic			*MR_ps_call_sites;
-#ifdef MR_USE_ACTIVATION_COUNTS
-	int					MR_ps_activation_count;
-#endif
-	MR_ProcDynamic				*MR_ps_outermost_activation_ptr;
-};
-
-struct MR_Compiler_ProcStatic_Struct {
-	MR_Compiler_Proc_Id			MR_ps_proc_id;
 	MR_ConstString				MR_ps_file_name;
 	int					MR_ps_line_number;
 	int					MR_ps_is_in_interface;
@@ -98,6 +71,9 @@
 	int					MR_ps_activation_count;
 #endif
 	MR_ProcDynamic				*MR_ps_outermost_activation_ptr;
+	int					MR_ps_cur_csd_stack_slot;
+	int					MR_ps_next_csd_stack_slot;
+	int					MR_ps_old_outermost_stack_slot;
 };
 
 struct MR_CallSiteDynamic_Struct {
@@ -107,7 +83,7 @@
 };
 
 struct MR_ProcDynamic_Struct {
-	MR_ProcStatic				*MR_pd_proc_static;
+	const MR_Proc_Layout			*MR_pd_proc_layout;
 	MR_CallSiteDynamic			**MR_pd_call_site_ptr_ptrs;
 };
 
@@ -130,7 +106,7 @@
 	MR_deep_token_callback,
 	MR_deep_token_isa_predicate,
 	MR_deep_token_isa_function,
-	MR_deep_token_isa_compiler_generated
+	MR_deep_token_isa_uci_pred
 } MR_Profile_Encoding_Token;
 
 #define	MR_enter_instrumentation()					\
@@ -155,6 +131,7 @@
 		(csd)->MR_csd_own.MR_own_exits = 0;			\
 		(csd)->MR_csd_own.MR_own_fails = 0;			\
 		(csd)->MR_csd_own.MR_own_redos = 0;			\
+		(csd)->MR_csd_own.MR_own_excps = 0;			\
 	} while (0)
 #else
   #define MR_init_own_ports(csd)					\
@@ -203,17 +180,19 @@
 		MR_init_depth_count(newcsd);				\
 	} while (0)
 
-#define	MR_new_proc_dynamic(pd, ps)					\
+#define	MR_new_proc_dynamic(pd, pl)					\
 	do {								\
+		MR_ProcStatic	*psl;					\
 		int	npdi;						\
 									\
 		(pd) = MR_PROFILING_MALLOC(MR_ProcDynamic);		\
-		(pd)->MR_pd_proc_static = (ps);				\
+		(pd)->MR_pd_proc_layout = (pl);				\
+		psl = (pl)->MR_sle_proc_static;				\
 		(pd)->MR_pd_call_site_ptr_ptrs =			\
 			MR_PROFILING_MALLOC_ARRAY(MR_CallSiteDynamic *,	\
-				(ps)->MR_ps_num_call_sites);		\
+				psl->MR_ps_num_call_sites);		\
 									\
-		for (npdi = 0; npdi < (ps)->MR_ps_num_call_sites; npdi++) { \
+		for (npdi = 0; npdi < psl->MR_ps_num_call_sites; npdi++) { \
 			(pd)->MR_pd_call_site_ptr_ptrs[npdi] = NULL;	\
 		}							\
 	} while (0)
@@ -305,18 +284,22 @@
 	} while (0)
 
 #ifdef	MR_DEEP_CHECKS
-  #define MR_deep_assert(csd, ps, cond)					\
+  #define MR_deep_assert(csd, pl, ps, cond)				\
  	do {								\
 		if (!(cond)) {						\
-			MR_deep_assert_failed(csd, ps, MR_STRINGIFY(cond),\
-				__FILE__, __LINE__);			\
+			MR_deep_assert_failed(csd, pl, ps,		\
+				MR_STRINGIFY(cond), __FILE__, __LINE__); \
 		}							\
 	} while (0)
 #else
-  #define MR_deep_assert(csd, ps, cond)					\
+  #define MR_deep_assert(csd, pl, ps, cond)				\
   	((void) 0)
 #endif
 
+#if	defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
+extern	MR_bool				MR_disable_deep_profiling_in_debugger;
+#endif
+
 extern	MR_CallSiteDynamic		*MR_current_call_site_dynamic;
 extern	MR_CallSiteDynamic		*MR_next_call_site_dynamic;
 extern	MR_CallSiteDynList		**MR_current_callback_site;
@@ -352,10 +335,15 @@
 #endif	/* MR_DEEP_PROFILING_STATISTICS */
 
 extern	void	MR_deep_assert_failed(const MR_CallSiteDynamic *csd,
-			const MR_ProcStatic *ps, const char *cond,
-			const char *filename, int linenumber);
+			const MR_Proc_Layout *pl, const MR_ProcStatic *ps,
+			const char *cond, const char *filename,
+			int linenumber);
 extern	void	MR_setup_callback(void *entry);
-extern	void	MR_write_out_proc_static(FILE *fp, const MR_ProcStatic *ptr);
+extern	void	MR_write_out_user_proc_static(FILE *fp,
+			const MR_Proc_Layout_User *ptr);
+extern	void	MR_write_out_uci_proc_static(FILE *fp,
+			const MR_Proc_Layout_UCI *ptr);
+extern	void	MR_write_out_proc_static(FILE *fp, const MR_Proc_Layout *ptr);
 extern	void	MR_write_out_profiling_tree(void);
 
 extern	void	MR_deep_prof_init(void);
Index: runtime/mercury_deep_profiling_hand.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling_hand.h,v
retrieving revision 1.5
diff -u -b -r1.5 mercury_deep_profiling_hand.h
--- runtime/mercury_deep_profiling_hand.h	20 Mar 2004 05:44:13 -0000	1.5
+++ runtime/mercury_deep_profiling_hand.h	19 May 2004 03:54:29 -0000
@@ -15,12 +15,7 @@
 #include "mercury_std.h"
 #include "mercury_deep_profiling.h"
 
-#define	MR_proc_static_user_builtin_name(name, arity, mode)		\
-	MR_PASTE6(mercury_data__proc_static__,				\
-		name, _, arity, _, mode)
-#define	MR_call_sites_user_builtin_name(name, arity, mode)		\
-	MR_PASTE6(mercury_data__proc_static_call_sites__mercury__,	\
-		name, _, arity, _, mode)
+/*****************************************************************************/
 
 #define	MR_proc_static_user_name(module, name, arity, mode)		\
 	MR_PASTE8(mercury_data__proc_static__,				\
@@ -29,157 +24,92 @@
 	MR_PASTE8(mercury_data__proc_static_call_sites__mercury__,	\
 		module, __, name, _, arity, _, mode)
 
-#define	MR_proc_static_compiler_name(module, name, type, arity, mode)	\
+#define	MR_proc_static_uci_name(module, name, type, arity, mode)	\
 	MR_PASTE10(mercury_data__proc_static__,				\
 		name, _, module, __, type, _, arity, _, mode)
-#define	MR_call_sites_compiler_name(module, name, type, arity, mode)	\
+#define	MR_call_sites_uci_name(module, name, type, arity, mode)		\
 	MR_PASTE10(mercury_data__proc_static_call_sites__mercury__,	\
 		name, _, module, __, type, _, arity, _, mode)
 
+/*****************************************************************************/
+
 #ifdef MR_USE_ACTIVATION_COUNTS
   #define	MR_maybe_activation_count_field		0,
 #else
   #define	MR_maybe_activation_count_field
 #endif
 
-#define	MR_proc_static_user_builtin_empty(name, arity, mode, file, line, interface)\
-	MR_User_ProcStatic						\
-	MR_proc_static_user_builtin_name(name, arity, mode) = {		\
-		{							\
-			MR_PREDICATE,					\
-			"builtin",					\
-			"builtin",					\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
+#define	MR_proc_static_no_site(global_var_name, file, line, interface)	\
+	MR_ProcStatic global_var_name = {				\
 		file,							\
 		line,							\
 		interface,						\
 		0,							\
 		NULL,							\
 		MR_maybe_activation_count_field				\
-		NULL							\
-	}
-
-#define	MR_proc_static_compiler_empty(module, name, type, arity, mode, file, line, interface) \
-	MR_Compiler_ProcStatic						\
-	MR_proc_static_compiler_name(module, name, type, arity, mode) = { \
-		{							\
-			MR_STRINGIFY(type),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
-		file,							\
-		line,							\
-		interface,						\
-		0,							\
 		NULL,							\
-		MR_maybe_activation_count_field				\
-		NULL							\
+		MR_LONG_LVAL_TYPE_UNKNOWN,				\
+		MR_LONG_LVAL_TYPE_UNKNOWN,				\
+		MR_LONG_LVAL_TYPE_UNKNOWN				\
 	}
 
-#define	MR_proc_static_user_empty(module, name, arity, mode, file, line, interface)\
-	MR_User_ProcStatic						\
-	MR_proc_static_user_name(module, name, arity, mode) = {		\
-		{							\
-			MR_PREDICATE,					\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
+#define	MR_proc_static_one_site(global_var_name, call_sites_var_name,	\
+		file, line, interface)					\
+	MR_ProcStatic global_var_name = {				\
 		file,							\
 		line,							\
 		interface,						\
-		0,							\
-		NULL,							\
+		1,							\
+		call_sites_var_name,					\
 		MR_maybe_activation_count_field				\
-		NULL							\
+		NULL,							\
+		MR_LONG_LVAL_TYPE_UNKNOWN,				\
+		MR_LONG_LVAL_TYPE_UNKNOWN,				\
+		MR_LONG_LVAL_TYPE_UNKNOWN				\
 	}
 
-#define	MR_proc_static_user_plain(module, name, arity, mode, cmodule, cname, carity, cmode, file, line, interface)\
-	static const MR_CallSiteStatic					\
-	MR_call_sites_user_name(module, name, arity, mode)[] = {	\
-		{ MR_normal_call, (MR_ProcStatic *)			\
-		&MR_proc_static_user_name(cmodule, cname, carity, cmode),\
-		NULL, "", line, "" }					\
-	};								\
-									\
-	MR_User_ProcStatic						\
-	MR_proc_static_user_name(module, name, arity, mode) = {		\
-		{							\
-			MR_PREDICATE,					\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
-		file,							\
-		line,							\
-		interface,						\
-		1,							\
+#define	MR_proc_static_user_no_site(module, name, arity, mode,		\
+		file, line, interface) 					\
+	MR_proc_static_no_site(						\
+		MR_proc_static_user_name(module, name, arity, mode),	\
+			file, line, interface)
+
+#define	MR_proc_static_user_one_site(module, name, arity, mode,		\
+		file, line, interface) 					\
+	MR_proc_static_one_site(					\
+		MR_proc_static_user_name(module, name, arity, mode),	\
 		MR_call_sites_user_name(module, name, arity, mode),	\
-		MR_maybe_activation_count_field				\
-		NULL							\
-	}
+			file, line, interface)
+
+#define	MR_proc_static_uci_no_site(module, name, type, arity, mode,	\
+		file, line, interface) 					\
+	MR_proc_static_no_site(						\
+		MR_proc_static_uci_name(module, name, type, arity, mode), \
+			file, line, interface)
+
+#define	MR_proc_static_uci_one_site(module, name, type, arity, mode,	\
+		file, line, interface) 					\
+	MR_proc_static_one_site(					\
+		MR_proc_static_uci_name(module, name, type, arity, mode), \
+		MR_call_sites_uci_name(module, name, type, arity, mode), \
+			file, line, interface)
 
-#define	MR_proc_static_compiler_plain(module, name, type, arity, mode, cmodule, cname, carity, cmode, file, line, interface)\
+/*****************************************************************************/
+
+#define	MR_call_sites_uci_one_normal(module, name, type, arity, mode,	\
+		cmodule, cname, carity, cmode, line)			\
 	static const MR_CallSiteStatic					\
-	MR_call_sites_compiler_name(module, name, type, arity, mode)[] = {\
-		{ MR_normal_call, (MR_ProcStatic *)			\
-		&MR_proc_static_user_name(cmodule, cname, carity, cmode),\
+	MR_call_sites_uci_name(module, name, type, arity, mode)[] = {	\
+		{ MR_normal_call, (MR_Proc_Layout *)			\
+		&MR_proc_layout_user_name(cmodule, cname, carity, cmode),\
 		NULL, "", line, "" }					\
-	};								\
-									\
-	MR_Compiler_ProcStatic						\
-	MR_proc_static_compiler_name(module, name, type, arity, mode) = {\
-		{							\
-			MR_STRINGIFY(type),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
-		file,							\
-		line,							\
-		interface,						\
-		1,							\
-		MR_call_sites_compiler_name(module, name, type, arity, mode),\
-		MR_maybe_activation_count_field				\
-		NULL							\
 	}
 
-#define	MR_proc_static_user_ho(module, name, arity, mode, file, line, interface)	\
+#define	MR_call_sites_user_one_ho(module, name, arity, mode, line)	\
 	static const MR_CallSiteStatic					\
 	MR_call_sites_user_name(module, name, arity, mode)[] = {	\
 		{ MR_higher_order_call, NULL,				\
 		NULL, "", line, "" }					\
-	};								\
-									\
-	MR_User_ProcStatic						\
-	MR_proc_static_user_name(module, name, arity, mode) = {		\
-		{							\
-			MR_PREDICATE,					\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(module),				\
-			MR_STRINGIFY(name),				\
-			arity, 						\
-			mode, 						\
-		},							\
-		file,							\
-		line,							\
-		interface,						\
-		1,							\
-		MR_call_sites_user_name(module, name, arity, mode),	\
-		MR_maybe_activation_count_field				\
-		NULL							\
 	}
 
 /*****************************************************************************/
@@ -345,8 +275,8 @@
 	MR_update_prof_current_proc(MR_LABEL(proclabel));		\
 	MR_framevar(first_slot) = MR_r1;	/* TopCSD */		\
 	MR_framevar(first_slot+1) = MR_r2;	/* MiddleCSD */		\
-	MR_framevar(first_slot+3) = MR_r3;	/* OldActivationPtr */	\
-	MR_framevar(first_slot+4) = MR_r4;	/* NewActivationPtr */	\
+	MR_framevar(first_slot+2) = MR_r3;	/* OldActivationPtr */	\
+	MR_framevar(first_slot+3) = MR_r4;	/* NewActivationPtr */	\
 	(void) 0
 
 #define	MR_deep_non_exit_sr(proclabel, first_slot, label)		\
@@ -381,20 +311,20 @@
 /*****************************************************************************/
 
 #ifdef	MR_USE_ACTIVATION_COUNTS
-  #define	MR_deep_det_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_det_call_ac(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_det_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_det_call_ac(proclabel, proclayout, first_slot, label)
   #define	MR_deep_det_exit(proclabel, first_slot, label)		\
 		MR_deep_det_exit_ac(proclabel, first_slot, label)
 
-  #define	MR_deep_semi_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_semi_call_ac(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_semi_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_semi_call_ac(proclabel, proclayout, first_slot, label)
   #define	MR_deep_semi_exit(proclabel, first_slot, label)		\
 		MR_deep_semi_exit_ac(proclabel, first_slot, label)
   #define	MR_deep_semi_fail(proclabel, first_slot, label)		\
 		MR_deep_semi_fail_ac(proclabel, first_slot, label)
 
-  #define	MR_deep_non_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_non_call_ac(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_non_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_non_call_ac(proclabel, proclayout, first_slot, label)
   #define	MR_deep_non_exit(proclabel, first_slot, label)		\
 		MR_deep_non_exit_ac(proclabel, first_slot, label)
   #define	MR_deep_non_redo(proclabel, first_slot, label)		\
@@ -402,20 +332,20 @@
   #define	MR_deep_non_fail(proclabel, first_slot, label)		\
 		MR_deep_non_fail_ac(proclabel, first_slot, label)
 #else
-  #define	MR_deep_det_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_det_call_sr(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_det_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_det_call_sr(proclabel, proclayout, first_slot, label)
   #define	MR_deep_det_exit(proclabel, first_slot, label)		\
 		MR_deep_det_exit_sr(proclabel, first_slot, label)
 
-  #define	MR_deep_semi_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_semi_call_sr(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_semi_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_semi_call_sr(proclabel, proclayout, first_slot, label)
   #define	MR_deep_semi_exit(proclabel, first_slot, label)		\
 		MR_deep_semi_exit_sr(proclabel, first_slot, label)
   #define	MR_deep_semi_fail(proclabel, first_slot, label)		\
 		MR_deep_semi_fail_sr(proclabel, first_slot, label)
 
-  #define	MR_deep_non_call(proclabel, procstatic, first_slot, label) \
-		MR_deep_non_call_sr(proclabel, procstatic, first_slot, label)
+  #define	MR_deep_non_call(proclabel, proclayout, first_slot, label) \
+		MR_deep_non_call_sr(proclabel, proclayout, first_slot, label)
   #define	MR_deep_non_exit(proclabel, first_slot, label)		\
 		MR_deep_non_exit_sr(proclabel, first_slot, label)
   #define	MR_deep_non_redo(proclabel, first_slot, label)		\
Index: runtime/mercury_deep_rec_depth_actions.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_rec_depth_actions.h,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_deep_rec_depth_actions.h
--- runtime/mercury_deep_rec_depth_actions.h	14 Aug 2002 06:41:33 -0000	1.3
+++ runtime/mercury_deep_rec_depth_actions.h	19 May 2004 03:54:29 -0000
@@ -15,15 +15,16 @@
 ** These macros assume that the environments of their invocation define
 ** the following variables:
 ** 
-** pd:	should point to the ProcDynamic structure of the caller.
-** ps: 	should point to the ProcStatic structure of the caller.
+** pd:	should point to the MR_ProcDynamic structure of the caller.
+** pl: 	should point to the MR_Proc_Layout structure of the caller.
+** ps: 	should point to the MR_ProcStatic structure of the caller.
 */
 
 #define	MR_SAVE_DEPTH_ACTION(outer_count, csn)				\
 	do {								\
 		MR_CallSiteDynamic	*inner_csd;			\
 									\
-		MR_deep_assert(NULL, ps, csn <= ps->MR_ps_num_call_sites);\
+		MR_deep_assert(NULL, pl, ps, csn <= ps->MR_ps_num_call_sites);\
 		inner_csd = pd->MR_pd_call_site_ptr_ptrs[csn];		\
 									\
 		if (inner_csd != NULL) {				\
@@ -37,7 +38,7 @@
 	do {								\
 		MR_CallSiteDynamic	*inner_csd;			\
 									\
-		MR_deep_assert(NULL, ps, csn <= ps->MR_ps_num_call_sites);\
+		MR_deep_assert(NULL, pl, ps, csn <= ps->MR_ps_num_call_sites);\
 		inner_csd = pd->MR_pd_call_site_ptr_ptrs[csn];		\
 									\
 		if (inner_csd != NULL) {				\
@@ -48,7 +49,7 @@
 			inner_csd->MR_csd_own.inc_field += inner_count;	\
 			inner_csd->MR_csd_depth_count = outer_count;	\
 		} else {						\
-			MR_deep_assert(inner_csd, ps, outer_count == 0);\
+			MR_deep_assert(inner_csd, pl, ps, outer_count == 0);\
 		}							\
 	} 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.4
diff -u -b -r1.4 mercury_deep_rec_depth_body.h
--- runtime/mercury_deep_rec_depth_body.h	8 Nov 2002 00:45:41 -0000	1.4
+++ runtime/mercury_deep_rec_depth_body.h	19 May 2004 03:54:29 -0000
@@ -29,15 +29,18 @@
   #ifdef MR_DEEP_PROFILING_TAIL_RECURSION
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
 	csd = CSD;
-	MR_deep_assert(csd, NULL, csd == MR_current_call_site_dynamic);
+	MR_deep_assert(csd, NULL, NULL, csd == MR_current_call_site_dynamic);
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
-	MR_deep_assert(csd, ps, ps != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
 	MR_REC_DEPTH_BODY
 
Index: runtime/mercury_deep_redo_port_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_redo_port_body.h,v
retrieving revision 1.3
diff -u -b -r1.3 mercury_deep_redo_port_body.h
--- runtime/mercury_deep_redo_port_body.h	14 Aug 2002 06:41:34 -0000	1.3
+++ runtime/mercury_deep_redo_port_body.h	19 May 2004 03:54:29 -0000
@@ -26,9 +26,15 @@
 #ifdef MR_DEEP_PROFILING
 {
 	MR_CallSiteDynamic	*csd;
-	MR_ProcDynamic		*pd;
+	const MR_ProcDynamic	*pd;
+	const MR_Proc_Layout	*pl;
 	MR_ProcStatic		*ps;
 
+  #ifdef MR_EXEC_TRACE
+  	if (! MR_disable_deep_profiling_in_debugger) {
+	/* The matching parenthesis is at the end of the file */
+  #endif
+
 	MR_enter_instrumentation();
 	csd = (MR_CallSiteDynamic *) MiddleCSD;
 	MR_current_call_site_dynamic = csd;
@@ -38,9 +44,11 @@
   #endif
 
 	pd = csd->MR_csd_callee_ptr;
-	MR_deep_assert(csd, NULL, pd != NULL);
-	ps = pd->MR_pd_proc_static;
-	MR_deep_assert(csd, ps, ps != NULL);
+	MR_deep_assert(csd, NULL, NULL, pd != NULL);
+	pl = pd->MR_pd_proc_layout;
+	MR_deep_assert(csd, pl, NULL, pl != NULL);
+	ps = pl->MR_sle_proc_static;
+	MR_deep_assert(csd, pl, ps, ps != NULL);
 
   #if defined(MR_VERSION_AC)
     #ifdef MR_USE_ACTIVATION_COUNTS
@@ -61,6 +69,11 @@
     #endif
   #else
     #error "mercury_deep_redo_port_body.h: neither MR_VERSION_AC nor MR_VERSION_SR"
+  #endif
+
+  #ifdef MR_EXEC_TRACE
+	/* The matching parenthesis is at the start of the file */
+	}
   #endif
 
 	MR_leave_instrumentation();
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.46
diff -u -b -r1.46 mercury_engine.c
--- runtime/mercury_engine.c	12 Mar 2004 06:02:06 -0000	1.46
+++ runtime/mercury_engine.c	19 May 2004 03:54:29 -0000
@@ -63,6 +63,7 @@
 	{ "enabled",	MR_LLD_DEBUG_ENABLED_FLAG },
 	{ "notnearest",	MR_NOT_NEAREST_FLAG },
 	{ "debugslots",	MR_DEBUG_SLOTS_FLAG },
+	{ "deepdebugfile",	MR_DEEP_PROF_DEBUG_FILE_FLAG },
 	{ "detail",	MR_DETAILFLAG }
 };
 
Index: runtime/mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.33
diff -u -b -r1.33 mercury_engine.h
--- runtime/mercury_engine.h	12 Mar 2004 06:02:06 -0000	1.33
+++ runtime/mercury_engine.h	19 May 2004 03:54:29 -0000
@@ -64,8 +64,9 @@
 #define	MR_LLD_DEBUG_ENABLED_FLAG 	18
 #define	MR_NOT_NEAREST_FLAG 		19
 #define	MR_DEBUG_SLOTS_FLAG		20
-#define	MR_DETAILFLAG			21
-#define	MR_MAXFLAG			22
+#define	MR_DEEP_PROF_DEBUG_FILE_FLAG 	21
+#define	MR_DETAILFLAG			22
+#define	MR_MAXFLAG			23
 /* MR_DETAILFLAG should be the last real flag */
 
 /*
@@ -130,6 +131,10 @@
 ** MR_debug_slots_flag controls whether dumps of nondet stack frames will
 ** print the values of the fixed stack slots used by the debugger, in the
 ** stack frames of procedures compiled with debugging.
+**
+** MR_deep_prof_debug_file_flag, if set, causes the runtime, whenever it is
+** generating a Deep.data file, to also generate a human-readable Deep.debug
+** file.
 */
 
 #define	MR_progdebug		MR_debugflag[MR_PROGFLAG]
@@ -153,6 +158,8 @@
 #define	MR_lld_debug_enabled	MR_debugflag[MR_LLD_DEBUG_ENABLED_FLAG]
 #define	MR_not_nearest_flag	MR_debugflag[MR_NOT_NEAREST_FLAG]
 #define	MR_debug_slots_flag	MR_debugflag[MR_DEBUG_SLOTS_FLAG]
+#define	MR_deep_prof_debug_file_flag	MR_debugflag[\
+						MR_DEEP_PROF_DEBUG_FILE_FLAG]
 #define	MR_detaildebug		MR_debugflag[MR_DETAILFLAG]
 
 typedef struct {
Index: runtime/mercury_exception_catch_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_exception_catch_body.h,v
retrieving revision 1.4
diff -u -b -r1.4 mercury_exception_catch_body.h
--- runtime/mercury_exception_catch_body.h	19 Jan 2004 01:02:54 -0000	1.4
+++ runtime/mercury_exception_catch_body.h	19 May 2004 03:54:29 -0000
@@ -11,7 +11,7 @@
 ** the following macros:
 ** 
 ** proc_label
-** proc_static
+** proc_layout
 ** model
 ** excp_handler
 ** handle_ticket_on_exit
@@ -23,26 +23,18 @@
 */
 
 /*
-** Framevar(1) and possibly framevar(2) are used to save the inputs and/or
-** outputs of the closure. The first framevar available for saving deep
-** profiling information is framevar(3).
-*/
-
-#define	FIRST_DEEP_SLOT			3
-
-/*
 ** Each procedure defines several local labels. The local label numbers are
 ** allocated as follows. Note that not all procedures use all of these labels.
 */
 
-#define	CALL_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 1)
-#define	CLOSURE_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 2)
-#define	EXIT_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 3)
-#define	REDO_REDOIP_LABEL(pl)		MR_PASTE3(pl, _i, 4)
-#define	REDO_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 5)
-#define	FAIL_REDOIP_LABEL(pl)		MR_PASTE3(pl, _i, 6)
-#define	FAIL_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 7)
-#define	PREPARE_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 8)
+#define	CALL_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 1)
+#define	CLOSURE_RETURN_LABEL(pl)	MR_label_name(pl, 2)
+#define	EXIT_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 3)
+#define	REDO_REDOIP_LABEL(pl)		MR_label_name(pl, 4)
+#define	REDO_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 5)
+#define	FAIL_REDOIP_LABEL(pl)		MR_label_name(pl, 6)
+#define	FAIL_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 7)
+#define	PREPARE_RETURN_LABEL(pl)	MR_label_name(pl, 8)
 
 #if	defined(version_model_non) && \
 		(defined(MR_USE_TRAIL) || defined(MR_DEEP_PROFILING))
@@ -72,9 +64,10 @@
 
 #ifdef	MR_DEEP_PROFILING
 	MR_framevar(1) = MR_r2;
-	MR_deep_non_call(proc_label, proc_static, FIRST_DEEP_SLOT,
+	MR_deep_non_call(proc_label, proc_layout,
+		MR_EXCEPTION_FIRST_DEEP_SLOT,
 		CALL_PORT_RETURN_LABEL(proc_label));
-	MR_deep_prepare_ho_call(proc_label, FIRST_DEEP_SLOT,
+	MR_deep_prepare_ho_call(proc_label, MR_EXCEPTION_FIRST_DEEP_SLOT,
 		PREPARE_RETURN_LABEL(proc_label), 0, MR_framevar(1));
 	MR_r1 = MR_framevar(1);	/* The Goal to call */
 #else
@@ -93,7 +86,7 @@
 
 #ifdef	MR_DEEP_PROFILING
 	save_results();
-	MR_deep_non_exit(proc_static, FIRST_DEEP_SLOT,
+	MR_deep_non_exit(proc_layout, MR_EXCEPTION_FIRST_DEEP_SLOT,
 		EXIT_PORT_RETURN_LABEL(proc_label));
 	restore_results();
 #endif
@@ -110,7 +103,7 @@
 
 #if	defined(version_model_non) && defined(MR_DEEP_PROFILING)
 MR_define_label(REDO_REDOIP_LABEL(proc_label));
-	MR_deep_non_redo(proc_static, FIRST_DEEP_SLOT,
+	MR_deep_non_redo(proc_layout, MR_EXCEPTION_FIRST_DEEP_SLOT,
 		REDO_PORT_RETURN_LABEL(proc_label));
 	/* non_redo_port_code executes *semidet* failure */
 	MR_fail();
@@ -126,7 +119,7 @@
 #endif
 
 #ifdef	MR_DEEP_PROFILING
-	MR_deep_non_fail(proc_static, FIRST_DEEP_SLOT,
+	MR_deep_non_fail(proc_layout, MR_EXCEPTION_FIRST_DEEP_SLOT,
 		FAIL_PORT_RETURN_LABEL(proc_label));
 	/* non_redo_port_code executes *semidet* failure */
 #endif
@@ -134,8 +127,6 @@
 
 #endif	/* defined(version_model_non) && \
 		(defined(MR_USE_TRAIL) || defined(MR_DEEP_PROFILING)) */
-
-#undef	FIRST_DEEP_SLOT
 
 #undef	CALL_PORT_RETURN_LABEL
 #undef	CLOSURE_RETURN_LABEL
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.50
diff -u -b -r1.50 mercury_grade.h
--- runtime/mercury_grade.h	21 Dec 2003 05:10:48 -0000	1.50
+++ runtime/mercury_grade.h	19 May 2004 03:54:29 -0000
@@ -52,9 +52,15 @@
 ** and remove them when increasing the binary compatibility version number.   
 ** Searching for MR_RTTI_VERSION__ should find all code related to the
 ** RTTI version number.
+**
+** The MR_GRADE_EXEC_TRACE_VERSION_NO and MR_GRADE_DEEP_PROF_VERSION_NO
+** macros should be incremented when a change breaks binary backwards
+** compatibility only in debugging and deep profiling grades respectively.
 */
 
 #define MR_GRADE_PART_0	v12_
+#define MR_GRADE_EXEC_TRACE_VERSION_NO	1
+#define MR_GRADE_DEEP_PROF_VERSION_NO	1
 
 #ifdef MR_HIGHLEVEL_CODE
 
@@ -127,8 +133,8 @@
 #endif
 
 #ifdef MR_DEEP_PROFILING
-  #define MR_GRADE_PART_5	MR_PASTE2(MR_GRADE_PART_4, _profdeep)
-  #define MR_GRADE_OPT_PART_5	MR_GRADE_OPT_PART_4 ".profdeep"
+  #define MR_GRADE_PART_5	MR_PASTE3(MR_GRADE_PART_4, _profdeep, MR_GRADE_DEEP_PROF_VERSION_NO)
+  #define MR_GRADE_OPT_PART_5	MR_GRADE_OPT_PART_4 ".profdeep" MR_STRINGIFY(MR_GRADE_DEEP_PROF_VERSION_NO)
   #if defined(MR_MPROF_PROFILE_TIME) || defined(MR_MPROF_PROFILE_CALLS) \
 	|| defined(MR_MPROF_PROFILE_MEMORY)
     /*
@@ -312,40 +318,20 @@
   #define MR_GRADE_OPT_PART_12	MR_GRADE_OPT_PART_11
 #endif
 
-/*
-** Stack traces aren't strictly binary incompatible - but if you
-** try to do a stack trace you might find it doesn't work very
-** well unless all modules are compiled in with --stack-trace.
-** Hence we consider it effectively binary incompatible.
-** Similar considerations apply to procedure call tracing.
-*/
 #if defined(MR_DECL_DEBUG)
-  #define MR_GRADE_PART_13		MR_PASTE2(MR_GRADE_PART_12, _decldebug)
-  #define MR_GRADE_OPT_PART_13		MR_GRADE_OPT_PART_12 ".decldebug"
-  #if ! defined(MR_STACK_TRACE)
-    #error "declarative debugging require stack traces"
-  #endif
-  #if ! defined(MR_REQUIRE_TRACING)
+  #define MR_GRADE_PART_13		MR_PASTE3(MR_GRADE_PART_12, _decldebug, MR_GRADE_EXEC_TRACE_VERSION_NO)
+  #define MR_GRADE_OPT_PART_13		MR_GRADE_OPT_PART_12 ".decldebug" MR_STRINGIFY(MR_GRADE_EXEC_TRACE_VERSION_NO)
+  #if ! defined(MR_EXEC_TRACE)
     #error "declarative debugging require execution tracing"
   #endif
 #else
-  #if defined(MR_STACK_TRACE)
-    #if defined(MR_REQUIRE_TRACING)
-      #define MR_GRADE_PART_13		MR_PASTE2(MR_GRADE_PART_12, _debug)
-      #define MR_GRADE_OPT_PART_13	MR_GRADE_OPT_PART_12 ".debug"
-    #else
-      #define MR_GRADE_PART_13		MR_PASTE2(MR_GRADE_PART_12, _strce)
-      #define MR_GRADE_OPT_PART_13	MR_GRADE_OPT_PART_12 ".strce"
-    #endif
-  #else
-    #if defined(MR_REQUIRE_TRACING)
-      #define MR_GRADE_PART_13		MR_PASTE2(MR_GRADE_PART_12, _trace)
-      #define MR_GRADE_OPT_PART_13	MR_GRADE_OPT_PART_12 ".trace"
+  #if defined(MR_EXEC_TRACE)
+    #define MR_GRADE_PART_13		MR_PASTE3(MR_GRADE_PART_12, _debug, MR_GRADE_EXEC_TRACE_VERSION_NO)
+    #define MR_GRADE_OPT_PART_13	MR_GRADE_OPT_PART_12 ".debug" MR_STRINGIFY(MR_GRADE_EXEC_TRACE_VERSION_NO)
     #else
       #define MR_GRADE_PART_13		MR_GRADE_PART_12
       #define MR_GRADE_OPT_PART_13	MR_GRADE_OPT_PART_12
     #endif
-  #endif
 #endif
 
 #ifdef MR_RECORD_TERM_SIZES
Index: runtime/mercury_hand_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_hand_compare_body.h,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_hand_compare_body.h
--- runtime/mercury_hand_compare_body.h	31 May 2001 06:00:13 -0000	1.2
+++ runtime/mercury_hand_compare_body.h	19 May 2004 03:54:29 -0000
@@ -11,7 +11,7 @@
 ** the following macros:
 ** 
 ** proc_label
-** proc_static
+** proc_layout
 ** body_code
 */
 
@@ -28,8 +28,8 @@
 ** allocated as follows.
 */
 
-#define	CALL_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 1)
-#define	EXIT_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 2)
+#define	CALL_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 1)
+#define	EXIT_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 2)
 
 /*****************************************************************************/
 
@@ -42,7 +42,7 @@
 	MR_stackvar(1) = MR_r1;
 	MR_stackvar(2) = MR_r2;
 
-	MR_deep_det_call(proc_label, proc_static, FIRST_DEEP_SLOT,
+	MR_deep_det_call(proc_label, proc_layout, FIRST_DEEP_SLOT,
 		CALL_PORT_RETURN_LABEL(proc_label));
 
 	MR_r1 = MR_stackvar(1);
Index: runtime/mercury_hand_unify_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_hand_unify_body.h,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_hand_unify_body.h
--- runtime/mercury_hand_unify_body.h	31 May 2001 06:00:14 -0000	1.2
+++ runtime/mercury_hand_unify_body.h	19 May 2004 03:54:29 -0000
@@ -11,7 +11,7 @@
 ** the following macros:
 ** 
 ** proc_label
-** proc_static
+** proc_layout
 ** body_code
 **
 ** It should also define may_need_fail_action for the model_non versions.
@@ -30,10 +30,10 @@
 ** allocated as follows.
 */
 
-#define	CALL_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 1)
-#define	EXIT_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 2)
-#define	FAIL_LABEL(pl)			MR_PASTE3(pl, _i, 3)
-#define	FAIL_PORT_RETURN_LABEL(pl)	MR_PASTE3(pl, _i, 4)
+#define	CALL_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 1)
+#define	EXIT_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 2)
+#define	FAIL_LABEL(pl)			MR_label_name(pl, 3)
+#define	FAIL_PORT_RETURN_LABEL(pl)	MR_label_name(pl, 4)
 
 /*****************************************************************************/
 
@@ -46,7 +46,7 @@
 	MR_stackvar(1) = MR_r1;
 	MR_stackvar(2) = MR_r2;
 
-	MR_deep_semi_call(proc_label, proc_static, FIRST_DEEP_SLOT,
+	MR_deep_semi_call(proc_label, proc_layout, FIRST_DEEP_SLOT,
 		CALL_PORT_RETURN_LABEL(proc_label));
 
 	MR_r1 = MR_stackvar(1);
Index: runtime/mercury_hand_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_hand_unify_compare_body.h,v
retrieving revision 1.1
diff -u -b -r1.1 mercury_hand_unify_compare_body.h
--- runtime/mercury_hand_unify_compare_body.h	9 Aug 2002 05:51:40 -0000	1.1
+++ runtime/mercury_hand_unify_compare_body.h	19 May 2004 03:54:29 -0000
@@ -16,24 +16,40 @@
 ** compare_code
 */
 
-#define	proc_label	MR_TYPE_UNIFY_FUNC(module, type, arity)
-#define	proc_static	MR_proc_static_compiler_name(module, __Unify__, type, \
-				arity, 0)
+#define	proc_label	MR_proc_entry_uci_name(module, __Unify__,	\
+				type, arity, 0)
+#define	proc_layout	MR_proc_layout_uci_name(module, __Unify__,	\
+				type, arity, 0)
 #define	body_code	do { unify_code } while(0)
 
 #include	"mercury_hand_unify_body.h"
 
 #undef	proc_label
-#undef	proc_static
+#undef	proc_layout
 #undef	body_code
 
-#define	proc_label	MR_TYPE_COMPARE_FUNC(module, type, arity)
-#define	proc_static	MR_proc_static_compiler_name(module, __Compare__, type, \
-				arity, 0)
+#define	proc_label	MR_proc_entry_uci_name(module, __Compare__,	\
+				type, arity, 0)
+#define	proc_layout	MR_proc_layout_uci_name(module, __Compare__,	\
+				type, arity, 0)
 #define	body_code	do { compare_code } while(0)
 
 #include	"mercury_hand_compare_body.h"
 
 #undef	proc_label
-#undef	proc_static
+#undef	proc_layout
+#undef	body_code
+
+#define	proc_label	MR_proc_entry_uci_name(module, __CompareRep__,	\
+				type, arity, 0)
+#define	proc_layout	MR_proc_layout_uci_name(module, __CompareRep__,	\
+				type, arity, 0)
+#define	body_code	do { MR_fatal_error(				\
+				"direct type-specific compare_rep call"); \
+			} while(0)
+
+#include	"mercury_hand_compare_body.h"
+
+#undef	proc_label
+#undef	proc_layout
 #undef	body_code
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.70
diff -u -b -r1.70 mercury_ho_call.c
--- runtime/mercury_ho_call.c	23 Mar 2004 07:18:12 -0000	1.70
+++ runtime/mercury_ho_call.c	19 May 2004 03:54:29 -0000
@@ -31,7 +31,9 @@
 #include "mercury_deep_profiling.h"
 #include "mercury_deep_profiling_hand.h"
 #include "mercury_layout_util.h"
-#include "mercury_builtin_types.h"	/* for unify/compare of pred/func */
+#include "mercury_builtin_types.h"
+#include "mercury_builtin_types_proc_layouts.h"
+	/* for unify/compare of pred/func and for proc_layout structures */
 
 #ifdef	MR_DEEP_PROFILING
   #ifdef MR_DEEP_PROFILING_STATISTICS
@@ -54,7 +56,7 @@
 			((void) 0)
   #endif
 
-  #define	special_pred_call_leave_code(ps, field)			\
+  #define	special_pred_call_leave_code(pl, field)			\
 	do {								\
 		MR_CallSiteDynamic	*csd;				\
 		MR_ProcDynamic		*pd;				\
@@ -62,7 +64,7 @@
 		csd = MR_next_call_site_dynamic;			\
 		pd = csd->MR_csd_callee_ptr;				\
 		if (pd == NULL) {					\
-			MR_new_proc_dynamic(pd, (MR_ProcStatic *) &ps);	\
+			MR_new_proc_dynamic(pd, (MR_Proc_Layout *) &pl); \
 			csd->MR_csd_callee_ptr = pd;			\
 			maybe_incr_prof_call_builtin_new();		\
 		} else {						\
@@ -72,46 +74,21 @@
 		csd->MR_csd_own.field++;				\
 	} while (0)
 
-  #define	unify_call_exit_code(predname)				\
+  #define	unify_call_exit_code(mod, pred, type, a)		\
 	special_pred_call_leave_code(					\
-		MR_proc_static_user_builtin_name(predname, 2, 0),	\
+		MR_proc_layout_uci_name(mod, pred, type, a, 0),		\
 		MR_own_exits)
 
-  #define	unify_call_fail_code(predname)				\
+  #define	unify_call_fail_code(mod, pred, type, a)		\
 	special_pred_call_leave_code(					\
-		MR_proc_static_user_builtin_name(predname, 2, 0),	\
+		MR_proc_layout_uci_name(mod, pred, type, a, 0),		\
 		MR_own_fails)
 
-  #define	compare_call_exit_code(predname)			\
+  #define	compare_call_exit_code(mod, pred, type, a)		\
 	special_pred_call_leave_code(					\
-		MR_proc_static_user_builtin_name(predname, 3, 0),	\
+		MR_proc_layout_uci_name(mod, pred, type, a, 0),		\
 		MR_own_exits)
 
-  #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(reference);
-  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
 
 #ifdef MR_HIGHLEVEL_CODE
@@ -874,18 +851,18 @@
 
 	if (x_proc_id != y_proc_id) {
 		if (MR_PROC_ID_COMPILER_GENERATED(*x_proc_id)) {
-			x_module_name = x_proc_id->MR_proc_comp.
-						MR_comp_def_module;
-			x_pred_name = x_proc_id->MR_proc_comp.MR_comp_pred_name;
+			x_module_name = x_proc_id->MR_proc_uci.
+						MR_uci_def_module;
+			x_pred_name = x_proc_id->MR_proc_uci.MR_uci_pred_name;
 		} else {
 			x_module_name = x_proc_id->MR_proc_user.
 						MR_user_decl_module;
 			x_pred_name = x_proc_id->MR_proc_user.MR_user_name;
 		}
 		if (MR_PROC_ID_COMPILER_GENERATED(*y_proc_id)) {
-			y_module_name = y_proc_id->MR_proc_comp.
-						MR_comp_def_module;
-			y_pred_name = y_proc_id->MR_proc_comp.MR_comp_pred_name;
+			y_module_name = y_proc_id->MR_proc_uci.
+						MR_uci_def_module;
+			y_pred_name = y_proc_id->MR_proc_uci.MR_uci_pred_name;
 		} else {
 			y_module_name = y_proc_id->MR_proc_user.
 						MR_user_decl_module;
@@ -1123,41 +1100,5 @@
 #ifdef	MR_DEEP_PROFILING
 void mercury_sys_init_call_write_out_proc_statics(FILE *fp)
 {
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(integer_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(integer_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(float_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(float_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(string_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(string_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(c_pointer_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(c_pointer_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(reference_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(reference_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typeinfo_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typeinfo_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typectorinfo_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typectorinfo_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typedesc_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typedesc_compare, 3, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typectordesc_unify, 2, 0));
-	MR_write_out_proc_static(fp, (MR_ProcStatic *)
-		&MR_proc_static_user_builtin_name(typectordesc_compare, 3, 0));
 }
 #endif
Index: runtime/mercury_layout_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.c,v
retrieving revision 1.33
diff -u -b -r1.33 mercury_layout_util.c
--- runtime/mercury_layout_util.c	21 Jan 2004 02:52:37 -0000	1.33
+++ runtime/mercury_layout_util.c	19 May 2004 03:54:29 -0000
@@ -864,7 +864,7 @@
 {
 	if (MR_PROC_LAYOUT_COMPILER_GENERATED(proc_layout)) {
 		*proc_name_ptr = proc_layout->MR_sle_proc_id.
-			MR_proc_comp.MR_comp_pred_name;
+			MR_proc_uci.MR_uci_pred_name;
 		if (MR_streq(*proc_name_ptr, "__Unify__")) {
 			*arity_ptr = 2;
 		} else if (MR_streq(*proc_name_ptr, "__Compare__")) {
@@ -903,7 +903,7 @@
 		** and index. (The index predicate doesn't need these
 		** typeinfos, but it has them anyway.)
 		*/
-		*num_added_args_ptr = proc->MR_sle_comp.MR_comp_type_arity;
+		*num_added_args_ptr = proc->MR_sle_uci.MR_uci_type_arity;
 		*arity_ptr = proc->MR_sle_num_head_vars - *num_added_args_ptr;
 		*pred_or_func_ptr = MR_PREDICATE;
 	} else {
Index: runtime/mercury_minimal_model.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_minimal_model.c,v
retrieving revision 1.11
diff -u -b -r1.11 mercury_minimal_model.c
--- runtime/mercury_minimal_model.c	20 Mar 2004 05:51:26 -0000	1.11
+++ runtime/mercury_minimal_model.c	19 May 2004 03:54:29 -0000
@@ -492,8 +492,8 @@
 ** suspensions and resumptions of derivations.
 */
 
-#define SUSPEND_LABEL(name) MR_PASTE3(MR_SUSPEND_ENTRY, _, name)
-#define RESUME_LABEL(name)  MR_PASTE3(MR_RESUME_ENTRY, _, name)
+#define SUSPEND_LABEL(name) MR_label_name(MR_SUSPEND_ENTRY, name)
+#define RESUME_LABEL(name)  MR_label_name(MR_RESUME_ENTRY, name)
 
 /*
 ** Given pointers to two ordinary frames on the nondet stack, return the
@@ -1278,10 +1278,10 @@
 MR_define_extern_entry(MR_SUSPEND_ENTRY);
 MR_define_extern_entry(MR_RESUME_ENTRY);
 
-MR_MAKE_PROC_LAYOUT(MR_SUSPEND_ENTRY, MR_DETISM_NON, 0, -1,
-    MR_PREDICATE, "table_builtin", "table_nondet_suspend", 2, 0);
-MR_MAKE_PROC_LAYOUT(MR_RESUME_ENTRY, MR_DETISM_NON, 0, -1,
-    MR_PREDICATE, "table_builtin", "table_nondet_resume", 1, 0);
+MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(MR_DETISM_NON, 0, -1,
+    MR_PREDICATE, table_builtin, table_nondet_suspend, 2, 0);
+MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(MR_DETISM_NON, 0, -1,
+    MR_PREDICATE, table_builtin, table_nondet_resume, 1, 0);
 
 #ifndef  MR_USE_MINIMAL_MODEL
 
@@ -1319,24 +1319,24 @@
 MR_declare_label(RESUME_LABEL(FixPointCheck));
 MR_declare_label(RESUME_LABEL(ReachedFixpoint));
 
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    SUSPEND_LABEL(Call), MR_SUSPEND_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(LoopOverSubgoals), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(StartCompletionOp), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(LoopOverSuspensions), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(ReturnAnswer), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(RedoPoint), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(RestartPoint), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(FixPointCheck), MR_RESUME_ENTRY);
-MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(
-    RESUME_LABEL(ReachedFixpoint), MR_RESUME_ENTRY);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_suspend, 2, 0,
+    Call);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    LoopOverSubgoals);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    StartCompletionOp);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    LoopOverSuspensions);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    ReturnAnswer);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    RedoPoint);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    RestartPoint);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    FixPointCheck);
+MR_MAKE_USER_INTERNAL_LAYOUT(table_builtin, table_nondet_resume, 1, 0,
+    ReachedFixpoint);
 
 MR_BEGIN_MODULE(table_nondet_suspend_resume_module)
     MR_init_entry_sl(MR_SUSPEND_ENTRY);
Index: runtime/mercury_minimal_model.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_minimal_model.h,v
retrieving revision 1.8
diff -u -b -r1.8 mercury_minimal_model.h
--- runtime/mercury_minimal_model.h	20 Mar 2004 05:51:27 -0000	1.8
+++ runtime/mercury_minimal_model.h	19 May 2004 03:54:29 -0000
@@ -230,8 +230,10 @@
 
 #ifndef	MR_HIGHLEVEL_CODE
 
-  #define MR_SUSPEND_ENTRY     mercury__table_builtin__table_nondet_suspend_2_0
-  #define MR_RESUME_ENTRY      mercury__table_builtin__table_nondet_resume_1_0
+  #define MR_SUSPEND_ENTRY     MR_proc_entry_user_name(table_builtin,	\
+		  			table_nondet_suspend, 2, 0)
+  #define MR_RESUME_ENTRY      MR_proc_entry_user_name(table_builtin,	\
+		  			table_nondet_resume, 1, 0)
 
   MR_declare_entry(MR_SUSPEND_ENTRY);
   MR_declare_entry(MR_RESUME_ENTRY);
Index: runtime/mercury_ml_expand_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ml_expand_body.h,v
retrieving revision 1.30
diff -u -b -r1.30 mercury_ml_expand_body.h
--- runtime/mercury_ml_expand_body.h	5 Apr 2004 07:18:55 -0000	1.30
+++ runtime/mercury_ml_expand_body.h	19 May 2004 03:54:29 -0000
@@ -749,7 +749,7 @@
                 MR_Closure_Layout   *closure_layout;
                 MR_Proc_Id          *proc_id;
                 MR_User_Proc_Id     *user_proc_id;
-                MR_Compiler_Proc_Id *comp_proc_id;
+                MR_UCI_Proc_Id      *uci_proc_id;
                 MR_ConstString      name;
                 int                 num_args;
                 int                 i;
@@ -764,7 +764,7 @@
                 if (proc_id->MR_proc_user.MR_user_arity < 0) {
                     name = "dynlink_proc";  /* XXX */
                 } else if (MR_PROC_ID_COMPILER_GENERATED(*proc_id)) {
-                    name = proc_id->MR_proc_comp.MR_comp_pred_name;
+                    name = proc_id->MR_proc_uci.MR_uci_pred_name;
                 } else {
                     name = proc_id->MR_proc_user.MR_user_name;
                 }
Index: runtime/mercury_proc_id.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_proc_id.h,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_proc_id.h
--- runtime/mercury_proc_id.h	3 Feb 2004 05:40:05 -0000	1.2
+++ runtime/mercury_proc_id.h	19 May 2004 03:54:29 -0000
@@ -32,7 +32,7 @@
 ** MR_PROC_LAYOUT_COMPILER_GENERATED, which will return true only if
 ** the procedure is of the second type.
 **
-** The compiler generates MR_User_Proc_Id and MR_Compiler_Proc_Id structures
+** The compiler generates MR_User_Proc_Id and MR_UCI_Proc_Id structures
 ** in order to avoid having to initialize the MR_Proc_Id union through the
 ** inapplicable alternative, since the C standard in widespread use now
 ** doesn't support that.
@@ -50,18 +50,18 @@
 	MR_int_least16_t	MR_user_mode;
 };
 
-struct MR_Compiler_Proc_Id_Struct {
-	MR_ConstString		MR_comp_type_name;
-	MR_ConstString		MR_comp_type_module;
-	MR_ConstString		MR_comp_def_module;
-	MR_ConstString		MR_comp_pred_name;
-	MR_int_least16_t	MR_comp_type_arity;
-	MR_int_least16_t	MR_comp_mode;
+struct MR_UCI_Proc_Id_Struct {
+	MR_ConstString		MR_uci_type_name;
+	MR_ConstString		MR_uci_type_module;
+	MR_ConstString		MR_uci_def_module;
+	MR_ConstString		MR_uci_pred_name;
+	MR_int_least16_t	MR_uci_type_arity;
+	MR_int_least16_t	MR_uci_mode;
 };
 
 union MR_Proc_Id_Union {
 	MR_User_Proc_Id		MR_proc_user;
-	MR_Compiler_Proc_Id	MR_proc_comp;
+	MR_UCI_Proc_Id		MR_proc_uci;
 };
 
 #define	MR_PROC_ID_COMPILER_GENERATED(proc_id)				\
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.78
diff -u -b -r1.78 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h	14 Apr 2004 01:31:57 -0000	1.78
+++ runtime/mercury_stack_layout.h	19 May 2004 03:54:29 -0000
@@ -381,17 +381,7 @@
 /*
 ** Define a stack layout for an internal label.
 **
-** The MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY variant allows you to specify
-** the label name (l) and the entry label name (e) independently, which
-** means that it can be used for labels in code fragments which are
-** simultaneously part of several procedures. (Some hand-written code
-** in the library is like this; the different procedures usually differ
-** only in attributes such as the uniqueness of their arguments.)
-**
-** The MR_MAKE_INTERNAL_LAYOUT variant assumes that the internal label
-** is in the procedure named by the entry label.
-**
-** The only useful information in the structures created by these macros
+** The only useful information in the structures created by this macro
 ** is the reference to the procedure layout, which allows you to find the
 ** stack frame size and the succip location, thereby enabling stack tracing.
 **
@@ -405,20 +395,17 @@
 #define	MR_LABEL_LAYOUT_REF(label)					\
 	((const MR_Label_Layout *) &MR_LAYOUT_FROM_LABEL(MR_add_prefix(label)))
 
-#define MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(label, entry) \
+#define MR_MAKE_USER_INTERNAL_LAYOUT(module, name, arity, mode, label)	\
 	MR_Label_Layout_No_Var_Info					\
-	MR_LAYOUT_FROM_LABEL(label) = {					\
+	MR_label_layout_user_name(module, name, arity, mode, label) = {	\
 		(MR_Proc_Layout *) &					\
-			MR_PASTE2(mercury_data__proc_layout__, entry),	\
+			MR_proc_layout_user_name(module, name, arity, mode), \
 		-1,							\
 		MR_FALSE,						\
 		0,							\
 		-1		/* No info about live values */		\
 	}
 
-#define MR_MAKE_INTERNAL_LAYOUT(entry, labelnum)			\
-	MR_MAKE_INTERNAL_LAYOUT_WITH_ENTRY(entry##_i##labelnum, entry)
-
 /*
 ** These macros are used as shorthands in generated C source files.
 ** The first two arguments are the entry label name and the label number;
@@ -813,16 +800,20 @@
 **   one for user-defined procedures and one for procedures of the compiler
 **   generated Unify, Index and Compare predicates.
 **
-** - The third group is the MR_Exec_Trace structure, which contains
-**   information specifically intended for the debugger. It will be generated
-**   only if the module is compiled with execution tracing.
+** - The third group is the MR_Exec_Trace and MR_ProcStatic structures, which
+**   contain information specifically intended for the debugger and the deep
+**   profiler respectively. The MR_Exec_Trace structure will be generated
+**   only if the module is compiled with execution tracing, while the
+**   MR_ProcStatic structure will be generated only if the module is compiled
+**   in a deep profiling grade.
 **
 ** The runtime system considers all proc layout structures to be of type
 ** MR_Proc_Layout, but must use the macros defined below to check for the 
 ** existence of each substructure before accessing the fields of that
 ** substructure. The macros are MR_PROC_LAYOUT_HAS_PROC_ID to check for the
-** MR_Proc_Id substructure and MR_PROC_LAYOUT_HAS_EXEC_TRACE to check for the
-** MR_Exec_Trace substructure.
+** MR_Proc_Id substructure, MR_PROC_LAYOUT_HAS_EXEC_TRACE to check for the
+** MR_Exec_Trace substructure. and MR_PROC_LAYOUT_HAS_PROC_STATIC to check for
+** the MR_ProcStatic substructure.
 **
 ** The reason why some substructures may be missing is to save space.
 ** If the options with which a module is compiled do not require execution
@@ -831,61 +822,48 @@
 ** substructure will not be present either
 **
 ** The compiler itself generates proc layout structures using the following
-** five types.
+** three types.
 **
 ** - When generating only stack traversal information, the compiler will
 **   generate proc layout structures of type MR_Proc_Layout_Traversal.
 **
-** - When generating only stack traversal and procedure id information, the
-**   compiler will generate proc layout structures of types MR_Proc_Layout_User
-**   and MR_Proc_Layout_Compiler.
-**
-** - When generating all three groups of information, the compiler will
-**   generate proc layout structures of types MR_Proc_Layout_User_Exec
-**   and MR_Proc_Layout_Compiler_Exec.
+** - When generating stack traversal and procedure id information, plus
+**   possibly others, the compiler will generate proc layout structures of
+**   types MR_Proc_Layout_User and MR_Proc_Layout_UCI.
 */
 
 struct MR_Proc_Layout_Struct {
 	MR_Stack_Traversal	MR_sle_traversal;
 	MR_Proc_Id		MR_sle_proc_id;
-	MR_Exec_Trace		MR_sle_exec_trace;
+	MR_STATIC_CODE_CONST MR_Exec_Trace	*MR_sle_exec_trace;
+	MR_ProcStatic				*MR_sle_proc_static;
 };
 
-typedef	struct MR_Proc_Layout_Traversal_Struct {
-	MR_Stack_Traversal	MR_trav_traversal;
-	MR_Word			MR_trav_no_proc_id;	/* will be -1 */
-} MR_Proc_Layout_Traversal;
-
 typedef	struct MR_Proc_Layout_User_Struct {
 	MR_Stack_Traversal	MR_user_traversal;
 	MR_User_Proc_Id		MR_user_id;
-	MR_Word			MR_user_no_exec_trace;	/* will be NULL */
+	MR_STATIC_CODE_CONST MR_Exec_Trace	*MR_sle_exec_trace;
+	MR_ProcStatic				*MR_sle_proc_static;
 } MR_Proc_Layout_User;
 
-typedef	struct MR_Proc_Layout_Compiler_Struct {
-	MR_Stack_Traversal	MR_comp_traversal;
-	MR_Compiler_Proc_Id	MR_comp_id;
-	MR_Word			MR_comp_no_exec_trace;	/* will be NULL */
-} MR_Proc_Layout_Compiler;
-
-typedef	struct MR_Proc_Layout_User_Exec_Struct {
-	MR_Stack_Traversal	MR_user_exec_traversal;
-	MR_User_Proc_Id		MR_user_exec_id;
-	MR_Exec_Trace		MR_user_exec_trace;
-} MR_Proc_Layout_User_Exec;
-
-typedef	struct MR_Proc_Layout_Compiler_Exec_Struct {
-	MR_Stack_Traversal	MR_comp_exec_traversal;
-	MR_Compiler_Proc_Id	MR_comp_exec_id;
-	MR_Exec_Trace		MR_comp_exec_trace;
-} MR_Proc_Layout_Compiler_Exec;
+typedef	struct MR_Proc_Layout_UCI_Struct {
+	MR_Stack_Traversal			MR_uci_traversal;
+	MR_UCI_Proc_Id				MR_uci_id;
+	MR_STATIC_CODE_CONST MR_Exec_Trace	*MR_sle_exec_trace;
+	MR_ProcStatic				*MR_sle_proc_static;
+} MR_Proc_Layout_UCI;
+
+typedef	struct MR_Proc_Layout_Traversal_Struct {
+	MR_Stack_Traversal	MR_trav_traversal;
+	MR_Word			MR_trav_no_proc_id;	/* will be -1 */
+} MR_Proc_Layout_Traversal;
 
 #define	MR_PROC_LAYOUT_HAS_PROC_ID(entry)			\
 		((MR_Word) entry->MR_sle_user.MR_user_pred_or_func != -1)
 
 #define	MR_PROC_LAYOUT_HAS_EXEC_TRACE(entry)			\
 		(MR_PROC_LAYOUT_HAS_PROC_ID(entry)		\
-		&& entry->MR_sle_call_label != NULL)
+		&& entry->MR_sle_exec_trace != NULL)
 
 #define	MR_sle_code_addr	MR_sle_traversal.MR_trav_code_addr
 #define	MR_sle_succip_locn	MR_sle_traversal.MR_trav_succip_locn
@@ -893,28 +871,28 @@
 #define	MR_sle_detism		MR_sle_traversal.MR_trav_detism
 
 #define	MR_sle_user		MR_sle_proc_id.MR_proc_user
-#define	MR_sle_comp		MR_sle_proc_id.MR_proc_comp
+#define	MR_sle_uci		MR_sle_proc_id.MR_proc_uci
 
-#define	MR_sle_call_label	MR_sle_exec_trace.MR_exec_call_label
-#define	MR_sle_module_layout	MR_sle_exec_trace.MR_exec_module_layout
-#define	MR_sle_proc_rep		MR_sle_exec_trace.MR_exec_proc_rep
-#define	MR_sle_tabling_pointer	MR_sle_exec_trace.MR_exec_tabling_pointer
-#define	MR_sle_table_info	MR_sle_exec_trace.MR_exec_table_info
-#define	MR_sle_head_var_nums	MR_sle_exec_trace.MR_exec_head_var_nums
-#define	MR_sle_num_head_vars	MR_sle_exec_trace.MR_exec_num_head_vars
-#define	MR_sle_used_var_names	MR_sle_exec_trace.MR_exec_used_var_names
-#define	MR_sle_max_named_var_num MR_sle_exec_trace.MR_exec_max_named_var_num
-#define	MR_sle_max_r_num	MR_sle_exec_trace.MR_exec_max_r_num
-#define	MR_sle_maybe_from_full	MR_sle_exec_trace.MR_exec_maybe_from_full
-#define	MR_sle_maybe_io_seq	MR_sle_exec_trace.MR_exec_maybe_io_seq
-#define	MR_sle_maybe_trail	MR_sle_exec_trace.MR_exec_maybe_trail
-#define	MR_sle_maybe_maxfr	MR_sle_exec_trace.MR_exec_maybe_maxfr
-#define	MR_sle_maybe_call_table MR_sle_exec_trace.MR_exec_maybe_call_table
-#define	MR_sle_maybe_decl_debug MR_sle_exec_trace.MR_exec_maybe_decl_debug
+#define	MR_sle_call_label	MR_sle_exec_trace->MR_exec_call_label
+#define	MR_sle_module_layout	MR_sle_exec_trace->MR_exec_module_layout
+#define	MR_sle_proc_rep		MR_sle_exec_trace->MR_exec_proc_rep
+#define	MR_sle_tabling_pointer	MR_sle_exec_trace->MR_exec_tabling_pointer
+#define	MR_sle_table_info	MR_sle_exec_trace->MR_exec_table_info
+#define	MR_sle_head_var_nums	MR_sle_exec_trace->MR_exec_head_var_nums
+#define	MR_sle_num_head_vars	MR_sle_exec_trace->MR_exec_num_head_vars
+#define	MR_sle_used_var_names	MR_sle_exec_trace->MR_exec_used_var_names
+#define	MR_sle_max_named_var_num MR_sle_exec_trace->MR_exec_max_named_var_num
+#define	MR_sle_max_r_num	MR_sle_exec_trace->MR_exec_max_r_num
+#define	MR_sle_maybe_from_full	MR_sle_exec_trace->MR_exec_maybe_from_full
+#define	MR_sle_maybe_io_seq	MR_sle_exec_trace->MR_exec_maybe_io_seq
+#define	MR_sle_maybe_trail	MR_sle_exec_trace->MR_exec_maybe_trail
+#define	MR_sle_maybe_maxfr	MR_sle_exec_trace->MR_exec_maybe_maxfr
+#define	MR_sle_maybe_call_table MR_sle_exec_trace->MR_exec_maybe_call_table
+#define	MR_sle_maybe_decl_debug MR_sle_exec_trace->MR_exec_maybe_decl_debug
 
 #define	MR_sle_eval_method(proc_layout_ptr)				\
 			((MR_EvalMethod) (proc_layout_ptr)->		\
-				MR_sle_exec_trace.MR_exec_eval_method_CAST_ME)
+				MR_sle_exec_trace->MR_exec_eval_method_CAST_ME)
 
 	/* Adjust the arity of functions for printing. */
 #define MR_sle_user_adjusted_arity(entry)				\
@@ -924,7 +902,7 @@
 
 /*
 ** Define a layout structure for a procedure, containing information
-** for the first two substructures.
+** for stack traversal and procedure identification.
 **
 ** The slot count and the succip location parameters do not have to be
 ** supplied for procedures that live on the nondet stack, since for such
@@ -939,11 +917,11 @@
 ** is hand-written as C modules cannot be inlined in other Mercury modules.
 **
 ** Due to the possibility that code addresses are not static, any use of
-** the MR_MAKE_PROC_LAYOUT macro has to be accompanied by a call to the
+** the MR_MAKE_PROC_ID_PROC_LAYOUT macro has to be accompanied by a call to the
 ** MR_INIT_PROC_LAYOUT_ADDR macro in the initialization code of the C module
 ** that defines the entry. (The cast in the body of MR_INIT_PROC_LAYOUT_ADDR
 ** is needed because compiler-generated layout structures may use any of the
-** five variant types listed above.)
+** variant types listed above.)
 */ 
 
 #define	MR_PROC_NO_SLOT_COUNT		-1
@@ -961,27 +939,97 @@
 		} while (0)
 #endif
 
-#define MR_MAKE_PROC_LAYOUT(entry, detism, slots, succip_locn,		\
-		pf, module, name, arity, mode) 				\
-	MR_Proc_Layout_User						\
-	MR_PASTE2(mercury_data__proc_layout__, entry) = {		\
+#define MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(sc, detism, slots, succip_locn, \
+		pf, module, name, arity, mode, proc_static)		\
+	MR_declare_entry(MR_proc_entry_user_name(module, name, 		\
+		arity, mode));						\
+	sc const MR_Proc_Layout_User					\
+	MR_proc_layout_user_name(module, name, arity, mode) = {		\
 		{							\
-			MR_MAKE_PROC_LAYOUT_ADDR(entry),		\
+			MR_MAKE_PROC_LAYOUT_ADDR(			\
+				MR_proc_entry_user_name(module, name,	\
+					arity, mode)),			\
 			succip_locn,					\
 			slots,						\
 			detism						\
 		},							\
 		{							\
 			pf,						\
-			module,						\
-			module,						\
-			name,						\
+			MR_STRINGIFY(module),				\
+			MR_STRINGIFY(module),				\
+			MR_STRINGIFY(name),				\
+			arity,						\
+			mode						\
+		},							\
+		NULL,							\
+		(MR_ProcStatic *) proc_static				\
+	}
+
+#define MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(sc, detism, slots, succip_locn, \
+		module, name, type, arity, mode, proc_static)		\
+	MR_declare_entry(MR_proc_entry_uci_name(module, name,		\
+		type, arity, mode)); 					\
+	sc const MR_Proc_Layout_UCI					\
+	MR_proc_layout_uci_name(module, name, type, arity, mode) = {	\
+		{							\
+			MR_MAKE_PROC_LAYOUT_ADDR(			\
+				MR_proc_entry_uci_name(module, name,	\
+					type, arity, mode)),		\
+			succip_locn,					\
+			slots,						\
+			detism						\
+		},							\
+		{							\
+			MR_STRINGIFY(type),				\
+			MR_STRINGIFY(module),				\
+			MR_STRINGIFY(module),				\
+			MR_STRINGIFY(name),				\
 			arity,						\
 			mode						\
 		},							\
-		0							\
+		NULL,							\
+		(MR_ProcStatic *) proc_static				\
 	}
 
+#define MR_STATIC_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
+		pf, module, name, arity, mode)				\
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(static, detism, slots,	\
+		succip_locn, pf, module, name, arity, mode,		\
+		&MR_proc_static_user_name(module, name, arity, mode))
+#define MR_EXTERN_USER_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
+		pf, module, name, arity, mode)				\
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots, \
+		succip_locn, pf, module, name, arity, mode,		\
+		&MR_proc_static_user_name(module, name, arity, mode))
+
+#define MR_STATIC_UCI_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
+		module, name, type, arity, mode)			\
+	MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(static, detism, slots,	\
+		succip_locn, module, name, type, arity, mode,		\
+		&MR_proc_static_uci_name(module, name, type, arity, mode))
+#define MR_EXTERN_UCI_PROC_STATIC_PROC_LAYOUT(detism, slots, succip_locn, \
+		module, name, type, arity, mode)			\
+	MR_MAKE_UCI_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots,\
+		succip_locn, module, name, type, arity, mode,		\
+		&MR_proc_static_uci_name(module, name, type, arity, mode))
+
+#define MR_STATIC_USER_PROC_ID_PROC_LAYOUT(detism, slots, succip_locn,	\
+		pf, module, name, arity, mode)				\
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(static, detism, slots,	\
+		succip_locn, pf, module, name, arity, mode, NULL)
+#define MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(detism, slots, succip_locn,	\
+		pf, module, name, arity, mode)				\
+	MR_MAKE_USER_PROC_STATIC_PROC_LAYOUT(/* extern */, detism, slots,\
+		succip_locn, pf, module, name, arity, mode, NULL)
+
+#define MR_DECLARE_UCI_PROC_STATIC_LAYOUTS(mod, n, a)                       \
+	const MR_Proc_Layout_UCI					\
+		MR_proc_layout_uci_name(mod, __Unify__, n, a, 0);	\
+	const MR_Proc_Layout_UCI					\
+		MR_proc_layout_uci_name(mod, __Compare__, n, a, 0);	\
+	const MR_Proc_Layout_UCI					\
+		MR_proc_layout_uci_name(mod, __CompareRep__, n, a, 0);
+
 /*
 ** In procedures compiled with execution tracing, three items are stored
 ** in stack slots with fixed numbers. They are:
@@ -1102,7 +1150,7 @@
 ** the context where the closure was created.
 **
 ** The compiler generates closure id structures as either MR_User_Closure_Id
-** or MR_Compiler_Closure_Id structures in order to avoid initializing the
+** or MR_UCI_Closure_Id structures in order to avoid initializing the
 ** MR_Proc_Id union through an inappropriate member.
 */
 
@@ -1122,12 +1170,12 @@
 	MR_ConstString		MR_user_closure_goal_path;
 };
 
-struct MR_Compiler_Closure_Id_Struct {
-	MR_Compiler_Proc_Id	MR_comp_closure_proc_id;
-	MR_ConstString		MR_comp_closure_module_name;
-	MR_ConstString		MR_comp_closure_file_name;
-	MR_Integer		MR_comp_closure_line_number;
-	MR_ConstString		MR_comp_closure_goal_path;
+struct MR_UCI_Closure_Id_Struct {
+	MR_UCI_Proc_Id		MR_uci_closure_proc_id;
+	MR_ConstString		MR_uci_closure_module_name;
+	MR_ConstString		MR_uci_closure_file_name;
+	MR_Integer		MR_uci_closure_line_number;
+	MR_ConstString		MR_uci_closure_goal_path;
 };
 
 #endif /* not MERCURY_STACK_LAYOUT_H */
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.62
diff -u -b -r1.62 mercury_stack_trace.c
--- runtime/mercury_stack_trace.c	12 Mar 2004 06:02:07 -0000	1.62
+++ runtime/mercury_stack_trace.c	19 May 2004 03:54:29 -0000
@@ -1262,16 +1262,16 @@
         }
 
         fprintf(fp, "%s for %s.%s/%ld-%ld",
-            entry->MR_sle_comp.MR_comp_pred_name,
-            entry->MR_sle_comp.MR_comp_type_module,
-            entry->MR_sle_comp.MR_comp_type_name,
-            (long) entry->MR_sle_comp.MR_comp_type_arity,
-            (long) entry->MR_sle_comp.MR_comp_mode);
+            entry->MR_sle_uci.MR_uci_pred_name,
+            entry->MR_sle_uci.MR_uci_type_module,
+            entry->MR_sle_uci.MR_uci_type_name,
+            (long) entry->MR_sle_uci.MR_uci_type_arity,
+            (long) entry->MR_sle_uci.MR_uci_mode);
 
-        if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
-            entry->MR_sle_comp.MR_comp_def_module) != 0)
+        if (strcmp(entry->MR_sle_uci.MR_uci_type_module,
+            entry->MR_sle_uci.MR_uci_def_module) != 0)
         {
-            fprintf(fp, " {%s}", entry->MR_sle_comp.MR_comp_def_module);
+            fprintf(fp, " {%s}", entry->MR_sle_uci.MR_uci_def_module);
         }
     } else {
         if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
Index: runtime/mercury_stacks.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stacks.h,v
retrieving revision 1.44
diff -u -b -r1.44 mercury_stacks.h
--- runtime/mercury_stacks.h	6 Apr 2004 22:29:40 -0000	1.44
+++ runtime/mercury_stacks.h	19 May 2004 03:54:29 -0000
@@ -386,10 +386,20 @@
 	)
 } MR_Exception_Handler_Frame;
 
+/*
+** In deep profiling grades, we need (a) 1 stack slot (framevar 1)
+** to save the input closure across the call port code; (b) up to 2 stack slots
+** (framevars 1 and 2) to store the result and maybe the success indicator,
+** and (c) 4 stack slots (frame vars 3 to 6) for use by the profiling
+** routines themselves. We can reuse framevar 1 for two purposes because their
+** live ranges do not overlap.
+*/
+
 #ifdef	MR_DEEP_PROFILING
-  #define MR_EXCEPTION_FRAMEVARS	2
+  #define MR_EXCEPTION_FRAMEVARS	6
+  #define MR_EXCEPTION_FIRST_DEEP_SLOT	3
 #else
-  #define MR_EXCEPTION_FRAMEVARS	0
+  #define MR_EXCEPTION_FRAMEVARS	2
 #endif
 
 #define MR_EXCEPTION_STRUCT \
@@ -405,9 +415,6 @@
 		** redoip when unwinding the nondet stack in		      \
 		** builtin_throw/1), and save the stuff we will		      \
 		** need if an exception is thrown.			      \
-		**							      \
-		** In deep profiling grades, we need two stack slots to save  \
-		** intermediate values in across calls to profiling routines. \
 		*/							      \
 		MR_mkpragmaframe((name), MR_EXCEPTION_FRAMEVARS,	      \
 			MR_Exception_Handler_Frame_struct,		      \
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.26
diff -u -b -r1.26 mercury_std.h
--- runtime/mercury_std.h	17 Jun 2003 09:42:31 -0000	1.26
+++ runtime/mercury_std.h	19 May 2004 03:54:29 -0000
@@ -238,6 +238,14 @@
 #define MR_PASTE9_2(a,b,c,d,e,f,g,h,i)	    a##b##c##d##e##f##g##h##i
 #define MR_PASTE10(a,b,c,d,e,f,g,h,i,j)	    MR_PASTE10_2(a,b,c,d,e,f,g,h,i,j)
 #define MR_PASTE10_2(a,b,c,d,e,f,g,h,i,j)   a##b##c##d##e##f##g##h##i##j
+#define MR_PASTE11(a,b,c,d,e,f,g,h,i,j,k)     \
+				MR_PASTE11_2(a,b,c,d,e,f,g,h,i,j,k)
+#define MR_PASTE11_2(a,b,c,d,e,f,g,h,i,j,k)   \
+				a##b##c##d##e##f##g##h##i##j##k
+#define MR_PASTE12(a,b,c,d,e,f,g,h,i,j,k,l)	\
+				MR_PASTE12_2(a,b,c,d,e,f,g,h,i,j,k,l)
+#define MR_PASTE12_2(a,b,c,d,e,f,g,h,i,j,k,l) \
+				a##b##c##d##e##f##g##h##i##j##k##l
 
 /*
 ** MR_CHECK_EXPR_TYPE(expr, type):
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.56
diff -u -b -r1.56 mercury_trace_base.c
--- runtime/mercury_trace_base.c	12 Mar 2004 06:02:07 -0000	1.56
+++ runtime/mercury_trace_base.c	19 May 2004 03:54:29 -0000
@@ -68,7 +68,7 @@
 MR_Unsigned		MR_io_tabling_stop_event_num = 0;
 MR_bool			MR_io_tabling_debug = MR_FALSE;
 
-#ifdef	MR_REQUIRE_TRACING
+#ifdef	MR_EXEC_TRACE
   MR_bool		MR_io_tabling_allowed = MR_TRUE;
 #else
   MR_bool		MR_io_tabling_allowed = MR_FALSE;
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.112
diff -u -b -r1.112 mercury_type_info.h
--- runtime/mercury_type_info.h	1 Apr 2004 04:51:06 -0000	1.112
+++ runtime/mercury_type_info.h	19 May 2004 03:54:29 -0000
@@ -1313,34 +1313,6 @@
   #define MR_DEFINE_TYPE_CTOR_INFO_STRING(s)                            \
         MR_string_const(MR_STRINGIFY(s), sizeof(MR_STRINGIFY(s))-1)
 
-  #define MR_UNIFY_COMPARE_DECLS(m, n, a)                               \
-        MR_declare_entry(MR_TYPE_UNIFY_FUNC(m, n, a));                  \
-        MR_declare_entry(MR_TYPE_COMPARE_FUNC(m, n, a));
-
-  #define MR_UNIFY_COMPARE_DEFNS(m, n, a)                               \
-        MR_define_extern_entry(MR_TYPE_UNIFY_FUNC(m, n, a));            \
-        MR_define_extern_entry(MR_TYPE_COMPARE_FUNC(m, n, a));
-
-  #ifdef MR_DEEP_PROFILING
-
-    #define MR_UNIFY_COMPARE_LABELS(m, n, a)                            \
-        MR_init_entry(MR_TYPE_UNIFY_FUNC(m, n, a));                     \
-        MR_init_entry(MR_TYPE_COMPARE_FUNC(m, n, a));                   \
-        MR_init_label(MR_PASTE2(MR_TYPE_UNIFY_FUNC(m, n, a), _i1));     \
-        MR_init_label(MR_PASTE2(MR_TYPE_UNIFY_FUNC(m, n, a), _i2));     \
-        MR_init_label(MR_PASTE2(MR_TYPE_UNIFY_FUNC(m, n, a), _i3));     \
-        MR_init_label(MR_PASTE2(MR_TYPE_UNIFY_FUNC(m, n, a), _i4));     \
-        MR_init_label(MR_PASTE2(MR_TYPE_COMPARE_FUNC(m, n, a), _i1));   \
-        MR_init_label(MR_PASTE2(MR_TYPE_COMPARE_FUNC(m, n, a), _i2));
-
-  #else  /* ! MR_DEEP_PROFILING */
-
-    #define MR_UNIFY_COMPARE_LABELS(m, n, a)                            \
-        MR_init_entry(MR_TYPE_UNIFY_FUNC(m, n, a));                     \
-        MR_init_entry(MR_TYPE_COMPARE_FUNC(m, n, a));
-
-  #endif /* MR_DEEP_PROFILING */
-
 #endif /* MR_HIGHLEVEL_CODE */
 
 #define MR_DEFINE_TYPE_CTOR_INFO_BODY_FLAG(m, n, a, cr, u, c, f)        \
@@ -1485,20 +1457,6 @@
 
 #define MR_REGISTER_TYPE_CTOR_INFO(m, n, a)                             \
     MR_register_type_ctor_info(&MR_TYPE_CTOR_INFO_NAME(m, n, a))
-
-#define MR_DEFINE_PROC_STATICS(mod, n, a)                               \
-    MR_proc_static_compiler_empty(mod, __Unify__, n, a, 0,              \
-        MR_STRINGIFY(mod) ".m", 0, MR_TRUE);                  \
-    MR_proc_static_compiler_empty(mod, __Compare__, n, a, 0,            \
-        MR_STRINGIFY(mod) ".m", 0, MR_TRUE);
-
-#define MR_WRITE_OUT_PROC_STATICS(fp, m, n, a)                          \
-    do {                                                                \
-        MR_write_out_proc_static(fp, (MR_ProcStatic *)                  \
-            &MR_proc_static_compiler_name(m, __Unify__, n, a, 0));      \
-        MR_write_out_proc_static(fp, (MR_ProcStatic *)                  \
-            &MR_proc_static_compiler_name(m, __Compare__, n, a, 0));    \
-    } while (0)
 
 /*---------------------------------------------------------------------------*/
 
Index: runtime/mercury_types.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.36
diff -u -b -r1.36 mercury_types.h
--- runtime/mercury_types.h	3 Feb 2004 05:40:05 -0000	1.36
+++ runtime/mercury_types.h	19 May 2004 03:54:29 -0000
@@ -201,18 +201,18 @@
 
 typedef struct MR_Closure_Id_Struct             MR_Closure_Id;
 typedef struct MR_User_Closure_Id_Struct        MR_User_Closure_Id;
-typedef struct MR_Compiler_Closure_Id_Struct    MR_Compiler_Closure_Id;
+typedef struct MR_UCI_Closure_Id_Struct         MR_UCI_Closure_Id;
 
 typedef struct MR_Type_Param_Locns_Struct       MR_Type_Param_Locns;
 
 typedef struct MR_User_Proc_Id_Struct           MR_User_Proc_Id;
-typedef struct MR_Compiler_Proc_Id_Struct       MR_Compiler_Proc_Id;
+typedef struct MR_UCI_Proc_Id_Struct            MR_UCI_Proc_Id;
 typedef union  MR_Proc_Id_Union                 MR_Proc_Id;
 
 typedef struct MR_CallSiteStatic_Struct         MR_CallSiteStatic;
 typedef struct MR_CallSiteDynamic_Struct        MR_CallSiteDynamic;
 typedef struct MR_User_ProcStatic_Struct        MR_User_ProcStatic;
-typedef struct MR_Compiler_ProcStatic_Struct    MR_Compiler_ProcStatic;
+typedef struct MR_UCI_ProcStatic_Struct         MR_UCI_ProcStatic;
 typedef struct MR_ProcStatic_Struct             MR_ProcStatic;
 typedef struct MR_ProcDynamic_Struct            MR_ProcDynamic;
 typedef struct MR_ProfilingMetrics_Struct       MR_ProfilingMetrics;
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.34
diff -u -b -r1.34 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h	21 Jan 2004 02:52:38 -0000	1.34
+++ runtime/mercury_unify_compare_body.h	19 May 2004 03:54:29 -0000
@@ -47,36 +47,36 @@
 #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)                           \
+      #define return_compare_answer(mod, type, arity, answer)               \
         do {                                                                \
-            compare_call_exit_code(MR_PASTE2(kind, _compare_representation)); \
+            compare_call_exit_code(mod, __CompareRep__, type, arity);       \
             raw_return_answer(answer);                                      \
         } while (0)
     #else
-      #define return_compare_answer(kind, answer)                           \
+      #define return_compare_answer(mod, type, arity, answer)               \
         do {                                                                \
-            compare_call_exit_code(MR_PASTE2(kind, _compare));              \
+            compare_call_exit_code(mod, __Compare__, type, arity);          \
             raw_return_answer(answer);                                      \
         } while (0)
     #endif
   #else
-    #define return_compare_answer(kind, answer)                             \
+    #define return_compare_answer(mod, type, arity, answer)                 \
         raw_return_answer(answer)
   #endif
 #else
   #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
-    #define return_unify_answer(kind, answer)                               \
+    #define return_unify_answer(mod, type, arity, answer)                   \
         do {                                                                \
             if (answer) {                                                   \
-                unify_call_exit_code(MR_PASTE2(kind, _unify));              \
+                unify_call_exit_code(mod, __Unify__, type, arity);          \
                 raw_return_answer(MR_TRUE);                                 \
             } else {                                                        \
-                unify_call_fail_code(MR_PASTE2(kind, _unify));              \
+                unify_call_fail_code(mod, __Unify__, type, arity);          \
                 raw_return_answer(MR_FALSE);                                \
             }                                                               \
         } while (0)
   #else
-    #define return_unify_answer(kind, answer)                               \
+    #define return_unify_answer(mod, type, arity, answer)                   \
         raw_return_answer(answer)
   #endif
 #endif
@@ -223,9 +223,11 @@
                     if (x_functor_desc->MR_du_functor_ordinal <
                         y_functor_desc->MR_du_functor_ordinal)
                     {
-                        return_compare_answer(user, MR_COMPARE_LESS);
+                        return_compare_answer(builtin, user_by_rtti, 0,
+                            MR_COMPARE_LESS);
                     } else {
-                        return_compare_answer(user, MR_COMPARE_GREATER);
+                        return_compare_answer(builtin, user_by_rtti, 0,
+                            MR_COMPARE_GREATER);
                     }
                 }
 
@@ -320,9 +322,11 @@
                         MR_restore_transient_registers();
                         if (result != MR_COMPARE_EQUAL) {
   #ifdef  select_compare_code
-                            return_compare_answer(user, result);
+                            return_compare_answer(builtin, user_by_rtti, 0,
+                                result);
   #else
-                            return_unify_answer(user, MR_FALSE);
+                            return_unify_answer(builtin, user_by_rtti, 0,
+                                MR_FALSE);
   #endif
                         }
                     }
@@ -355,7 +359,8 @@
     #endif
                     MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
-                        return_compare_answer(user, result);
+                        return_compare_answer(builtin, user_by_rtti, 0,
+                            result);
                     }
   #else
                     MR_save_transient_registers();
@@ -363,16 +368,18 @@
                         x_data_value[cur_slot], y_data_value[cur_slot]);
                     MR_restore_transient_registers();
                     if (! result) {
-                        return_unify_answer(user, MR_FALSE);
+                        return_unify_answer(builtin, user_by_rtti, 0,
+                            MR_FALSE);
                     }
   #endif
                     cur_slot++;
                 }
 
   #ifdef  select_compare_code
-                return_compare_answer(user, MR_COMPARE_EQUAL);
+                return_compare_answer(builtin, user_by_rtti, 0,
+                    MR_COMPARE_EQUAL);
   #else
-                return_unify_answer(user, MR_TRUE);
+                return_unify_answer(builtin, user_by_rtti, 0, MR_TRUE);
   #endif
             }
 
@@ -476,7 +483,7 @@
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
                     MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
-                        return_compare_answer(tuple, result);
+                        return_compare_answer(builtin, tuple, 0, result);
                     }
 #else
                     MR_save_transient_registers();
@@ -484,14 +491,14 @@
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
                     MR_restore_transient_registers();
                     if (! result) {
-                        return_unify_answer(tuple, MR_FALSE);
+                        return_unify_answer(builtin, tuple, 0, MR_FALSE);
                     }
 #endif
                 }
 #ifdef  select_compare_code
-                return_compare_answer(tuple, MR_COMPARE_EQUAL);
+                return_compare_answer(builtin, tuple, 0, MR_COMPARE_EQUAL);
 #else
-                return_unify_answer(tuple, MR_TRUE);
+                return_unify_answer(builtin, tuple, 0, MR_TRUE);
 #endif
             }
 
@@ -505,14 +512,15 @@
 
 #ifdef  select_compare_code
             if ((MR_Integer) x == (MR_Integer) y) {
-                return_compare_answer(integer, MR_COMPARE_EQUAL);
+                return_compare_answer(builtin, int, 0, MR_COMPARE_EQUAL);
             } else if ((MR_Integer) x < (MR_Integer) y) {
-                return_compare_answer(integer, MR_COMPARE_LESS);
+                return_compare_answer(builtin, int, 0, MR_COMPARE_LESS);
             } else {
-                return_compare_answer(integer, MR_COMPARE_GREATER);
+                return_compare_answer(builtin, int, 0, MR_COMPARE_GREATER);
             }
 #else
-            return_unify_answer(integer, (MR_Integer) x == (MR_Integer) y);
+            return_unify_answer(builtin, int, 0,
+                (MR_Integer) x == (MR_Integer) y);
 #endif
 
         case MR_TYPECTOR_REP_FLOAT:
@@ -523,14 +531,15 @@
                 fy = MR_word_to_float(y);
 #ifdef  select_compare_code
                 if (fx == fy) {
-                    return_compare_answer(float, MR_COMPARE_EQUAL);
+                    return_compare_answer(builtin, float, 0, MR_COMPARE_EQUAL);
                 } else if (fx < fy) {
-                    return_compare_answer(float, MR_COMPARE_LESS);
+                    return_compare_answer(builtin, float, 0, MR_COMPARE_LESS);
                 } else {
-                    return_compare_answer(float, MR_COMPARE_GREATER);
+                    return_compare_answer(builtin, float, 0,
+                        MR_COMPARE_GREATER);
                 }
 #else
-                return_unify_answer(float, fx == fy);
+                return_unify_answer(builtin, float, 0, fx == fy);
 #endif
             }
 
@@ -542,14 +551,17 @@
 
 #ifdef  select_compare_code
                 if (result == 0) {
-                    return_compare_answer(string, MR_COMPARE_EQUAL);
+                    return_compare_answer(builtin, string, 0,
+                        MR_COMPARE_EQUAL);
                 } else if (result < 0) {
-                    return_compare_answer(string, MR_COMPARE_LESS);
+                    return_compare_answer(builtin, string, 0,
+                        MR_COMPARE_LESS);
                 } else {
-                    return_compare_answer(string, MR_COMPARE_GREATER);
+                    return_compare_answer(builtin, string, 0,
+                        MR_COMPARE_GREATER);
                 }
 #else
-                return_unify_answer(string, result == 0);
+                return_unify_answer(builtin, string, 0, result == 0);
 #endif
             }
 
@@ -566,14 +578,18 @@
         case MR_TYPECTOR_REP_C_POINTER:
 #ifdef  select_compare_code
             if ((void *) x == (void *) y) {
-                return_compare_answer(c_pointer, MR_COMPARE_EQUAL);
+                return_compare_answer(builtin, c_pointer, 0,
+                    MR_COMPARE_EQUAL);
             } else if ((void *) x < (void *) y) {
-                return_compare_answer(c_pointer, MR_COMPARE_LESS);
+                return_compare_answer(builtin, c_pointer, 0,
+                    MR_COMPARE_LESS);
             } else {
-                return_compare_answer(c_pointer, MR_COMPARE_GREATER);
+                return_compare_answer(builtin, c_pointer, 0,
+                    MR_COMPARE_GREATER);
             }
 #else
-            return_unify_answer(c_pointer, (void *) x == (void *) y);
+            return_unify_answer(builtin, c_pointer, 0,
+                (void *) x == (void *) y);
 #endif
 
         case MR_TYPECTOR_REP_TYPEINFO:
@@ -585,7 +601,7 @@
                 result = MR_compare_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-                return_compare_answer(typeinfo, result);
+                return_compare_answer(private_builtin, type_info, 1, result);
 #else
                 MR_bool result;
 
@@ -593,7 +609,7 @@
                 result = MR_unify_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-                return_unify_answer(typeinfo, result);
+                return_unify_answer(private_builtin, type_info, 1, result);
 #endif
             }
 
@@ -611,7 +627,7 @@
                 result = MR_compare_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-                return_compare_answer(typedesc, result);
+                return_compare_answer(type_desc, type_desc, 0, result);
 #else
                 MR_bool result;
 
@@ -619,7 +635,7 @@
                 result = MR_unify_type_info(
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
-                return_unify_answer(typedesc, result);
+                return_unify_answer(type_desc, type_desc, 0, result);
 #endif
             }
 
@@ -632,7 +648,8 @@
                 result = MR_compare_type_ctor_info(
                     (MR_TypeCtorInfo) x, (MR_TypeCtorInfo) y);
                 MR_restore_transient_registers();
-                return_compare_answer(typectorinfo, result);
+                return_compare_answer(private_builtin, type_ctor_info, 1,
+                    result);
 #else
                 MR_bool result;
 
@@ -640,7 +657,8 @@
                 result = MR_unify_type_ctor_info(
                     (MR_TypeCtorInfo) x, (MR_TypeCtorInfo) y);
                 MR_restore_transient_registers();
-                return_unify_answer(typectorinfo, result);
+                return_unify_answer(private_builtin, type_ctor_info, 1,
+                    result);
 #endif
             }
 
@@ -653,7 +671,7 @@
                 result = MR_compare_type_ctor_desc(
                     (MR_TypeCtorDesc) x, (MR_TypeCtorDesc) y);
                 MR_restore_transient_registers();
-                return_compare_answer(typectordesc, result);
+                return_compare_answer(type_desc, type_ctor_desc, 0, result);
 #else
                 MR_bool result;
 
@@ -661,7 +679,7 @@
                 result = MR_unify_type_ctor_desc(
                     (MR_TypeCtorDesc) x, (MR_TypeCtorDesc) y);
                 MR_restore_transient_registers();
-                return_unify_answer(typectordesc, result);
+                return_unify_answer(type_desc, type_ctor_desc, 0, result);
 #endif
             }
 
@@ -680,9 +698,9 @@
                 MR_restore_transient_registers();
 
                 if (MR_type_ctor_rep(type_ctor_info) == MR_TYPECTOR_REP_FUNC) {
-                    return_compare_answer(func, result);
+                    return_compare_answer(builtin, func, 0, result);
                 } else {
-                    return_compare_answer(pred, result);
+                    return_compare_answer(builtin, pred, 0, result);
                 }
 #else
                 MR_fatal_error(attempt_msg "higher-order terms");
@@ -731,7 +749,8 @@
             */
             MR_fatal_error(attempt_msg "terms of a reference type");
 #else
-            return_unify_answer(reference, (void *) x == (void *) y);
+            return_unify_answer(private_builtin, ref, 1,
+                (void *) x == (void *) y);
 #endif
 
         case MR_TYPECTOR_REP_UNKNOWN:
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.131
diff -u -b -r1.131 mercury_wrapper.c
--- runtime/mercury_wrapper.c	12 Feb 2004 06:54:57 -0000	1.131
+++ runtime/mercury_wrapper.c	19 May 2004 03:54:29 -0000
@@ -919,7 +919,8 @@
 	MR_MDB_IN_WINDOW,
 	MR_FORCE_READLINE,
 	MR_NUM_OUTPUT_ARGS,
-	MR_DEBUG_THREADS_OPT
+	MR_DEBUG_THREADS_OPT,
+	MR_DEEP_PROF_DEBUG_FILE_OPT
 };
 
 struct MR_option MR_long_opts[] = {
@@ -942,7 +943,8 @@
 	{ "mdb-in-window",		0, 0, MR_MDB_IN_WINDOW },
 	{ "force-readline",		0, 0, MR_FORCE_READLINE },
 	{ "num-output-args", 		1, 0, MR_NUM_OUTPUT_ARGS },
-	{ "debug-threads",		0, 0, MR_DEBUG_THREADS_OPT }
+	{ "debug-threads",		0, 0, MR_DEBUG_THREADS_OPT },
+	{ "deep-debug-file",		0, 0, MR_DEEP_PROF_DEBUG_FILE_OPT }
 };
 
 static void
@@ -1094,6 +1096,10 @@
 #ifdef MR_THREAD_SAFE
 			MR_debug_threads = MR_TRUE;
 #endif
+			break;
+
+		case MR_DEEP_PROF_DEBUG_FILE_OPT:
+			MR_deep_prof_debug_file_flag = MR_TRUE;
 			break;
 
 		case 'a':
cvs server: Diffing runtime/GETOPT
cvs server: Diffing runtime/machdeps
cvs server: Diffing samples
cvs server: Diffing samples/c_interface
cvs server: Diffing samples/c_interface/c_calls_mercury
cvs server: Diffing samples/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/c_interface/mercury_calls_c
cvs server: Diffing samples/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/c_interface/mercury_calls_fortran
cvs server: Diffing samples/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/diff
cvs server: Diffing samples/muz
cvs server: Diffing samples/rot13
cvs server: Diffing samples/solutions
cvs server: Diffing samples/tests
cvs server: Diffing samples/tests/c_interface
cvs server: Diffing samples/tests/c_interface/c_calls_mercury
cvs server: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/tests/c_interface/mercury_calls_c
cvs server: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs server: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/tests/diff
cvs server: Diffing samples/tests/muz
cvs server: Diffing samples/tests/rot13
cvs server: Diffing samples/tests/solutions
cvs server: Diffing samples/tests/toplevel
cvs server: Diffing scripts
Index: scripts/c2init.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/c2init.in,v
retrieving revision 1.42
diff -u -b -r1.42 c2init.in
--- scripts/c2init.in	12 Feb 2004 02:48:17 -0000	1.42
+++ scripts/c2init.in	19 May 2004 03:54:29 -0000
@@ -57,13 +57,15 @@
 
 MKINIT=${MERCURY_MKINIT=mkinit}
 
-case $require_tracing in
-	true)
+case $debug in true)
 		trace_opt="-t" ;;
 esac
 
-case $stack_trace in
-	true)
+case $debug in true)
+	init_opt="-i" ;;
+esac
+
+case $profile_deep in true)
 		init_opt="-i" ;;
 esac
 
Index: scripts/canonical_grade.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/canonical_grade.sh-subr,v
retrieving revision 1.8
diff -u -b -r1.8 canonical_grade.sh-subr
--- scripts/canonical_grade.sh-subr	20 Oct 2003 07:29:36 -0000	1.8
+++ scripts/canonical_grade.sh-subr	19 May 2004 03:54:29 -0000
@@ -127,12 +127,10 @@
 # 	false)	;;
 # esac
 
-case $stack_trace,$require_tracing,$decl_debug in
-	true,true,true)		GRADE="$GRADE.decldebug" ;;
-	true,true,false)	GRADE="$GRADE.debug" ;;
-	false,true,false)	GRADE="$GRADE.trace" ;;
-	true,false,false)	GRADE="$GRADE.strce" ;;
-	false,false,false)	;;
+case $debug,$decl_debug in
+	true,true)		GRADE="$GRADE.decldebug" ;;
+	true,false)		GRADE="$GRADE.debug" ;;
+	false,false)		;;
 	*)			progname=`basename $0`
 				echo "$progname: error: invalid combination of debugging options." 1>&2
 				exit 1
Index: scripts/final_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/final_grade_options.sh-subr,v
retrieving revision 1.10
diff -u -b -r1.10 final_grade_options.sh-subr
--- scripts/final_grade_options.sh-subr	11 Feb 2004 03:54:04 -0000	1.10
+++ scripts/final_grade_options.sh-subr	19 May 2004 03:54:29 -0000
@@ -23,8 +23,7 @@
 # .tr grade is not compatible with .mm
 #	(see comment in runtime/mercury_tabling.c for rationale)
 #
-case $use_trail,$use_minimal_model in
-	true,true)
+case $use_trail,$use_minimal_model in true,true)
 		echo "trailing and minimal model tabling are not compatible" 1>&2
 		exit 1 ;;
 esac
@@ -33,8 +32,7 @@
 # .debug grade implies --use-trail in the absence of .mm
 #	(see comment in compiler/handle_options.m for rationale)
 #
-case $stack_trace,$require_tracing,$use_minimal_model in
-	true,true,false)
+case $debug,$use_minimal_model in true,false)
 		use_trail=true ;;
 esac
 
@@ -42,9 +40,7 @@
 # --decl-debug implies --debug
 #
 case $decl_debug in true)
-	require_tracing=true
-	stack_trace=true
-	;;
+	debug=true ;;
 esac
 
 #
Index: scripts/init_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/init_grade_options.sh-subr,v
retrieving revision 1.21
diff -u -b -r1.21 init_grade_options.sh-subr
--- scripts/init_grade_options.sh-subr	20 Oct 2003 07:29:36 -0000	1.21
+++ scripts/init_grade_options.sh-subr	19 May 2004 03:54:29 -0000
@@ -72,8 +72,7 @@
 reserve_tag=false
 use_minimal_model=false
 pic_reg=false
-stack_trace=false
-require_tracing=false
+debug=false
 decl_debug=false
 
 case $# in
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.101
diff -u -b -r1.101 mgnuc.in
--- scripts/mgnuc.in	2 Apr 2004 09:32:29 -0000	1.101
+++ scripts/mgnuc.in	19 May 2004 03:54:29 -0000
@@ -413,13 +413,8 @@
 	false)		PICREG_OPTS="" ;;
 esac
 
-case $stack_trace in
-	true)		STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;;
-	false)		STACK_TRACE_OPTS="" ;;
-esac
-
-case $require_tracing in
-	true)		TRACE_OPTS="-DMR_REQUIRE_TRACING" ;;
+case $debug in
+	true)		TRACE_OPTS="-DMR_EXEC_TRACE" ;;
 	false)		TRACE_OPTS="" ;;
 esac
 
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.110
diff -u -b -r1.110 ml.in
--- scripts/ml.in	10 Apr 2004 05:12:23 -0000	1.110
+++ scripts/ml.in	19 May 2004 03:54:29 -0000
@@ -98,9 +98,7 @@
 
 MAYBE_STATIC_OPT=""
 
-# --require-tracing (which is implied by --debug and by --decl-debug)
-# implies --trace
-case $require_tracing in
+case $debug in
 	true)	trace=true ;;
 	false)	;;
 esac
Index: scripts/parse_grade_options.sh-subr
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/parse_grade_options.sh-subr,v
retrieving revision 1.27
diff -u -b -r1.27 parse_grade_options.sh-subr
--- scripts/parse_grade_options.sh-subr	10 Feb 2004 12:43:33 -0000	1.27
+++ scripts/parse_grade_options.sh-subr	19 May 2004 03:54:29 -0000
@@ -158,23 +158,10 @@
 	--no-pic-reg)
 		pic_reg=false ;;
 
-# The following more fine-grained options have been omitted
-# since they are not very useful and would probably only confuse people.
-#	--stack-trace)
-#		stack_trace=true ;;
-#	--no-stack-trace)
-#		stack_trace=false ;;
-#	--require-tracing)
-#		require_tracing=true ;;
-#	--no-require-tracing)
-#		require_tracing=false ;;
-
 	--debug)
-		stack_trace=true
-		require_tracing=true ;;
+		debug=true ;;
 	--no-debug)
-		stack_trace=false
-		require_tracing=false ;;
+		debug=false ;;
 
 	--decl-debug)
 		decl_debug=true ;;
@@ -210,8 +197,7 @@
 		reserve_tag=false
 		use_minimal_model=false
 		pic_reg=false
-		stack_trace=false
-		require_tracing=false
+		debug=false
 		decl_debug=false
 
 		grade_pieces=`echo $grade | tr '.' ' '`
@@ -412,23 +398,11 @@
 					pic_reg=true
 					;;
 
-# The following more fine-grained options have been omitted
-# since they are not very useful and would probably only confuse people.
-#				trace)
-#					stack_trace=false
-#					require_tracing=true
-#
-#				strce)
-#					stack_trace=true
-#					require_tracing=false
-
 				debug)
-					stack_trace=true
-					require_tracing=true
+					debug=true
 					;;
+
 				decldebug)
-					stack_trace=true
-					require_tracing=true
 					decl_debug=true
 					;;
 
cvs server: Diffing tests
cvs server: Diffing tests/benchmarks
cvs server: Diffing tests/debugger
cvs server: Diffing tests/debugger/declarative
cvs server: Diffing tests/dppd
cvs server: Diffing tests/general
cvs server: Diffing tests/general/accumulator
cvs server: Diffing tests/general/string_format
cvs server: Diffing tests/general/structure_reuse
cvs server: Diffing tests/grade_subdirs
cvs server: Diffing tests/hard_coded
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.231
diff -u -b -r1.231 Mmakefile
--- tests/hard_coded/Mmakefile	12 May 2004 14:19:41 -0000	1.231
+++ tests/hard_coded/Mmakefile	19 May 2004 03:54:29 -0000
@@ -182,7 +182,6 @@
 	user_compare \
 	user_defined_equality2 \
 	write \
-	write_binary \
 	write_reg1 \
 	write_reg2
 
@@ -261,16 +260,6 @@
 	C_ONLY_PROGS=
 endif
 
-# XXX test_array2d does not work in at least asm_fast.gc.profdeep; the
-# problem does not lie in test_array2d or array2d and has not yet been
-# fixed.
-ifeq "$(findstring profdeep,$(GRADE))" ""
-	BROKEN_FOR_PROFDEEP = \
-		test_array2d
-else
-	BROKEN_FOR_PROFDEEP =
-endif
-
 # constant_prop_2 fails in hl*prof* grades, due to a complicated phase
 # ordering problem.  The first simplify pass eliminates a call to
 # private_builtin.typed_unify, but does not yet simplify the if-then-else
@@ -282,10 +271,25 @@
 # so link_error is now dead.  But dead proc elimination doesn't get run
 # again, so we go ahead and emit a declaration for link_error, and in
 # MLDS profiling grades also a reference, which causes the test case to fail.
+
+# constant_prop_2 relies on deleting all references to an external predicate,
+# but the appearance of the call in the caller puts a reference to its proc
+# layout structure into the call sites array of its caller, even if the call
+# is never made. We could fix this by skipping over call sites in unreachable
+# code, but doing so would require duplicating, in deep_profiling.m, the code
+# used by simplify.m to eliminate the unreachable code. Since the only profit
+# would be to pass unrealistic test cases like constant_prop_2, this is not
+# worth doing.
+
 ifeq "$(findstring hl,$(GRADE))$(findstring prof,$(GRADE))" "hlprof"
-	NONHLPROF_PROGS =
+	PROF_PROGS =
 else
-	NONHLPROF_PROGS = constant_prop_2
+  ifeq "$(findstring profdeep,$(GRADE))" ""
+	PROF_PROGS = \
+		constant_prop_2
+  else
+	PROF_PROGS =
+  endif
 endif
 
 # These tests trigger a bug in lcc
@@ -339,13 +343,15 @@
 # The following tests are passed only in some grades.
 
 # Deep profiling cannot yet handle exceptions being caught, which the
-# allow_stubs, dir_test and user_defined_equality test cases do.
+# test cases below do.
 
 ifeq "$(findstring profdeep,$(GRADE))" ""
 	EXCEPTION_PROGS = \
 		allow_stubs \
 		dir_test \
-		user_defined_equality
+		test_array2d \
+		user_defined_equality \
+		write_binary
 else
 	EXCEPTION_PROGS =
 endif
@@ -431,12 +437,12 @@
 ifneq "$(findstring java,$(GRADE))" ""
 	PROGS = $(JAVA_PROGS) $(JAVA_PASS_PROGS)
 else
-	PROGS = $(ORDINARY_PROGS) $(NONHLPROF_PROGS) $(BROKEN_FOR_LCC_PROGS) \
+	PROGS = $(ORDINARY_PROGS) $(PROF_PROGS) $(BROKEN_FOR_LCC_PROGS) \
 		$(CLOSURE_LAYOUT_PROGS) $(EXCEPTION_PROGS) \
 		$(BACKEND_PROGS) $(NONDET_C_PROGS) \
 		$(C_AND_GC_ONLY_PROGS) $(STATIC_LINK_PROGS) \
-		$(CHAR_REP_PROGS) $(BROKEN_FOR_PROFDEEP)  \
-		$(C_ONLY_PROGS) $(DOTNET_PROGS) $(JAVA_PROGS)
+		$(CHAR_REP_PROGS) $(C_ONLY_PROGS) \
+		$(DOTNET_PROGS) $(JAVA_PROGS)
 endif
 
 # --split-c-files does not work in the hl* grades (e.g. hlc.gc),
cvs server: Diffing tests/hard_coded/exceptions
cvs server: Diffing tests/hard_coded/purity
cvs server: Diffing tests/hard_coded/sub-modules
cvs server: Diffing tests/hard_coded/typeclasses
cvs server: Diffing tests/invalid
cvs server: Diffing tests/invalid/purity
cvs server: Diffing tests/misc_tests
cvs server: Diffing tests/mmc_make
cvs server: Diffing tests/mmc_make/lib
cvs server: Diffing tests/recompilation
cvs server: Diffing tests/tabling
cvs server: Diffing tests/term
cvs server: Diffing tests/valid
cvs server: Diffing tests/warnings
cvs server: Diffing tools
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.158
diff -u -b -r1.158 bootcheck
--- tools/bootcheck	30 Dec 2003 10:07:34 -0000	1.158
+++ tools/bootcheck	19 May 2004 03:54:29 -0000
@@ -122,6 +122,14 @@
 		--no-sym-links.
 	--no-sym-links
 		Use this option on systems which don't support symbolic links.
+	--disable-debug-libs
+		Make the trace and browser libraries empty. This can be useful
+		when trying to track down the reason why they are being linked
+		into the compiler in the first place.
+	--keep-deep-data
+		Keep the Deep.data files resulting from the bootcheck. The
+		usual behavior is to delete them in the interest of conserving
+		disk space.
 "
 
 unset WORKSPACE
@@ -169,8 +177,10 @@
 compile_times=false
 write_out_profile_data=true
 type_stats=""
+disable_debug_libs=false
+delete_deep_data=true
 
-if test -r .KEEP_OBJS
+if test -f .KEEP_OBJS
 then
 	keep_objs=true
 fi
@@ -316,6 +326,12 @@
 	--no-sym-links)
 		use_cp=true ;;
 
+	--disable-debug-libs)
+		disable_debug_libs=true ;;
+
+	--keep-deep-data)
+		delete_deep_data=false ;;
+
 	--)	
 		shift; break ;;
 	-*)
@@ -643,6 +659,31 @@
 			/bin/rm -f Mmake.params
 			cp $root/Mmake.stage.params Mmake.params
 		fi
+		if test -f $root/Mmake.stage.browser.params
+		then
+			/bin/rm -f browser/Mmake.browser.params
+			cp $root/Mmake.stage.browser.params browser/Mmake.browser.params
+		fi
+		if test -f $root/Mmake.stage.deep.params
+		then
+			/bin/rm -f deep_profiler/Mmake.deep.params
+			cp $root/Mmake.stage.deep.params deep_profiler/Mmake.deep.params
+		fi
+		if test -f $root/Mmake.stage.library.params
+		then
+			/bin/rm -f library/Mmake.library.params
+			cp $root/Mmake.stage.library.params library/Mmake.library.params
+		fi
+		if test -f $root/Mmake.stage.runtime.params
+		then
+			/bin/rm -f runtime/Mmake.runtime.params
+			cp $root/Mmake.stage.runtime.params runtime/Mmake.runtime.params
+		fi
+		if test -f $root/Mmake.stage.trace.params
+		then
+			/bin/rm -f trace/Mmake.trace.params
+			cp $root/Mmake.stage.trace.params trace/Mmake.trace.params
+		fi
 		if test -f $root/Mercury.stage.options
 		then
 			/bin/rm -f Mercury.options
@@ -726,6 +767,14 @@
 			exit 1
 		fi
 
+		if $disable_debug_libs
+		then
+			/bin/rm $stage2dir/browser/lib$BROWSER_LIB_NAME.a
+			ar cr $stage2dir/browser/lib$BROWSER_LIB_NAME.a
+			/bin/rm $stage2dir/trace/lib$TRACE_LIB_NAME.a
+			ar cr $stage2dir/trace/lib$TRACE_LIB_NAME.a
+		fi
+
 		if (cd $stage2dir && $MMAKE $mmake_opts $jfactor analysis)
 		then
 			echo "building of stage 2 analysis successful"
@@ -755,8 +804,10 @@
 		then
 			ls -lt $stage2dir/library/*.c
 			ls -lt $stage2dir/library/*.o
+			ls -lt $stage2dir/library/*.{a,so}
 			ls -lt $stage2dir/compiler/*.c
 			ls -lt $stage2dir/compiler/*.o
+			ls -lt $stage2dir/compiler/mercury_compile
 		fi
 	fi
 
@@ -1281,6 +1332,11 @@
 	fi
 
 	cd $root
+fi
+
+if $delete_deep_data
+then
+	(cd $root; find stage2 tests -name Deep.data -print | xargs /bin/rm -f)
 fi
 
 #-----------------------------------------------------------------------------#
Index: tools/make_port_code
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/make_port_code,v
retrieving revision 1.3
diff -u -b -r1.3 make_port_code
--- tools/make_port_code	29 Aug 2002 07:55:31 -0000	1.3
+++ tools/make_port_code	19 May 2004 03:54:29 -0000
@@ -84,7 +84,7 @@
                     outermost_define="#undef "
                 fi
                 decls=
-                inputs="ProcStatic"
+                inputs="ProcLayout"
                 outputs="TopCSD MiddleCSD"
                 if test $impl = sr
                 then
cvs server: Diffing trace
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.67
diff -u -b -r1.67 mercury_trace.c
--- trace/mercury_trace.c	12 Mar 2004 06:02:18 -0000	1.67
+++ trace/mercury_trace.c	19 May 2004 03:54:29 -0000
@@ -639,7 +639,7 @@
             retry_event_num = MR_event_num_framevar(base_curfr) + 1;
         }
 
-#ifdef  MR_REQUIRE_TRACING
+#ifdef  MR_EXEC_TRACE
         all_actions_tabled = MR_TRUE;
 #else
         all_actions_tabled = assume_all_io_is_tabled;
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.73
diff -u -b -r1.73 mercury_trace_external.c
--- trace/mercury_trace_external.c	12 Mar 2004 06:02:18 -0000	1.73
+++ trace/mercury_trace_external.c	19 May 2004 03:54:29 -0000
@@ -933,16 +933,16 @@
 			depth,
 			port,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_name,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_name,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_module,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_module,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_def_module,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_def_module,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_pred_name,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_pred_name,
 			/* is the type_ctor's arity what is wanted? XXX */
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_arity,
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_mode,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_arity,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_mode,
 			layout->MR_sll_entry->MR_sle_detism,
 			(MR_String) (MR_Word) path,
 			lineno,
@@ -1037,16 +1037,16 @@
 			depth,
 			port,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_name,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_name,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_module,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_module,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_def_module,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_def_module,
 			(MR_String)
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_pred_name,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_pred_name,
 			/* is the type_ctor's arity what is wanted? XXX */
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_type_arity,
-			layout->MR_sll_entry->MR_sle_comp.MR_comp_mode,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_type_arity,
+			layout->MR_sll_entry->MR_sle_uci.MR_uci_mode,
 			layout->MR_sll_entry->MR_sle_detism,
 			arguments,
 			(MR_String) (MR_Word) path,
@@ -1373,18 +1373,18 @@
 		MR_send_message_to_socket_format(
 			/* XXX Names with " may cause some problems here */
 			"proc(\"%s\",\"%s\",\"%s\",%ld,%ld).\n",
-			entry->MR_sle_comp.MR_comp_pred_name,
-			entry->MR_sle_comp.MR_comp_type_module,
-			entry->MR_sle_comp.MR_comp_type_name,
-			(long) entry->MR_sle_comp.MR_comp_type_arity,
-			(long) entry->MR_sle_comp.MR_comp_mode);
+			entry->MR_sle_uci.MR_uci_pred_name,
+			entry->MR_sle_uci.MR_uci_type_module,
+			entry->MR_sle_uci.MR_uci_type_name,
+			(long) entry->MR_sle_uci.MR_uci_type_arity,
+			(long) entry->MR_sle_uci.MR_uci_mode);
 
-		if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
-				entry->MR_sle_comp.MR_comp_def_module) != 0)
+		if (strcmp(entry->MR_sle_uci.MR_uci_type_module,
+			entry->MR_sle_uci.MR_uci_def_module) != 0)
 		{
 			MR_send_message_to_socket_format(
 				"def_module(\"%s\").\n",
-				entry->MR_sle_comp.MR_comp_def_module);
+				entry->MR_sle_uci.MR_uci_def_module);
 		}
 	} else {
 		if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.171
diff -u -b -r1.171 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	13 May 2004 08:50:32 -0000	1.171
+++ trace/mercury_trace_internal.c	19 May 2004 03:54:29 -0000
@@ -16,6 +16,7 @@
 #include "mercury_getopt.h"
 #include "mercury_signal.h"
 #include "mercury_builtin_types.h"
+#include "mercury_deep_profiling.h"
 
 #include "mercury_trace.h"
 #include "mercury_trace_internal.h"
@@ -664,6 +665,9 @@
 	*/
 
 	MR_turn_off_debug(&MR_saved_debug_state, MR_FALSE);
+#if	defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
+	MR_disable_deep_profiling_in_debugger = MR_TRUE;
+#endif
 
 	MR_trace_internal_ensure_init();
 
@@ -709,6 +713,9 @@
 
 	MR_scroll_next = 0;
 	MR_turn_debug_back_on(&MR_saved_debug_state);
+#if	defined(MR_DEEP_PROFILING) && defined(MR_EXEC_TRACE)
+	MR_disable_deep_profiling_in_debugger = MR_FALSE;
+#endif
 	return jumpaddr;
 }
 
cvs server: Diffing util
cvs server: Diffing vim
cvs server: Diffing vim/after
cvs server: Diffing vim/ftplugin
cvs server: 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