[m-rev.] for review: more info in procedure body representations

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Apr 3 18:09:01 AEST 2002


For review by Mark.

Add two pieces of information that will be needed to an upcoming change
to the representation of procedure bodies in the declarative debugger.
The first piece is the full list of head vars. This is needed now because the
debugger no longer ignores variables of type type_info, and thus the Nth
headvar is no longer guaranteed to be variable number N. The second piece
is a cut/no_cut indicator in `some' goals. This is needed to allow us to
reconstruct goal paths exactly as we traverse goal representations.

browser/program_representation.m:
	Make the two data structure changes described above.

browser/*.m:
	Trivial changes to conform to the new data structures.

compiler/prog_rep.m:
	Create the updated data procedure representation.

compiler/*.m:
	Record and transmit the information needed by the updated procedure
	representation.

runtime/mercury_stack_layout.h:
	Update the documentation of the relevant field in proc_layouts.

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/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.22
diff -u -b -r1.22 declarative_debugger.m
--- browser/declarative_debugger.m	2002/01/28 07:20:09	1.22
+++ browser/declarative_debugger.m	2002/04/03 07:28:22
@@ -766,11 +766,11 @@
 
 next_contour(Store, Node, Cont, AtomInfo) :-
 	(
-		Node = call(_, _, _, _, _, _, MaybeGoal)
+		Node = call(_, _, _, _, _, _, MaybeProc)
 	->
 		AtomInfo = [],
 		(
-			MaybeGoal = yes(Goal)
+			MaybeProc = yes(proc_rep(_, Goal))
 		->
 			Cont = subgoal_cont(Goal, return)
 		;
@@ -861,7 +861,7 @@
 		process_trace_event_goal(Ref, Event, Goal, neg_cont(Cont0),
 				Cont)
 	).
-process_trace_event_goal(Ref, Event, some_rep(Goal), Cont0, Cont) -->
+process_trace_event_goal(Ref, Event, some_rep(Goal, _), Cont0, Cont) -->
 	process_trace_event_goal(Ref, Event, Goal, Cont0, Cont).
 process_trace_event_goal(Ref, Event, GoalRep, Cont0, Cont) -->
 	{ GoalRep = atomic_goal_rep(_, _, _, _, AtomicGoal) },
@@ -916,7 +916,7 @@
 	{ error("process_non_event_goals_2: cond event expected") }.
 process_non_event_goals_2(negation_rep(Goal), Cont, MaybeArgs) -->
 	process_non_event_goals_2(Goal, neg_cont(Cont), MaybeArgs).
-process_non_event_goals_2(some_rep(Goal), Cont, MaybeArgs) -->
+process_non_event_goals_2(some_rep(Goal, _), Cont, MaybeArgs) -->
 	process_non_event_goals_2(Goal, Cont, MaybeArgs).
 process_non_event_goals_2(Goal, Cont, MaybeArgs) -->
 	{ Goal = atomic_goal_rep(_, _, _, _, AtomicGoal) },
Index: browser/declarative_execution.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/declarative_execution.m,v
retrieving revision 1.15
diff -u -b -r1.15 declarative_execution.m
--- browser/declarative_execution.m	2001/01/16 15:44:17	1.15
+++ browser/declarative_execution.m	2002/04/03 03:24:39
@@ -35,7 +35,7 @@
 			sequence_number,	% Call sequence number.
 			event_number,		% Trace event number.
 			bool,			% At the maximum depth?
-			maybe(goal_rep)		% Body of the called procedure.
+			maybe(proc_rep)		% Body of the called procedure.
 		)
 	;	exit(
 			R,			% Preceding event.
@@ -728,15 +728,15 @@
 	null_trace_node_id(Answer).
 
 :- func construct_call_node_with_goal(trace_node_id, trace_atom,
-		sequence_number, event_number, bool, goal_rep)
+		sequence_number, event_number, bool, proc_rep)
 		= trace_node(trace_node_id).
 :- pragma export(construct_call_node_with_goal(in, in, in, in, in, in) = out,
 		"MR_DD_construct_call_node_with_goal").
 
 construct_call_node_with_goal(Preceding, Atom, SeqNo, EventNo, MaxDepth,
-		GoalRep) = Call :-
+		ProcRep) = Call :-
 	Call = call(Preceding, Answer, Atom, SeqNo, EventNo, MaxDepth,
-			yes(GoalRep)),
+			yes(ProcRep)),
 	null_trace_node_id(Answer).
 
 
Index: browser/program_representation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/program_representation.m,v
retrieving revision 1.6
diff -u -b -r1.6 program_representation.m
--- browser/program_representation.m	2001/12/19 06:44:47	1.6
+++ browser/program_representation.m	2002/04/03 02:56:41
@@ -42,6 +42,12 @@
 	% Each element of this structure will correspond one-to-one
 	% to the original stage 90 HLDS.
 
+:- type proc_rep
+	--->	proc_rep(
+			list(var_rep),		% The head variables, in order.
+			goal_rep		% The procedure body.
+		).
+
 :- type goal_rep
 	--->	conj_rep(
 			list(goal_rep)		% The conjuncts in the original
@@ -64,7 +70,8 @@
 			goal_rep		% The negated goal.
 		)
 	;	some_rep(
-			goal_rep		% The quantified goal.
+			goal_rep,		% The quantified goal.
+			maybe_cut
 		)
 	;	atomic_goal_rep(
 			detism_rep,
@@ -150,6 +157,7 @@
                         ;       first
                         ;       later.
 
+	% Does a `some' goal change determinism?
 :- type maybe_cut       --->    cut ; no_cut.
 
 :- pred path_step_from_string(string, goal_path_step).
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.101
diff -u -b -r1.101 code_gen.m
--- compiler/code_gen.m	2002/03/28 03:42:44	1.101
+++ compiler/code_gen.m	2002/04/03 03:05:13
@@ -341,12 +341,13 @@
 			no, EntryLabel),
 		proc_info_eval_method(ProcInfo, EvalMethod),
 		proc_info_get_initial_instmap(ProcInfo, ModuleInfo, InstMap0),
+		proc_info_headvars(ProcInfo, HeadVars),
 		proc_info_varset(ProcInfo, VarSet),
 		proc_info_vartypes(ProcInfo, VarTypes),
 		ProcLayout = proc_layout_info(RttiProcLabel, EntryLabel,
 			Detism, TotalSlots, MaybeSuccipSlot, EvalMethod,
-			MaybeTraceCallLabel, MaxTraceReg, Goal, InstMap0,
-			TraceSlotInfo, ForceProcId, VarSet, VarTypes,
+			MaybeTraceCallLabel, MaxTraceReg, HeadVars, Goal,
+			InstMap0, TraceSlotInfo, ForceProcId, VarSet, VarTypes,
 			InternalMap, MaybeTableIoDecl),
 		global_data_add_new_proc_layout(GlobalData0,
 			proc(PredId, ProcId), ProcLayout, GlobalData1)
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.41
diff -u -b -r1.41 continuation_info.m
--- compiler/continuation_info.m	2002/03/28 03:42:50	1.41
+++ compiler/continuation_info.m	2002/04/03 03:03:11
@@ -92,6 +92,8 @@
 					% rN register that can contain useful
 					% information during a call to MR_trace
 					% from within this procedure.
+			head_vars	:: list(prog_var),
+					% The head variables, in order.
 			proc_body	:: hlds_goal,
 					% The body of the procedure.
 			initial_instmap	:: instmap,
Index: compiler/prog_rep.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.11
diff -u -b -r1.11 prog_rep.m
--- compiler/prog_rep.m	2002/03/28 03:43:34	1.11
+++ compiler/prog_rep.m	2002/04/03 04:21:56
@@ -18,17 +18,19 @@
 
 :- interface.
 
+:- import_module parse_tree__prog_data.
 :- import_module hlds__hlds_pred, hlds__hlds_goal, hlds__hlds_module.
 :- import_module hlds__instmap.
 :- import_module mdb, mdb__program_representation.
+:- import_module list.
 
-:- pred prog_rep__represent_goal(hlds_goal::in, instmap::in, vartypes::in,
-	module_info::in, goal_rep::out) is det.
+:- pred prog_rep__represent_proc(list(prog_var)::in, hlds_goal::in,
+	instmap::in, vartypes::in, module_info::in, proc_rep::out) is det.
 
 :- implementation.
 
-:- import_module hlds__hlds_data, parse_tree__prog_data.
-:- import_module string, list, set, std_util, require, term.
+:- import_module hlds__hlds_data.
+:- import_module string, set, std_util, require, term.
 
 :- type prog_rep__info
 	--->	info(
@@ -36,6 +38,15 @@
 			module_info :: module_info
 		).
 
+:- pred prog_rep__represent_goal(hlds_goal::in, instmap::in, vartypes::in,
+	module_info::in, goal_rep::out) is det.
+
+prog_rep__represent_proc(HeadVars, Goal, InstMap0, VarTypes, ModuleInfo,
+		proc_rep(HeadVarsRep, GoalRep)) :-
+	list__map(term__var_to_int, HeadVars, HeadVarsRep),
+	prog_rep__represent_goal(Goal, InstMap0, info(VarTypes, ModuleInfo),
+		GoalRep).
+
 prog_rep__represent_goal(Goal, InstMap0, VarTypes, ModuleInfo, Rep) :-
 	prog_rep__represent_goal(Goal, InstMap0, info(VarTypes, ModuleInfo),
 		Rep).
@@ -171,10 +182,18 @@
 		InstMap0, Info, Rep) :-
 	prog_rep__represent_cases(Cases, InstMap0, Info, CaseReps),
 	Rep = switch_rep(CaseReps).
-prog_rep__represent_goal_expr(some(_, _, Goal), _, InstMap0, Info, Rep)
+prog_rep__represent_goal_expr(some(_, _, Goal), GoalInfo, InstMap0, Info, Rep)
 		:-
 	prog_rep__represent_goal(Goal, InstMap0, Info, InnerRep),
-	Rep = some_rep(InnerRep).
+	Goal = _ - InnerGoalInfo,
+	goal_info_get_determinism(GoalInfo, OuterDetism),
+	goal_info_get_determinism(InnerGoalInfo, InnerDetism),
+	( InnerDetism = OuterDetism ->
+		MaybeCut = no_cut
+	;
+		MaybeCut = cut
+	),
+	Rep = some_rep(InnerRep, MaybeCut).
 prog_rep__represent_goal_expr(generic_call(GenericCall, Args, _, _),
 		GoalInfo, InstMap0, Info, Rep) :-
 	list__map(term__var_to_int, Args, ArgsRep),
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.65
diff -u -b -r1.65 stack_layout.m
--- compiler/stack_layout.m	2002/04/03 06:15:11	1.65
+++ compiler/stack_layout.m	2002/04/03 07:19:18
@@ -249,7 +249,7 @@
 stack_layout__construct_layouts(ProcLayoutInfo) -->
 	{ ProcLayoutInfo = proc_layout_info(RttiProcLabel, EntryLabel, Detism,
 		StackSlots, SuccipLoc, EvalMethod, MaybeCallLabel, MaxTraceReg,
-		Goal, InstMap, TraceSlotInfo, ForceProcIdLayout,
+		HeadVars, Goal, InstMap, TraceSlotInfo, ForceProcIdLayout,
 		VarSet, VarTypes, InternalMap, MaybeTableIoDecl) },
 	{ map__to_assoc_list(InternalMap, Internals) },
 	stack_layout__set_cur_proc_named_vars(map__init),
@@ -286,8 +286,9 @@
 	stack_layout__set_label_tables(LabelTables),
 	stack_layout__construct_proc_layout(RttiProcLabel, EntryLabel,
 		ProcLabel, Detism, StackSlots, SuccipLoc, EvalMethod,
-		MaybeCallLabel, MaxTraceReg, Goal, InstMap, TraceSlotInfo,
-		VarSet, VarTypes, NamedVars, MaybeTableIoDecl, Kind).
+		MaybeCallLabel, MaxTraceReg, HeadVars, Goal, InstMap,
+		TraceSlotInfo, VarSet, VarTypes, NamedVars, MaybeTableIoDecl,
+		Kind).
 
 %---------------------------------------------------------------------------%
 
@@ -386,16 +387,16 @@
 
 :- pred stack_layout__construct_proc_layout(rtti_proc_label::in, label::in,
 	proc_label::in, determinism::in, int::in, maybe(int)::in,
-	eval_method::in, maybe(label)::in, int::in, hlds_goal::in, instmap::in,
-	trace_slot_info::in, prog_varset::in, vartypes::in,
-	map(int, string)::in, maybe(table_io_decl_info)::in,
+	eval_method::in, maybe(label)::in, int::in, list(prog_var)::in,
+	hlds_goal::in, instmap::in, trace_slot_info::in, prog_varset::in,
+	vartypes::in, map(int, string)::in, maybe(table_io_decl_info)::in,
 	proc_layout_kind::in, stack_layout_info::in, stack_layout_info::out)
 	is det.
 
 stack_layout__construct_proc_layout(RttiProcLabel, EntryLabel, ProcLabel,
 		Detism, StackSlots, MaybeSuccipLoc, EvalMethod, MaybeCallLabel,
-		MaxTraceReg, Goal, InstMap, TraceSlotInfo, VarSet, VarTypes,
-		UsedVarNames, MaybeTableIoDeclInfo, Kind) -->
+		MaxTraceReg, HeadVars, Goal, InstMap, TraceSlotInfo, VarSet,
+		VarTypes, UsedVarNames, MaybeTableIoDeclInfo, Kind) -->
 	{
 		MaybeSuccipLoc = yes(Location)
 	->
@@ -453,7 +454,7 @@
 	;
 		{ Kind = proc_layout_exec_trace(_) },
 		stack_layout__construct_trace_layout(RttiProcLabel, EvalMethod,
-			MaybeCallLabel, MaxTraceReg, Goal, InstMap,
+			MaybeCallLabel, MaxTraceReg, HeadVars, Goal, InstMap,
 			TraceSlotInfo, VarSet, VarTypes, UsedVarNames,
 			MaybeTableIoDeclInfo, ExecTrace),
 		{ MaybeRest = proc_id_and_exec_trace(ExecTrace) }
@@ -474,15 +475,15 @@
 	).
 
 :- pred stack_layout__construct_trace_layout(rtti_proc_label::in,
-	eval_method::in, maybe(label)::in, int::in, hlds_goal::in,
-	instmap::in, trace_slot_info::in, prog_varset::in, vartypes::in,
-	map(int, string)::in, maybe(table_io_decl_info)::in,
+	eval_method::in, maybe(label)::in, int::in, list(prog_var)::in,
+	hlds_goal::in, instmap::in, trace_slot_info::in, prog_varset::in,
+	vartypes::in, map(int, string)::in, maybe(table_io_decl_info)::in,
 	proc_layout_exec_trace::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_trace_layout(RttiProcLabel, EvalMethod, MaybeCallLabel,
-		MaxTraceReg, Goal, InstMap, TraceSlotInfo, VarSet, VarTypes,
-		UsedVarNameMap, MaybeTableIoDecl, ExecTrace) -->
+		MaxTraceReg, HeadVars, Goal, InstMap, TraceSlotInfo, VarSet,
+		VarTypes, UsedVarNameMap, MaybeTableIoDecl, ExecTrace) -->
 	stack_layout__construct_var_name_vector(VarSet, UsedVarNameMap,
 		MaxVarNum, VarNameVector),
 	stack_layout__get_trace_level(TraceLevel),
@@ -494,7 +495,7 @@
 	;
 		{ BodyReps = yes },
 		stack_layout__get_module_info(ModuleInfo),
-		{ prog_rep__represent_goal(Goal, InstMap, VarTypes,
+		{ prog_rep__represent_proc(HeadVars, Goal, InstMap, VarTypes,
 			ModuleInfo, GoalRep) },
 		{ type_to_univ(GoalRep, GoalRepUniv) },
 		stack_layout__get_cell_counter(CellCounter0),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.57
diff -u -b -r1.57 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h	2002/04/03 07:08:19	1.57
+++ runtime/mercury_stack_layout.h	2002/04/03 07:19:22
@@ -525,7 +525,7 @@
 ** stored there, as well the table associating source-file contexts with labels.
 **
 ** The proc_rep field contains a representation of the body of the procedure
-** as a Mercury term of type goal_rep, defined in program_representation.m.
+** as a Mercury term of type proc_rep, defined in program_representation.m.
 ** Note that the type of this field is `MR_Word *', not `MR_Word',
 ** for the same reasons that MR_mkword() has type `MR_Word *' rather
 ** than `MR_Word' (see the comment in runtime/mercury_tags.h).
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
--------------------------------------------------------------------------
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