[m-rev.] diff: consistent variable numbers in proc layouts

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Apr 1 12:09:15 AEST 2005


This will be committed only on the main branch; applying the diff
to the release branch causes conflicts. The test cases whose "failures"
it fixes can be disabled on the release branch.

Zoltan.

Ensure the variable numbers we use procedure layouts are consistent across
trace levels.

compiler/continuation_info.m:
compiler/code_gen.m:
	Record procedure bodies even if the trace level is not --trace rep,
	to allow it to be used to compute the variable number compression map.

compiler/stack_layout.m:
	Always compute and use the variable number compression map.

tests/debugger/field_names.exp:
tests/debugger/declarative/dependency.exp:
	Update the expected variable numbers.

tests/debugger/declarative/loopcheck.exp:
	Expect fewer events in declarative debugging grades after my previous
	change to buultin.unify.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.137
diff -u -b -r1.137 code_gen.m
--- compiler/code_gen.m	24 Mar 2005 05:33:59 -0000	1.137
+++ compiler/code_gen.m	31 Mar 2005 04:53:54 -0000
@@ -349,9 +349,9 @@
 			eff_trace_needs_proc_body_reps(PredInfo, ProcInfo,
 				TraceLevel, TraceSuppress) = yes
 		->
-			MaybeGoal = yes(Goal)
+			NeedGoalRep = yes
 		;
-			MaybeGoal = no
+			NeedGoalRep = no
 		),
 		NeedsAllNames = eff_trace_needs_all_var_names(PredInfo,
 			ProcInfo, TraceLevel, TraceSuppress),
@@ -371,9 +371,10 @@
 		ProcLayout = proc_layout_info(RttiProcLabel, EntryLabel,
 			Detism, TotalSlots, MaybeSuccipSlot, EvalMethod,
 			EffTraceLevel, MaybeTraceCallLabel, MaxTraceReg,
-			HeadVars, ArgModes, MaybeGoal, InstMap0, TraceSlotInfo,
-			ForceProcId, VarSet, VarTypes, InternalMap,
-			MaybeTableInfo, NeedsAllNames, MaybeDeepProfInfo),
+			HeadVars, ArgModes, Goal, NeedGoalRep, InstMap0,
+			TraceSlotInfo, ForceProcId, VarSet, VarTypes,
+			InternalMap, MaybeTableInfo, NeedsAllNames,
+			MaybeDeepProfInfo),
 		global_data_add_new_proc_layout(proc(PredId, ProcId),
 			ProcLayout, !GlobalData)
 	;
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.58
diff -u -b -r1.58 continuation_info.m
--- compiler/continuation_info.m	24 Mar 2005 02:00:20 -0000	1.58
+++ compiler/continuation_info.m	31 Mar 2005 04:53:42 -0000
@@ -115,9 +115,12 @@
 					% compiler.
 			arg_modes	:: list(mode),
 					% The modes of the head variables.
-			maybe_proc_body	:: maybe(hlds_goal),
-					% The body of the procedure, if
-					% required.
+			proc_body	:: hlds_goal,
+					% The body of the procedure.
+			needs_body_rep	:: bool,
+					% Do we need to include a
+					% representation of the procedure body
+					% in the exec trace layout?
 			initial_instmap	:: instmap,
 					% The instmap at the start of the
 					% procedure body.
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.100
diff -u -b -r1.100 stack_layout.m
--- compiler/stack_layout.m	31 Mar 2005 04:44:22 -0000	1.100
+++ compiler/stack_layout.m	31 Mar 2005 05:18:40 -0000
@@ -308,13 +308,12 @@
 stack_layout__construct_layouts(ProcLayoutInfo, !Info) :-
 	ProcLayoutInfo = proc_layout_info(RttiProcLabel, EntryLabel, _Detism,
 		_StackSlots, _SuccipLoc, _EvalMethod, _EffTraceLevel,
-		_MaybeCallLabel, _MaxTraceReg, HeadVars, _ArgModes, MaybeGoal,
-		_InstMap, _TraceSlotInfo, ForceProcIdLayout, VarSet, _VarTypes,
-		InternalMap, MaybeTableIoDecl, _NeedsAllNames,
-		_MaybeDeepProfInfo),
+		_MaybeCallLabel, _MaxTraceReg, HeadVars, _ArgModes,
+		Goal, _NeedGoalRep, _InstMap, _TraceSlotInfo,
+		ForceProcIdLayout, VarSet, _VarTypes, InternalMap,
+		MaybeTableIoDecl, _NeedsAllNames, _MaybeDeepProfInfo),
 	map__to_assoc_list(InternalMap, Internals),
-	compute_var_number_map(HeadVars, VarSet, Internals, MaybeGoal,
-		VarNumMap),
+	compute_var_number_map(HeadVars, VarSet, Internals, Goal, VarNumMap),
 
 	ProcLabel = get_proc_label(EntryLabel),
 	stack_layout__get_procid_stack_layout(!.Info, ProcIdLayout0),
@@ -328,9 +327,7 @@
 	;
 		Kind = proc_layout_traversal
 	),
-
 	ProcLayoutName = proc_layout(RttiProcLabel, Kind),
-
 	(
 		( !.Info ^ agc_stack_layout = yes
 		; !.Info ^ trace_stack_layout = yes
@@ -343,7 +340,6 @@
 	;
 		InternalLayouts = []
 	),
-
 	stack_layout__get_label_tables(!.Info, LabelTables0),
 	list__foldl(stack_layout__update_label_table, InternalLayouts,
 		LabelTables0, LabelTables),
@@ -512,9 +508,10 @@
 stack_layout__construct_proc_layout(ProcLayoutInfo, Kind, VarNumMap, !Info) :-
 	ProcLayoutInfo = proc_layout_info(RttiProcLabel, EntryLabel, Detism,
 		StackSlots, SuccipLoc, EvalMethod, EffTraceLevel,
-		MaybeCallLabel, MaxTraceReg, HeadVars, ArgModes, MaybeGoal,
-		InstMap, TraceSlotInfo, _ForceProcIdLayout, VarSet, VarTypes,
-		_InternalMap, MaybeTableInfo, NeedsAllNames, MaybeProcStatic),
+		MaybeCallLabel, MaxTraceReg, HeadVars, ArgModes,
+		Goal, NeedGoalRep, InstMap, TraceSlotInfo, _ForceProcIdLayout,
+		VarSet, VarTypes, _InternalMap, MaybeTableInfo, NeedsAllNames,
+		MaybeProcStatic),
 	stack_layout__construct_proc_traversal(EntryLabel, Detism, StackSlots,
 		SuccipLoc, Traversal, !Info),
 	(
@@ -530,10 +527,10 @@
 		->
 			stack_layout__construct_trace_layout(RttiProcLabel,
 				EvalMethod, EffTraceLevel, MaybeCallLabel,
-				MaxTraceReg, HeadVars, ArgModes, MaybeGoal,
-				InstMap, TraceSlotInfo, VarSet, VarTypes,
-				MaybeTableInfo, NeedsAllNames, VarNumMap,
-				ExecTrace, !Info),
+				MaxTraceReg, HeadVars, ArgModes, Goal,
+				NeedGoalRep, InstMap, TraceSlotInfo,
+				VarSet, VarTypes, MaybeTableInfo,
+				NeedsAllNames, VarNumMap, ExecTrace, !Info),
 			MaybeExecTrace = yes(ExecTrace)
 		;
 			MaybeExecTrace = no
@@ -559,7 +556,7 @@
 
 :- pred stack_layout__construct_trace_layout(rtti_proc_label::in,
 	eval_method::in, trace_level::in, maybe(label)::in, int::in,
-	list(prog_var)::in, list(mode)::in, maybe(hlds_goal)::in,
+	list(prog_var)::in, list(mode)::in, hlds_goal::in, bool::in,
 	instmap::in, trace_slot_info::in, prog_varset::in, vartypes::in,
 	maybe(proc_table_info)::in, bool::in, var_num_map::in,
 	proc_layout_exec_trace::out,
@@ -567,17 +564,17 @@
 
 stack_layout__construct_trace_layout(RttiProcLabel, EvalMethod, EffTraceLevel,
 		MaybeCallLabel, MaxTraceReg, HeadVars, ArgModes,
-		MaybeGoal, InstMap, TraceSlotInfo, _VarSet, VarTypes,
+		Goal, NeedGoalRep, InstMap, TraceSlotInfo, _VarSet, VarTypes,
 		MaybeTableInfo, NeedsAllNames, VarNumMap, ExecTrace, !Info) :-
 	stack_layout__construct_var_name_vector(VarNumMap,
 		NeedsAllNames, MaxVarNum, VarNameVector, !Info),
 	list__map(convert_var_to_int(VarNumMap), HeadVars, HeadVarNumVector),
 	ModuleInfo = !.Info ^ module_info,
 	(
-		MaybeGoal = no,
+		NeedGoalRep = no,
 		ProcBytes = []
 	;
-		MaybeGoal = yes(Goal),
+		NeedGoalRep = yes,
 		ProcBytes = prog_rep__represent_proc(HeadVars,
 			Goal, InstMap, VarTypes, VarNumMap, ModuleInfo)
 	),
@@ -686,27 +683,23 @@
 %---------------------------------------------------------------------------%
 
 :- pred compute_var_number_map(list(prog_var)::in, prog_varset::in,
-	assoc_list(int, internal_layout_info)::in, maybe(hlds_goal)::in,
+	assoc_list(int, internal_layout_info)::in, hlds_goal::in,
 	var_num_map::out) is det.
 
-compute_var_number_map(HeadVars, VarSet, Internals, MaybeGoal, VarNumMap) :-
-	VarNumMap0 = map__init,
-	Counter0 = counter__init(1),	% to match term__var_supply_init
-	(
-		MaybeGoal = yes(Goal),
+compute_var_number_map(HeadVars, VarSet, Internals, Goal, VarNumMap) :-
+	some [!VarNumMap, !Counter] (
+		!:VarNumMap = map__init,
+		!:Counter = counter__init(1), % to match term__var_supply_init
 		goal_util__goal_vars(Goal, GoalVarSet),
 		set__to_sorted_list(GoalVarSet, GoalVars),
 		list__foldl2(add_var_to_var_number_map(VarSet), GoalVars,
-			VarNumMap0, VarNumMap1, Counter0, Counter1)
-	;
-		MaybeGoal = no,
-		VarNumMap1 = VarNumMap0,
-		Counter1 = Counter0
-	),
+			!VarNumMap, !Counter),
 	list__foldl2(add_var_to_var_number_map(VarSet), HeadVars,
-		VarNumMap1, VarNumMap2, Counter1, Counter2),
-	list__foldl2(internal_var_number_map, Internals, VarNumMap2, VarNumMap,
-		Counter2, _Counter).
+			!VarNumMap, !Counter),
+		list__foldl2(internal_var_number_map, Internals, !VarNumMap,
+			!.Counter, _),
+		VarNumMap = !.VarNumMap
+	).
 
 :- pred internal_var_number_map(pair(int, internal_layout_info)::in,
 	var_num_map::in, var_num_map::out, counter::in, counter::out) is det.
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/field_names.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/field_names.exp,v
retrieving revision 1.5
diff -u -b -r1.5 field_names.exp
--- tests/debugger/field_names.exp	5 Apr 2004 07:18:57 -0000	1.5
+++ tests/debugger/field_names.exp	31 Mar 2005 09:48:41 -0000
@@ -239,55 +239,55 @@
 mdb> finish
       11:      6  2 EXIT pred field_names.make_t4/2-0 (det)
 mdb> p 2
-       A(2) (arg 2)           	t2f(0.600000000000000, 61, t1f1(41, 42, 43, 44), t1f2(51, 52, 53))
+       A(1) (arg 2)           	t2f(0.600000000000000, 61, t1f1(41, 42, 43, 44), t1f2(51, 52, 53))
 mdb> p 2^1
-       A(2) (arg 2)           	0.600000000000000
+       A(1) (arg 2)           	0.600000000000000
 mdb> p 2^2
-       A(2) (arg 2)           	61
+       A(1) (arg 2)           	61
 mdb> p 2^3^t1a
-       A(2) (arg 2)           	41
+       A(1) (arg 2)           	41
 mdb> p 2^3^t1b
-       A(2) (arg 2)           	42
+       A(1) (arg 2)           	42
 mdb> p 2^3^t1c
 mdb: the path t1c does not exist.
 mdb> p 2^3^t1d
-       A(2) (arg 2)           	44
+       A(1) (arg 2)           	44
 mdb> p 2^3^t1e
 mdb: the path t1e does not exist.
 mdb> p 2^4
-       A(2) (arg 2)           	t1f2(51, 52, 53)
+       A(1) (arg 2)           	t1f2(51, 52, 53)
 mdb> p 2^4^t1a
 mdb: the path t1a does not exist.
 mdb> p 2^4^t1e
-       A(2) (arg 2)           	51
+       A(1) (arg 2)           	51
 mdb> p 2^4^t1f
 mdb: the path t1f does not exist.
 mdb> p 2^4^t1g
-       A(2) (arg 2)           	53
+       A(1) (arg 2)           	53
 mdb> p 2^t2a
-       A(2) (arg 2)           	0.600000000000000
+       A(1) (arg 2)           	0.600000000000000
 mdb> p 2^t2b
-       A(2) (arg 2)           	t1f1(41, 42, 43, 44)
+       A(1) (arg 2)           	t1f1(41, 42, 43, 44)
 mdb> p 2^t2b^t1a
-       A(2) (arg 2)           	41
+       A(1) (arg 2)           	41
 mdb> p 2^t2b^t1b
-       A(2) (arg 2)           	42
+       A(1) (arg 2)           	42
 mdb> p 2^t2b^t1c
 mdb: the path t1c does not exist.
 mdb> p 2^t2b^t1d
-       A(2) (arg 2)           	44
+       A(1) (arg 2)           	44
 mdb> p 2^t2b^t1e
 mdb: the path t1e does not exist.
 mdb> p 2^t2c
-       A(2) (arg 2)           	t1f2(51, 52, 53)
+       A(1) (arg 2)           	t1f2(51, 52, 53)
 mdb> p 2^t2c^t1a
 mdb: the path t1a does not exist.
 mdb> p 2^t2c^t1e
-       A(2) (arg 2)           	51
+       A(1) (arg 2)           	51
 mdb> p 2^t2c^t1f
 mdb: the path t1f does not exist.
 mdb> p 2^t2c^t1g
-       A(2) (arg 2)           	53
+       A(1) (arg 2)           	53
 mdb> step
       12:      7  2 CALL pred field_names.make_t5/2-0 (det)
 mdb> finish
Index: tests/debugger/loopcheck.exp3
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/loopcheck.exp3,v
retrieving revision 1.2
diff -u -b -r1.2 loopcheck.exp3
--- tests/debugger/loopcheck.exp3	16 Nov 2004 00:16:39 -0000	1.2
+++ tests/debugger/loopcheck.exp3	1 Apr 2005 01:44:50 -0000
@@ -22,5 +22,5 @@
 mdb> continue
 Uncaught Mercury exception:
 Software Error: detected infinite recursion in pred loopcheck.loop/1
-Last trace event was event #316.
+Last trace event was event #312.
 Last trace event before the unhandled exception was event #8.
cvs diff: Diffing tests/debugger/declarative
Index: tests/debugger/declarative/dependency.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/declarative/dependency.exp,v
retrieving revision 1.7
diff -u -b -r1.7 dependency.exp
--- tests/debugger/declarative/dependency.exp	19 Nov 2004 11:54:29 -0000	1.7
+++ tests/debugger/declarative/dependency.exp	31 Mar 2005 09:50:59 -0000
@@ -22,15 +22,15 @@
 mdb> p proc_body
 	
 proc_rep(
-  [|](2, []), 
+  [|](1, []), 
   conj_rep(
     [|](
       atomic_goal_rep(
         det_rep, 
         "dependency.m", 
         20, 
-        [|](3, []), 
-        plain_call_rep("dependency", "p", [|](3, []))), 
+        [|](2, []), 
+        plain_call_rep("dependency", "p", [|](2, []))), 
       [|](
         ite_rep(atomic_goal_rep/5, atomic_goal_rep/5, atomic_goal_rep/5), 
         [|](atomic_goal_rep/5, [|](switch_rep([|]/2), [|](disj_rep([|]/2), [])))))))
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
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 util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list