[m-dev.] for review: --call-trace-struct

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Apr 29 12:38:28 AEST 1999


Estimated hours taken: 10

Add an option that causes the compiler to pass information to the
execution tracing system in one struct, rather than four separate arguments.

Two of these arguments are pointers, which each require two instructions
to set up on SPARC, MIPS and other RISCs that do not use a global pool.
The other two arguments are small constants. Therefore on 32-bit RISCs,
replacing MR_trace/4 with MR_trace_struct/1 will probably replace
six instructions with two, which saves four instructions' worth
of time and 16 bytes of code, at the cost of 12 bytes of data,
and possibly the cost of some instructions later loading the info
from the struct into registers. However, this loading cost does not have
to be paid if tracing is not enabled, and other optimizations may
reduce the cost even if tracing is enabled. For example, I strongly suspect
that on out-of-order machines, which means most CPUs you can buy today,
the load instructions are effectively free, because they happen while
the indirect jump to MR_trace_real takes place.

I intend to benchmark this option on our various platforms,
and have autoconfigure set it on the machines in which it is beneficial.

doc/user_guide.texi:
	Document the new --call-trace-struct option, and say it is not
	for general use.

compiler/options.m:
	Add the new option.

compiler/trace.m:
	If the option is set, call MR_trace_struct instead of MR_trace,
	and create a new kind of static (in both senses) global data structure
	to hold the arguments.

	Move the definition of trace_port to llds.m, and the procedure to
	convert it to string to llds_out.m

compiler/code_info.m:
	Add an extra code_info slot to hold this new kind of global data,
	and its access predicates.

compiler/code_gen.m:
	Transfer this new kind of global data from code_info to the global_data
	part of module_info.

compiler/hlds_pred.m:
	Add a new field to the global_data data structure to hold this data.

compiler/mercury_compile.m:
	Include the new global data in the list of things we give to llds_out.

compiler/llds.m:
	Add a new kind of comp_gen_c_data to hold MR_trace_struct arguments.

	Also move the definition of trace_port from trace.m to here,
	since the new kind of comp_gen_c_data refers to this type.

compiler/llds_out.m:
	Add code to print the new kind of comp_gen_c_data.

	Move the code to print trace_ports from trace.m toi here.

compiler/llds_common.m:
	Ignore the new kind of comp_gen_c_data, since by construction
	its contents are never common with anything else.

runtime/mercury_trace_base.[ch]:
	Add a new variant of MR_trace, MR_trace_struct, that consolidates
	the arguments into a single MR_Trace_Call_Info struct.

	Fix a bad variable name: the int argument to MR_trace is a max r
	register number, not a max mr register number.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.63
diff -u -b -u -r1.63 code_gen.m
--- code_gen.m	1999/04/16 06:04:15	1.63
+++ code_gen.m	1999/04/26 06:19:47
@@ -237,10 +237,13 @@
 			MaybeSuccipSlot, MaybeTraceCallLabel,
 			TraceSlotInfo, ForceProcId, InternalMap),
 		global_data_add_new_proc_layout(GlobalData0,
-			proc(PredId, ProcId), ProcLayout, GlobalData)
+			proc(PredId, ProcId), ProcLayout, GlobalData1)
 	;
-		GlobalData = GlobalData0
+		GlobalData1 = GlobalData0
 	),
+	code_info__get_non_common_static_data(NonCommonStatics, CodeInfo, _),
+	global_data_add_new_non_common_static_datas(GlobalData1,
+		NonCommonStatics, GlobalData),
 
 	predicate_name(ModuleInfo, PredId, Name),
 	predicate_arity(ModuleInfo, PredId, Arity),
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.238
diff -u -b -u -r1.238 code_info.m
--- code_info.m	1999/04/20 11:47:42	1.238
+++ code_info.m	1999/04/26 06:19:49
@@ -129,10 +129,20 @@
 :- pred code_info__get_succip_used(bool, code_info, code_info).
 :- mode code_info__get_succip_used(out, in, out) is det.
 
+		% Get the label layout information created by tracing
+		% during code generation.
 :- pred code_info__get_layout_info(map(label, internal_layout_info), 
 	code_info, code_info).
 :- mode code_info__get_layout_info(out, in, out) is det.
 
+		% Get the global static data structures that have
+		% been created during code generation and which do
+		% not have to be scanned by llds_common, since they
+		% have no common parts by construction.
+:- pred code_info__get_non_common_static_data(list(comp_gen_c_data),
+	code_info, code_info).
+:- mode code_info__get_non_common_static_data(out, in, out) is det.
+
 %---------------------------------------------------------------------------%
 
 :- implementation.
@@ -195,6 +205,10 @@
 	code_info, code_info).
 :- mode code_info__set_temp_content_map(in, in, out) is det.
 
+:- pred code_info__set_non_common_static_data(list(comp_gen_c_data),
+	code_info, code_info).
+:- mode code_info__set_non_common_static_data(in, in, out) is det.
+
 %---------------------------------------------------------------------------%
 
 	% The code_info structure has three groups of fields.
@@ -262,7 +276,7 @@
 		int,		% The maximum number of extra
 				% temporary stackslots that have been
 				% used during the procedure.
-		map(lval, slot_contents)
+		map(lval, slot_contents),
 				% The temporary locations that have ever been
 				% used on the stack, and what they contain.
 				% Once we have used a stack slot to store
@@ -273,6 +287,10 @@
 				% which would make it impossible to describe
 				% to gc what the slot contains after the end
 				% of the branched control structure.
+		list(comp_gen_c_data)
+				% Static data structures created for this
+				% procedure which do not need to be scanned
+				% by llds_common.
 	).
 
 %---------------------------------------------------------------------------%
@@ -331,7 +349,8 @@
 		SaveSuccip,
 		LayoutMap,
 		0,
-		TempContentMap
+		TempContentMap,
+		[]
 	),
 	code_info__init_maybe_trace_info(Globals, ModuleInfo, ProcInfo,
 		MaybeFailVars, TraceSlotInfo, CodeInfo0, CodeInfo1),
@@ -359,163 +378,173 @@
 
 code_info__get_globals(SA, CI, CI) :-
 	CI  = code_info(SA, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_module_info(SB, CI, CI) :-
 	CI  = code_info(_, SB, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_pred_id(SC, CI, CI) :-
 	CI  = code_info(_, _, SC, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_proc_id(SD, CI, CI) :-
 	CI  = code_info(_, _, _, SD, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_proc_info(SE, CI, CI) :-
 	CI  = code_info(_, _, _, _, SE, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_varset(SF, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, SF, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_var_slot_count(SG, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, SG, _,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_maybe_trace_info(SH, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, SH,
-		_, _, _, _, _, _, _, _, _, _, _, _).
+		_, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_forward_live_vars(LA, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		LA, _, _, _, _, _, _, _, _, _, _, _).
+		LA, _, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_instmap(LB, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, LB, _, _, _, _, _, _, _, _, _, _).
+		_, LB, _, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_zombies(LC, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, LC, _, _, _, _, _, _, _, _, _).
+		_, _, LC, _, _, _, _, _, _, _, _, _, _).
 
 code_info__get_exprn_info(LD, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, LD, _, _, _, _, _, _, _, _).
+		_, _, _, LD, _, _, _, _, _, _, _, _, _).
 
 code_info__get_temps_in_use(LE, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, LE, _, _, _, _, _, _, _).
+		_, _, _, _, LE, _, _, _, _, _, _, _, _).
 
 code_info__get_fail_info(LF, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, LF, _, _, _, _, _, _).
+		_, _, _, _, _, LF, _, _, _, _, _, _, _).
 
 code_info__get_label_count(PA, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, PA, _, _, _, _, _).
+		_, _, _, _, _, _, PA, _, _, _, _, _, _).
 
 code_info__get_cell_count(PB, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, PB, _, _, _, _).
+		_, _, _, _, _, _, _, PB, _, _, _, _, _).
 
 code_info__get_succip_used(PC, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, PC, _, _, _).
+		_, _, _, _, _, _, _, _, PC, _, _, _, _).
 
 code_info__get_layout_info(PD, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, PD, _, _).
+		_, _, _, _, _, _, _, _, _, PD, _, _, _).
 
 code_info__get_max_temp_slot_count(PE, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, PE, _).
+		_, _, _, _, _, _, _, _, _, _, PE, _, _).
 
 code_info__get_temp_content_map(PF, CI, CI) :-
 	CI  = code_info(_, _, _, _, _, _, _, _,
-		_, _, _, _, _, _, _, _, _, _, _, PF).
+		_, _, _, _, _, _, _, _, _, _, _, PF, _).
+
+code_info__get_non_common_static_data(PG, CI, CI) :-
+	CI  = code_info(_, _, _, _, _, _, _, _,
+		_, _, _, _, _, _, _, _, _, _, _, _, PG).
 
 %---------------------------------------------------------------------------%
 
 code_info__set_maybe_trace_info(SH, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, _,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF),
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_forward_live_vars(LA, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		_,  LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF),
+		_,  LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_instmap(LB, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, _,  LC, LD, LE, LF, PA, PB, PC, PD, PE, PF),
+		LA, _,  LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_zombies(LC, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, _,  LD, LE, LF, PA, PB, PC, PD, PE, PF),
+		LA, LB, _,  LD, LE, LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_exprn_info(LD, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, _,  LE, LF, PA, PB, PC, PD, PE, PF),
+		LA, LB, LC, _,  LE, LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_temps_in_use(LE, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, _,  LF, PA, PB, PC, PD, PE, PF),
+		LA, LB, LC, LD, _,  LF, PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_fail_info(LF, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, _,  PA, PB, PC, PD, PE, PF),
+		LA, LB, LC, LD, LE, _,  PA, PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_label_count(PA, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, _,  PB, PC, PD, PE, PF),
+		LA, LB, LC, LD, LE, LF, _,  PB, PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_cell_count(PB, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, _,  PC, PD, PE, PF),
+		LA, LB, LC, LD, LE, LF, PA, _,  PC, PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_succip_used(PC, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, _,  PD, PE, PF),
+		LA, LB, LC, LD, LE, LF, PA, PB, _,  PD, PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_layout_info(PD, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, _,  PE, PF),
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, _,  PE, PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_max_temp_slot_count(PE, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, _,  PF),
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, _,  PF, PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__set_temp_content_map(PF, CI0, CI) :-
 	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, _ ),
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, _ , PG),
 	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
+
+code_info__set_non_common_static_data(PG, CI0, CI) :-
+	CI0 = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, _ ),
+	CI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
@@ -634,6 +663,10 @@
 	code_info, code_info).
 :- mode code_info__add_gc_layout_for_label(in, in, in, out) is det.
 
+:- pred code_info__add_non_common_static_data(comp_gen_c_data,
+	code_info, code_info).
+:- mode code_info__add_non_common_static_data(in, in, out) is det.
+
 %---------------------------------------------------------------------------%
 
 :- implementation.
@@ -846,6 +879,11 @@
 	{ map__select(TempContentMap, TempsInUse, TempsInUseContentMap) },
 	{ map__to_assoc_list(TempsInUseContentMap, Temps) }.
 
+code_info__add_non_common_static_data(NonCommonData) -->
+	code_info__get_non_common_static_data(NonCommonDatas0),
+	code_info__set_non_common_static_data(
+		[NonCommonData | NonCommonDatas0]).
+
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
 
@@ -894,11 +932,11 @@
 code_info__reset_to_position(position_info(PosCI), CurCI, NextCI) :-
 		% The static fields in PosCI and CurCI should be identical.
 	PosCI  = code_info(_,  _,  _,  _,  _,  _,  _,  _, 
-		LA, LB, LC, LD, LE, LF, _,  _,  _,  _,  _,  _ ),
+		LA, LB, LC, LD, LE, LF, _,  _,  _,  _,  _,  _,  _ ),
 	CurCI  = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		_,  _,  _,  _,  _,  _,  PA, PB, PC, PD, PE, PF),
+		_,  _,  _,  _,  _,  _,  PA, PB, PC, PD, PE, PF, PG),
 	NextCI = code_info(SA, SB, SC, SD, SE, SF, SG, SH,
-		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF).
+		LA, LB, LC, LD, LE, LF, PA, PB, PC, PD, PE, PF, PG).
 
 code_info__generate_branch_end(StoreMap, MaybeEnd0, MaybeEnd, Code) -->
 	code_info__get_exprn_info(Exprn0),
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.43
diff -u -b -u -r1.43 hlds_module.m
--- hlds_module.m	1999/04/23 01:02:42	1.43
+++ hlds_module.m	1999/04/26 06:19:58
@@ -2136,6 +2136,9 @@
 :- pred global_data_update_proc_layout(global_data::in,
 	pred_proc_id::in, proc_layout_info::in, global_data::out) is det.
 
+:- pred global_data_add_new_non_common_static_datas(global_data::in,
+	list(comp_gen_c_data)::in, global_data::out) is det.
+
 :- pred global_data_maybe_get_proc_layout(global_data::in, pred_proc_id::in,
 	proc_layout_info::out) is semidet.
 
@@ -2148,6 +2151,9 @@
 :- pred global_data_get_all_proc_layouts(global_data::in,
 	list(proc_layout_info)::out) is det.
 
+:- pred global_data_get_all_non_common_static_data(global_data::in,
+	list(comp_gen_c_data)::out) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -2157,11 +2163,20 @@
 
 :- type global_data
 	--->	global_data(
-			proc_var_map,
-			proc_layout_map
+			proc_var_map,		% Information about the global
+						% variables defined by each
+						% procedure.
+			proc_layout_map,	% Information about the
+						% layout structures defined
+						% by each procedure.
+			list(comp_gen_c_data)	% The list of global data
+						% structures that do not need
+						% to be checked by llds_common,
+						% because their construction
+						% ensures no overlaps.
 		).
 
-global_data_init(global_data(EmptyDataMap, EmptyLayoutMap)) :-
+global_data_init(global_data(EmptyDataMap, EmptyLayoutMap, [])) :-
 	map__init(EmptyDataMap),
 	map__init(EmptyLayoutMap).
 
@@ -2186,6 +2201,13 @@
 	global_data_set_proc_layout_map(GlobalData0, ProcLayoutMap,
 		GlobalData).
 
+global_data_add_new_non_common_static_datas(GlobalData0, NewNonCommonStatics,
+		GlobalData) :-
+	global_data_get_non_common_static_data(GlobalData0, NonCommonStatics0),
+	list__append(NewNonCommonStatics, NonCommonStatics0, NonCommonStatics),
+	global_data_set_non_common_static_data(GlobalData0, NonCommonStatics,
+		GlobalData).
+
 global_data_maybe_get_proc_layout(GlobalData0, PredProcId, ProcLayout) :-
 	global_data_get_proc_layout_map(GlobalData0, ProcLayoutMap),
 	map__search(ProcLayoutMap, PredProcId, ProcLayout).
@@ -2202,29 +2224,43 @@
 	global_data_get_proc_layout_map(GlobalData, ProcLayoutMap),
 	map__values(ProcLayoutMap, ProcLayouts).
 
+global_data_get_all_non_common_static_data(GlobalData, NonCommonStatics) :-
+	global_data_get_non_common_static_data(GlobalData, NonCommonStatics).
+
 %-----------------------------------------------------------------------------%
 
 :- pred global_data_get_proc_var_map(global_data::in, proc_var_map::out)
 	is det.
 :- pred global_data_get_proc_layout_map(global_data::in, proc_layout_map::out)
 	is det.
+:- pred global_data_get_non_common_static_data(global_data::in,
+	list(comp_gen_c_data)::out) is det.
 :- pred global_data_set_proc_var_map(global_data::in, proc_var_map::in,
 	global_data::out) is det.
 :- pred global_data_set_proc_layout_map(global_data::in, proc_layout_map::in,
 	global_data::out) is det.
+:- pred global_data_set_non_common_static_data(global_data::in,
+	list(comp_gen_c_data)::in, global_data::out) is det.
 
 global_data_get_proc_var_map(GD, A) :-
-	GD = global_data(A, _).
+	GD = global_data(A, _, _).
 
 global_data_get_proc_layout_map(GD, B) :-
-	GD = global_data(_, B).
+	GD = global_data(_, B, _).
+
+global_data_get_non_common_static_data(GD, C) :-
+	GD = global_data(_, _, C).
 
 global_data_set_proc_var_map(GD0, A, GD) :-
-	GD0 = global_data(_, B),
-	GD  = global_data(A, B).
+	GD0 = global_data(_, B, C),
+	GD  = global_data(A, B, C).
 
 global_data_set_proc_layout_map(GD0, B, GD) :-
-	GD0 = global_data(A, _),
-	GD  = global_data(A, B).
+	GD0 = global_data(A, _, C),
+	GD  = global_data(A, B, C).
+
+global_data_set_non_common_static_data(GD0, C, GD) :-
+	GD0 = global_data(A, B, _),
+	GD  = global_data(A, B, C).
 
 %-----------------------------------------------------------------------------%
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.238
diff -u -b -u -r1.238 llds.m
--- llds.m	1999/04/16 06:04:37	1.238
+++ llds.m	1999/04/26 06:20:01
@@ -107,6 +107,26 @@
 			list(maybe(rval)),	% The arguments of the create.
 			list(pred_proc_id)	% The procedures referenced.
 						% Used by dead_proc_elim.
+		)
+	;	trace_call_info(
+			% This structure contains all the information
+			% we pass to a particular call to MR_trace_struct.
+
+			label,			% The label corresponding
+						% to this point in the code,
+						% whose layout structure
+						% describes the current
+						% contents of registers and
+						% stack slots.
+			string,			% A representation of the
+						% goal_path of the current
+						% position in the procedure.
+			int,			% The number of the highest
+						% numbered r register that is
+						% in use at the time of the
+						% call.
+			trace_port		% The type of port we are
+						% tracing.
 		).
 
 :- type comp_gen_c_module
@@ -426,6 +446,23 @@
 	;	exception
 	;	gc
 	.
+
+	% The kinds of ports for which the code we generate will
+	% call MR_trace. The redo port is not on this list, because for that
+	% port the code that calls MR_trace is not in compiler-generated code,
+	% but in the runtime system.  Likewise for the exception port.
+	% (The same comment applies to the type `external_trace_port'
+	% in trace.m.)
+:- type trace_port
+	--->	call
+	;	exit
+	;	fail
+	;	ite_then
+	;	ite_else
+	;	switch
+	;	disj
+	;	nondet_pragma_first
+	;	nondet_pragma_later.
 
 	% Each call instruction has a list of liveinfo, which stores
 	% information about which variables are live after the call
Index: compiler/llds_common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_common.m,v
retrieving revision 1.21
diff -u -b -u -r1.21 llds_common.m
--- llds_common.m	1998/11/19 06:13:28	1.21
+++ llds_common.m	1999/03/31 06:16:21
@@ -118,6 +118,10 @@
 		comp_gen_c_data(Name, DataName, Export, Args, Refs),
 		Info0, Info) :-
 	llds_common__process_maybe_rvals(Args0, Args, Info0, Info).
+llds_common__process_data(
+		trace_call_info(Label, Path, MaxRegInUse, Port),
+		trace_call_info(Label, Path, MaxRegInUse, Port),
+		Info, Info).
 
 :- pred llds_common__process_procs(list(c_procedure)::in,
 	list(c_procedure)::out, common_info::in, common_info::out) is det.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.106
diff -u -b -u -r1.106 llds_out.m
--- llds_out.m	1999/04/16 06:04:40	1.106
+++ llds_out.m	1999/04/26 06:24:39
@@ -136,6 +136,9 @@
 :- pred llds_out__make_rl_data_name(module_name, string).
 :- mode llds_out__make_rl_data_name(in, out) is det.
 
+:- pred llds_out__trace_port_to_string(trace_port, string).
+:- mode llds_out__trace_port_to_string(in, out) is det.
+
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -643,6 +646,7 @@
 	output_const_term_decl(ArgVals, DataAddr, ExportedFromFile, 
 			yes, yes, no, "", "", 0, _),
 	{ decl_set_insert(DeclSet0, DataAddr, DeclSet) }.
+output_c_data_def(trace_call_info(_, _, _, _), DeclSet, DeclSet) --> [].
 
 :- pred output_comp_gen_c_module_list(list(comp_gen_c_module)::in,
 	set_bbbtree(label)::in, decl_set::in, decl_set::out,
@@ -743,6 +747,37 @@
 	output_const_term_decl(ArgVals, DataAddr, ExportedFromFile, no, yes,
 		yes, "", "", 0, _),
 	{ decl_set_insert(DeclSet1, DataAddr, DeclSet) }.
+output_comp_gen_c_data(trace_call_info(Label, Path, MaxRegInUse, Port),
+		DeclSet0, DeclSet) -->
+	io__write_string("static MR_Trace_Call_Info\nmercury_data__tci__"),
+	output_label(Label),
+	io__write_string(" = {\n\t(const MR_Stack_Layout_Label *)\n"),
+	io__write_string("\t&mercury_data__layout__"),
+	output_label(Label),
+	io__write_string(",\n\t"""),
+	io__write_string(Path),
+	io__write_string(""", "),
+	io__write_int(MaxRegInUse),
+	io__write_string(", "),
+	{ llds_out__trace_port_to_string(Port, PortStr) },
+	io__write_string(PortStr),
+	io__write_string(" };\n"),
+	% Global data structures that hold trace call info
+	% are only ever referred to from calls to MR_trace_struct.
+	% We could add a new kind of data_addr that represents these
+	% structures so that we could put that data_addr inside DeclSet,
+	% but that would require significant extra there for no benefit.
+	{ DeclSet = DeclSet0 }.
+
+llds_out__trace_port_to_string(call, "MR_PORT_CALL").
+llds_out__trace_port_to_string(exit, "MR_PORT_EXIT").
+llds_out__trace_port_to_string(fail, "MR_PORT_FAIL").
+llds_out__trace_port_to_string(ite_then, "MR_PORT_THEN").
+llds_out__trace_port_to_string(ite_else, "MR_PORT_ELSE").
+llds_out__trace_port_to_string(switch,   "MR_PORT_SWITCH").
+llds_out__trace_port_to_string(disj,     "MR_PORT_DISJ").
+llds_out__trace_port_to_string(nondet_pragma_first, "MR_PORT_PRAGMA_FIRST").
+llds_out__trace_port_to_string(nondet_pragma_later, "MR_PORT_PRAGMA_LATER").
 
 :- pred output_user_c_code_list(list(user_c_code)::in,
 	io__state::di, io__state::uo) is det.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.124
diff -u -b -u -r1.124 mercury_compile.m
--- mercury_compile.m	1999/04/23 01:02:49	1.124
+++ mercury_compile.m	1999/04/26 06:20:13
@@ -1984,16 +1984,19 @@
 		ModuleName, CompileErrors) -->
 	globals__io_lookup_bool_option(verbose, Verbose),
 	globals__io_lookup_bool_option(statistics, Stats),
-	{ get_c_interface_info(HLDS, C_InterfaceInfo) },
 	{ base_type_info__generate_llds(HLDS0, TypeCtorInfos) },
 	{ base_type_layout__generate_llds(HLDS0, HLDS1, TypeCtorLayouts) },
 	{ stack_layout__generate_llds(HLDS1, HLDS,
 		ProcLayouts, InternalLayouts, LayoutLabels) },
+	{ get_c_interface_info(HLDS, C_InterfaceInfo) },
+	{ module_info_get_global_data(HLDS, GlobalData) },
+	{ global_data_get_all_proc_vars(GlobalData, GlobalVars) },
+	{ global_data_get_all_non_common_static_data(GlobalData,
+		NonCommonStaticData) },
 	{ list__append(InternalLayouts, TypeCtorLayouts, StaticData0) },
-	{ llds_common(Procs0, StaticData0, ModuleName, Procs1, StaticData) },
+	{ llds_common(Procs0, StaticData0, ModuleName, Procs1, StaticData1) },
+	{ list__append(StaticData1, NonCommonStaticData, StaticData) },
 	{ list__condense([TypeCtorInfos, ProcLayouts, StaticData], AllData) },
-	{ module_info_get_global_data(HLDS1, GlobalData) },
-	{ global_data_get_all_proc_vars(GlobalData, GlobalVars) },
 	mercury_compile__construct_c_file(C_InterfaceInfo, Procs1, GlobalVars,
 		AllData, CFile, NumChunks),
 	mercury_compile__output_llds(ModuleName, CFile, LayoutLabels,
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.260
diff -u -b -u -r1.260 options.m
--- options.m	1999/04/23 01:02:55	1.260
+++ options.m	1999/04/26 06:28:53
@@ -189,6 +189,7 @@
 		;	reclaim_heap_on_semidet_failure
 		;	reclaim_heap_on_nondet_failure
 		;	lazy_code
+		;	call_trace_struct
 		;	have_delay_slot
 		;	num_real_r_regs
 		;	num_real_f_regs
@@ -496,6 +497,7 @@
 	reclaim_heap_on_failure	-	bool_special,
 	reclaim_heap_on_semidet_failure	-	bool(yes),
 	reclaim_heap_on_nondet_failure	-	bool(yes),
+	call_trace_struct		-	bool(no),
 	have_delay_slot		-	bool(no),
 					% the `mmc' script may override the
 					% above default if configure says
@@ -844,6 +846,7 @@
 					reclaim_heap_on_semidet_failure).
 long_option("reclaim-heap-on-nondet-failure",
 					reclaim_heap_on_nondet_failure).
+long_option("call-trace-struct",	call_trace_struct).
 long_option("branch-delay-slot",	have_delay_slot).
 long_option("have-delay-slot",		have_delay_slot).
 long_option("num-real-r-regs",		num_real_r_regs).
@@ -1816,6 +1819,10 @@
 		"\tDon't reclaim heap on backtracking in semidet code.",
 		"--no-reclaim-heap-on-failure",
 		"\tCombines the effect of the two options above.",
+
+		"--call-trace-struct\t\t(This option is not for general use.)",
+		"\tPass information to the tracing system in one struct.",
+
 		"--cc <compiler-name>",
 		"\tSpecify which C compiler to use.",
 		"--c-include-directory <dir>",
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.19
diff -u -b -u -r1.19 trace.m
--- trace.m	1999/04/16 06:04:57	1.19
+++ trace.m	1999/04/26 06:22:53
@@ -54,6 +54,7 @@
 	% call MR_trace. The redo port is not on this list, because for that
 	% port the code that calls MR_trace is not in compiler-generated code,
 	% but in the runtime system.  Likewise for the exception port.
+	% (The same comment applies to the type `trace_port' in llds.m.)
 :- type external_trace_port
 	--->	call
 	;	exit
@@ -146,19 +147,6 @@
 :- import_module (inst), instmap, inst_match, mode_util, options.
 :- import_module list, bool, int, string, map, std_util, require.
 
-	% The redo port is not included in this type; see the comment
-	% on the type external_trace_port above.
-:- type trace_port
-	--->	call
-	;	exit
-	;	fail
-	;	ite_then
-	;	ite_else
-	;	switch
-	;	disj
-	;	nondet_pragma_first
-	;	nondet_pragma_later.
-
 	% Information specific to a trace port.
 :- type trace_port_info
 	--->	external
@@ -493,6 +481,7 @@
 	trace__produce_vars(LiveVars, VarSet, InstMap, TvarSet0, TvarSet,
 		VarInfoList, ProduceCode),
 	code_info__max_reg_in_use(MaxReg),
+	code_info__get_globals(Globals),
 	code_info__variable_locations(VarLocs),
 	code_info__get_proc_info(ProcInfo),
 	{
@@ -502,12 +491,26 @@
 	set__list_to_set(VarInfoList, VarInfoSet),
 	LayoutLabelInfo = layout_label_info(VarInfoSet, TvarDataMap),
 	llds_out__get_label(Label, yes, LabelStr),
-	Quote = """",
-	Comma = ", ",
-	trace__port_to_string(Port, PortStr),
 	DeclStmt = "\t\tCode *MR_jumpaddr;\n",
 	SaveStmt = "\t\tsave_transient_registers();\n",
 	RestoreStmt = "\t\trestore_transient_registers();\n",
+	GotoStmt = "\t\tif (MR_jumpaddr != NULL) GOTO(MR_jumpaddr);",
+	globals__lookup_bool_option(Globals, call_trace_struct,
+		CallTraceStruct)
+	},
+	( { CallTraceStruct = yes } ->
+		{ string__append_list([
+			"\t\tMR_jumpaddr = MR_trace_struct(\n",
+			"\t\t\t&mercury_data__tci__", LabelStr, ");\n"],
+			CallStmt) },
+		{ TraceCallInfo = trace_call_info(Label, PathStr,
+			MaxReg, Port) },
+		code_info__add_non_common_static_data(TraceCallInfo)
+	;
+		{
+		Quote = """",
+		Comma = ", ",
+		llds_out__trace_port_to_string(Port, PortStr),
 	string__int_to_string(MaxReg, MaxRegStr),
 	string__append_list([
 		"\t\tMR_jumpaddr = MR_trace(\n",
@@ -515,8 +518,11 @@
 		"\t\t\t&mercury_data__layout__", LabelStr, Comma, "\n",
 		"\t\t\t", PortStr, Comma, Quote, PathStr, Quote, Comma,
 		MaxRegStr, ");\n"],
-		CallStmt),
-	GotoStmt = "\t\tif (MR_jumpaddr != NULL) GOTO(MR_jumpaddr);",
+			CallStmt)
+		}
+	),
+	code_info__add_trace_layout_for_label(Label, LayoutLabelInfo),
+	{
 	string__append_list([DeclStmt, SaveStmt, CallStmt, RestoreStmt,
 		GotoStmt], TraceStmt),
 	TraceCode =
@@ -535,8 +541,7 @@
 				- ""
 		]),
 	Code = tree(ProduceCode, TraceCode)
-	},
-	code_info__add_trace_layout_for_label(Label, LayoutLabelInfo).
+	}.
 
 trace__maybe_setup_redo_event(TraceInfo, Code) :-
 	TraceInfo = trace_info(_, _, _, TraceRedo),
@@ -599,18 +604,6 @@
 	).
 
 %-----------------------------------------------------------------------------%
-
-:- pred trace__port_to_string(trace_port::in, string::out) is det.
-
-trace__port_to_string(call, "MR_PORT_CALL").
-trace__port_to_string(exit, "MR_PORT_EXIT").
-trace__port_to_string(fail, "MR_PORT_FAIL").
-trace__port_to_string(ite_then, "MR_PORT_THEN").
-trace__port_to_string(ite_else, "MR_PORT_ELSE").
-trace__port_to_string(switch,   "MR_PORT_SWITCH").
-trace__port_to_string(disj,     "MR_PORT_DISJ").
-trace__port_to_string(nondet_pragma_first, "MR_PORT_PRAGMA_FIRST").
-trace__port_to_string(nondet_pragma_later, "MR_PORT_PRAGMA_LATER").
 
 :- pred trace__code_model_to_string(code_model::in, string::out) is det.
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.170
diff -u -b -u -r1.170 user_guide.texi
--- user_guide.texi	1999/04/23 01:03:24	1.170
+++ user_guide.texi	1999/04/26 07:22:58
@@ -3091,6 +3091,11 @@
 Combines the effect of the two options above.
 
 @sp 1
+ at item @code{--call-trace-struct}
+(This option is not intended for general use.)
+Pass information to the tracing system in one struct.
+
+ at sp 1
 @item --cc @var{compiler-name}
 Specify which C compiler to use.
 
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing lp_solve
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.14
diff -u -b -u -r1.14 mercury_trace_base.c
--- mercury_trace_base.c	1999/03/20 07:16:26	1.14
+++ mercury_trace_base.c	1999/04/08 06:14:02
@@ -103,13 +103,87 @@
 #endif
 
 Code *
+MR_trace_struct(const MR_Trace_Call_Info *trace_call_info)
+{
+	/*
+	** You can change the 0 to 1 in the #if if you suspect that
+	** MR_trace and MR_trace_struct have diverged.
+	*/
+
+#if 0
+
+	return MR_trace(trace_call_info->MR_trace_sll,
+		trace_call_info->MR_trace_port,
+		trace_call_info->MR_trace_path,
+		trace_call_info->MR_trace_max_r_num);
+
+#else
+
+	const MR_Stack_Layout_Label	*layout;
+	Integer				maybe_from_full;
+	Unsigned			seqno;
+	Unsigned			depth;
+
+	/*
+	** WARNING WARNING WARNING
+	**
+	** The code of this function is duplicated from MR_trace,
+	** modulo references to the arguments. Any changes here
+	** must also be done there as well.
+	**
+	** This duplication is for efficiency.
+	*/
+
+	if (! MR_trace_enabled) {
+		return NULL;
+	}
+
+	/* in case MR_sp or MR_curfr is transient */
+	restore_transient_registers();
+
+	layout = trace_call_info->MR_trace_sll;
+	maybe_from_full = layout->MR_sll_entry->MR_sle_maybe_from_full;
+	if (MR_DETISM_DET_STACK(layout->MR_sll_entry->MR_sle_detism)) {
+		if (maybe_from_full > 0 && ! MR_stackvar(maybe_from_full)) {
+			return NULL;
+		}
+
+		seqno = (Unsigned) MR_call_num_stackvar(MR_sp);
+		depth = (Unsigned) MR_call_depth_stackvar(MR_sp);
+	} else {
+		if (maybe_from_full > 0 && ! MR_framevar(maybe_from_full)) {
+			return NULL;
+		}
+
+		seqno = (Unsigned) MR_call_num_framevar(MR_curfr);
+		depth = (Unsigned) MR_call_depth_framevar(MR_curfr);
+	}
+
+	return (*MR_trace_func_ptr)(layout, trace_call_info->MR_trace_port,
+			seqno, depth, trace_call_info->MR_trace_path,
+			trace_call_info->MR_trace_max_r_num);
+
+#endif
+}
+
+Code *
 MR_trace(const MR_Stack_Layout_Label *layout, MR_Trace_Port port,
-	const char * path, int max_mr_num)
+	const char * path, int max_r_num)
 {
 	Integer		maybe_from_full;
 	Unsigned	seqno;
 	Unsigned	depth;
 
+	/*
+	** WARNING WARNING WARNING
+	**
+	** The code of this function is duplicated in MR_trace_struct,
+	** modulo references to the arguments. Any changes here
+	** must also be done there as well.
+	**
+	** This duplication is for efficiency.
+	*/
+
 	if (! MR_trace_enabled) {
 		return NULL;
 	}
@@ -135,7 +209,7 @@
 	}
 
 	return (*MR_trace_func_ptr)(layout, port, seqno, depth,
-			path, max_mr_num);
+			path, max_r_num);
 }
 
 static void
@@ -155,7 +229,7 @@
 
 Code *
 MR_trace_fake(const MR_Stack_Layout_Label *layout, MR_Trace_Port port,
-	Unsigned seqno, Unsigned depth, const char * path, int max_mr_num)
+	Unsigned seqno, Unsigned depth, const char * path, int max_r_num)
 {
 	MR_tracing_not_enabled();
 	/*NOTREACHED*/
@@ -285,6 +359,22 @@
 
 #endif	/* MR_TRACE_HISTOGRAM */
 
+/*
+** This structure is only used by MR_do_trace_redo_fail.
+** Every call to MR_trace_struct from MR_do_trace_redo_fail will set the
+** label layout field to the value it finds in the stack slot reserved
+** for this purpose. The other three fields ("", 0, and MR_PORT_REDO)
+** are the same for all calls to MR_trace_struct from here.
+*/
+
+static	MR_Trace_Call_Info	MR_retry_trace_call_info =
+					{
+						NULL,
+						"",
+						0,
+						MR_PORT_REDO
+					};
+
 Define_extern_entry(MR_do_trace_redo_fail);
 
 BEGIN_MODULE(MR_trace_labels_module)
@@ -307,12 +397,15 @@
 	*/
 	{
 		Code *MR_jumpaddr;
+		MR_retry_trace_call_info.MR_trace_sll = 
+			(const MR_Stack_Layout_Label *)
+			MR_redo_layout_framevar(MR_redofr_slot(MR_curfr));
 		save_transient_registers();
-		MR_jumpaddr = MR_trace((const MR_Stack_Layout_Label *)
-			MR_redo_layout_framevar(MR_redofr_slot(MR_curfr)),
-			MR_PORT_REDO, "", 0);
+		MR_jumpaddr = MR_trace_struct(&MR_retry_trace_call_info);
 		restore_transient_registers();
-		if (MR_jumpaddr != NULL) GOTO(MR_jumpaddr);
+		if (MR_jumpaddr != NULL) {
+			GOTO(MR_jumpaddr);
+		}
 	}
 	fail();
 
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.5
diff -u -b -u -r1.5 mercury_trace_base.h
--- mercury_trace_base.h	1998/12/14 16:05:14	1.5
+++ mercury_trace_base.h	1999/04/08 05:55:43
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1997-1998 The University of Melbourne.
+** Copyright (C) 1997-1999 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.
 */
@@ -43,6 +43,24 @@
 #define MR_trace_reset_depth(d)		(MR_trace_call_depth = (Unsigned) (d))
 
 /*
+** This structure holds all the information passed to MR_trace() by the
+** tracing code generated by the compiler. This info is all in one structure
+** to allow calls to MR_trace to simply pass the address of a static data
+** structure. This should be faster than moving several separate arguments
+** into their registers. If tracing is not enabled, the arguments are
+** not looked at anyway. If tracing is enabled, the speed advantage
+** may or may not evaporate, depending on how many of these fields
+** the current trace command looks at.
+*/
+
+typedef struct MR_Trace_Call_Info_Struct {
+	const MR_Stack_Layout_Label	*MR_trace_sll;
+	const char 			*MR_trace_path;
+	int				MR_trace_max_r_num;
+	MR_Trace_Port			MR_trace_port;
+} MR_Trace_Call_Info;
+
+/*
 ** MR_trace is called from Mercury modules compiled with tracing.
 ** If the event is supposed to be traced, it performs an indirect call
 ** through MR_trace_func_ptr, which will point either to MR_trace_real,
@@ -51,10 +69,14 @@
 **
 ** The return value, if not NULL, says where execution should continue
 ** after the event. (NULL means it should continue as usual.)
+**
+** MR_trace_struct is the same as MR_trace, except it takes its arguments
+** in a structure (which is not modified by MR_trace_struct).
 */
 
 extern	Code	*MR_trace(const MR_Stack_Layout_Label *, MR_Trace_Port,
 			const char *, int);
+extern	Code	*MR_trace_struct(const MR_Trace_Call_Info *trace_call_info);
 
 extern	Code	*MR_trace_fake(const MR_Stack_Layout_Label *, MR_Trace_Port,
 			Unsigned, Unsigned, const char *, int);
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list