[m-dev.] for review: fixes to the generation of RTTI

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 16 10:34:00 AEST 1999


For review by Tyson.

Fix an old problem reported by Erwan about six months ago: in some cases,
the debugger listed a variable twice at one stop. The reason was that
we can record information about a variable either at a debugging port
or at a call's return site, and some points in the program are both.
The techniques we use to record the variable's details are necessarily
different (the return sites inspection is done after llds optimization),
and associate different insts with the variable. These differences
are irrelevant for RTTI, but they were confusing the code that was
designed to remove any such duplication.

Also fix another old problem: the appearance of "variable names"
such as V_11 in the lists of variables in the debugger. Such
variables should not appear in the debugger's output.

Both of these changes reduce the size of executables built with debugging.

compiler/llds.m:
	Do not use the type inst in the type live_value_type to record
	the instantiation state of a variabe, since the inst contains
	details such as exact functor bindings and uniqueness that RTTI
	is not interested in. RTTI wants to ignore differences in such
	areas, but this is not really possible while using type inst.
	We therefore introduce a new type llds_inst.

compiler/trace.m:
compiler/continuation_info.m:
	Compute llds_insts from insts before creating live_value_type
	structures. This requires access to a module_info to help interpret
	insts.

	In trace.m, do not invent names for live variables if they don't
	already have one.

compiler/code_info.m:
	Supply the module_info argument now needed by the modified predicates
	in continuation_info.

compiler/llds_out.m:
	Update the code for writing out live_value_types.

tests/debugger/quens.exp:
	Update the expected output of this debugger test case, since it
	no longer contains variables such as V_11.

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_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.239
diff -u -b -r1.239 code_info.m
--- code_info.m	1999/04/30 08:23:44	1.239
+++ code_info.m	1999/08/15 07:29:59
@@ -3244,9 +3244,10 @@
 	code_info__get_active_temps_data(Temps),
 	code_info__get_proc_info(ProcInfo),
 	code_info__get_globals(Globals),
+	code_info__get_module_info(ModuleInfo),
 	{ continuation_info__generate_return_live_lvalues(OutputArgLocs,
-		ReturnInstMap, Vars, VarLocs, Temps, ProcInfo, Globals,
-		LiveLvalues) }.
+		ReturnInstMap, Vars, VarLocs, Temps, ProcInfo, ModuleInfo,
+		Globals, LiveLvalues) }.
 
 :- pred code_info__generate_resume_layout(label::in, resume_map::in,
 	code_info::in, code_info::out) is det.
@@ -3259,8 +3260,9 @@
 		code_info__get_active_temps_data(Temps),
 		code_info__get_instmap(InstMap),
 		code_info__get_proc_info(ProcInfo),
+		code_info__get_module_info(ModuleInfo),
 		{ continuation_info__generate_resume_layout(ResumeMap,
-			Temps, InstMap, ProcInfo, Layout) },
+			Temps, InstMap, ProcInfo, ModuleInfo, Layout) },
 		code_info__add_gc_layout_for_label(Label, Layout)
 	;
 		[]
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.25
diff -u -b -r1.25 continuation_info.m
--- continuation_info.m	1999/08/13 01:42:57	1.25
+++ continuation_info.m	1999/08/15 07:48:57
@@ -226,13 +226,14 @@
 :- pred continuation_info__generate_return_live_lvalues(
 	assoc_list(prog_var, arg_loc)::in, instmap::in, list(prog_var)::in,
 	map(prog_var, set(rval))::in, assoc_list(lval, slot_contents)::in,
-	proc_info::in, globals::in, list(liveinfo)::out) is det.
+	proc_info::in, module_info::in, globals::in, list(liveinfo)::out)
+	is det.
 
 	% Generate the layout information we need for a resumption point,
 	% a label where forward execution can restart after backtracking.
 :- pred continuation_info__generate_resume_layout(map(prog_var, set(rval))::in,
 	assoc_list(lval, slot_contents)::in, instmap::in, proc_info::in,
-	layout_label_info::out) is det.
+	module_info::in, layout_label_info::out) is det.
 
 	% Generate the layout information we need to include in a closure.
 :- pred continuation_info__generate_closure_layout(module_info::in,
@@ -249,7 +250,7 @@
 
 :- implementation.
 
-:- import_module hlds_goal, code_util, type_util, options.
+:- import_module hlds_goal, code_util, type_util, inst_match, options.
 :- import_module string, require, varset, term.
 
 %-----------------------------------------------------------------------------%
@@ -416,13 +417,15 @@
 %-----------------------------------------------------------------------------%
 
 continuation_info__generate_return_live_lvalues(OutputArgLocs, ReturnInstMap,
-		Vars, VarLocs, Temps, ProcInfo, Globals, LiveLvalues) :-
+		Vars, VarLocs, Temps, ProcInfo, ModuleInfo, Globals,
+		LiveLvalues) :-
 	globals__want_return_var_layouts(Globals, WantReturnVarLayout),
 	proc_info_stack_slots(ProcInfo, StackSlots),
 	continuation_info__find_return_var_lvals(Vars, StackSlots,
 		OutputArgLocs, VarLvals),
 	continuation_info__generate_var_live_lvalues(VarLvals, ReturnInstMap,
-		VarLocs, ProcInfo, WantReturnVarLayout, VarLiveLvalues),
+		VarLocs, ProcInfo, ModuleInfo,
+		WantReturnVarLayout, VarLiveLvalues),
 	continuation_info__generate_temp_live_lvalues(Temps, TempLiveLvalues),
 	list__append(VarLiveLvalues, TempLiveLvalues, LiveLvalues).
 
@@ -456,15 +459,16 @@
 
 :- pred continuation_info__generate_var_live_lvalues(
 	assoc_list(prog_var, lval)::in, instmap::in,
-	map(prog_var, set(rval))::in, proc_info::in,
+	map(prog_var, set(rval))::in, proc_info::in, module_info::in,
 	bool::in, list(liveinfo)::out) is det.
 
-continuation_info__generate_var_live_lvalues([], _, _, _, _, []).
+continuation_info__generate_var_live_lvalues([], _, _, _, _, _, []).
 continuation_info__generate_var_live_lvalues([Var - Lval | VarLvals], InstMap,
-		VarLocs, ProcInfo, WantReturnVarLayout, [Live | Lives]) :-
+		VarLocs, ProcInfo, ModuleInfo, WantReturnVarLayout,
+		[Live | Lives]) :-
 	( WantReturnVarLayout = yes ->
 		continuation_info__generate_layout_for_var(Var, InstMap,
-			ProcInfo, LiveValueType, TypeVars),
+			ProcInfo, ModuleInfo, LiveValueType, TypeVars),
 		continuation_info__find_typeinfos_for_tvars(TypeVars,
 			VarLocs, ProcInfo, TypeParams),
 		Live = live_lvalue(direct(Lval), LiveValueType, TypeParams)
@@ -473,16 +477,16 @@
 		Live = live_lvalue(direct(Lval), unwanted, Empty)
 	),
 	continuation_info__generate_var_live_lvalues(VarLvals, InstMap,
-		VarLocs, ProcInfo, WantReturnVarLayout, Lives).
+		VarLocs, ProcInfo, ModuleInfo, WantReturnVarLayout, Lives).
 
 %---------------------------------------------------------------------------%
 
 continuation_info__generate_resume_layout(ResumeMap, Temps, InstMap,
-		ProcInfo, Layout) :-
+		ProcInfo, ModuleInfo, Layout) :-
 	map__to_assoc_list(ResumeMap, ResumeList),
 	set__init(TVars0),
 	continuation_info__generate_resume_layout_for_vars(ResumeList,
-		InstMap, ProcInfo, VarInfos, TVars0, TVars),
+		InstMap, ProcInfo, ModuleInfo, VarInfos, TVars0, TVars),
 	set__list_to_set(VarInfos, VarInfoSet),
 	set__to_sorted_list(TVars, TVarList),
 	continuation_info__find_typeinfos_for_tvars(TVarList, ResumeMap,
@@ -494,23 +498,26 @@
 
 :- pred continuation_info__generate_resume_layout_for_vars(
 	assoc_list(prog_var, set(rval))::in, instmap::in, proc_info::in,
-	list(var_info)::out, set(tvar)::in, set(tvar)::out) is det.
+	module_info::in, list(var_info)::out, set(tvar)::in,
+	set(tvar)::out) is det.
 
-continuation_info__generate_resume_layout_for_vars([], _, _, [], TVars, TVars).
+continuation_info__generate_resume_layout_for_vars([], _, _, _, [],
+		TVars, TVars).
 continuation_info__generate_resume_layout_for_vars([Var - RvalSet | VarRvals],
-		InstMap, ProcInfo, [VarInfo | VarInfos], TVars0, TVars) :-
+		InstMap, ProcInfo, ModuleInfo, [VarInfo | VarInfos],
+		TVars0, TVars) :-
 	continuation_info__generate_resume_layout_for_var(Var, RvalSet,
-		InstMap, ProcInfo, VarInfo, TypeVars),
+		InstMap, ProcInfo, ModuleInfo, VarInfo, TypeVars),
 	set__insert_list(TVars0, TypeVars, TVars1),
 	continuation_info__generate_resume_layout_for_vars(VarRvals,
-		InstMap, ProcInfo, VarInfos, TVars1, TVars).
+		InstMap, ProcInfo, ModuleInfo, VarInfos, TVars1, TVars).
 
 :- pred continuation_info__generate_resume_layout_for_var(prog_var::in,
-	set(rval)::in, instmap::in, proc_info::in,
+	set(rval)::in, instmap::in, proc_info::in, module_info::in,
 	var_info::out, list(tvar)::out) is det.
 
 continuation_info__generate_resume_layout_for_var(Var, RvalSet, InstMap,
-		ProcInfo, VarInfo, TypeVars) :-
+		ProcInfo, ModuleInfo, VarInfo, TypeVars) :-
 	set__to_sorted_list(RvalSet, RvalList),
 	( RvalList = [RvalPrime] ->
 		Rval = RvalPrime
@@ -523,7 +530,7 @@
 		error("var rval is not lval in stack resume map")
 	),
 	continuation_info__generate_layout_for_var(Var, InstMap, ProcInfo,
-		LiveValueType, TypeVars),
+		ModuleInfo, LiveValueType, TypeVars),
 	VarInfo = var_info(direct(Lval), LiveValueType).
 
 :- pred continuation_info__generate_temp_var_infos(
@@ -539,9 +546,10 @@
 %---------------------------------------------------------------------------%
 
 :- pred continuation_info__generate_layout_for_var(prog_var::in, instmap::in,
-	proc_info::in, live_value_type::out, list(tvar)::out) is det.
+	proc_info::in, module_info::in, live_value_type::out, list(tvar)::out)
+	is det.
 
-continuation_info__generate_layout_for_var(Var, InstMap, ProcInfo,
+continuation_info__generate_layout_for_var(Var, InstMap, ProcInfo, ModuleInfo,
 		LiveValueType, TypeVars) :-
 	proc_info_varset(ProcInfo, VarSet),
 	proc_info_vartypes(ProcInfo, VarTypes),
@@ -552,7 +560,12 @@
 	),
 	instmap__lookup_var(InstMap, Var, Inst),
 	map__lookup(VarTypes, Var, Type),
-	LiveValueType = var(Var, Name, Type, Inst),
+	( inst_match__inst_is_ground(ModuleInfo, Inst) ->
+		LldsInst = ground
+	;
+		LldsInst = partial(Inst)
+	),
+	LiveValueType = var(Var, Name, Type, LldsInst),
 	type_util__vars(Type, TypeVars).
 
 %---------------------------------------------------------------------------%
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.245
diff -u -b -r1.245 llds.m
--- llds.m	1999/08/12 09:58:39	1.245
+++ llds.m	1999/08/15 06:50:43
@@ -548,7 +548,7 @@
 	;	redoip				% A stored redoip.
 	;	redofr				% A stored redofr.
 	;	hp				% A stored heap pointer.
-	;	var(prog_var, string, type, inst)
+	;	var(prog_var, string, type, llds_inst)
 						% A variable (the var number
 						% and name are for execution
 						% tracing; we have to store
@@ -559,6 +559,23 @@
 	;	unwanted.			% Something we don't need,
 						% or at least don't need
 						% information about.
+
+	% For recording information about the inst of a variable for use
+	% by the garbage collector or the debugger, we don't need to know
+	% what functors its parts are bound to, or which parts of it are
+	% unique; we just need to know which parts of it are bound.
+	% If we used the HLDS type inst to represent the instantiatedness
+	% in the LLDS, we would find that insts that the LLDS wants to treat
+	% as the same would compare as different. The live_value_types and
+	% var_infos containing them would compare as different as well,
+	% which can lead to a variable being listed more than once in
+	% a label's list of live variable.
+	%
+	% At the moment, the LLDS only handles ground insts. When this changes,
+	% the argument type of partial will have to be changed.
+:- type llds_inst
+	--->	ground
+	;	partial((inst)).
 
 	% An lval represents a data location or register that can be used
 	% as the target of an assignment.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.117
diff -u -b -r1.117 llds_out.m
--- llds_out.m	1999/08/12 09:58:41	1.117
+++ llds_out.m	1999/08/15 07:30:59
@@ -1840,7 +1840,7 @@
 output_live_value_type(redoip) --> io__write_string("MR_redoip").
 output_live_value_type(hp) --> io__write_string("MR_hp").
 output_live_value_type(unwanted) --> io__write_string("unwanted").
-output_live_value_type(var(Var, Name, Type, Inst)) --> 
+output_live_value_type(var(Var, Name, Type, LldsInst)) --> 
 	io__write_string("var("),
 	{ term__var_to_int(Var, VarInt) },
 	io__write_int(VarInt),
@@ -1851,9 +1851,15 @@
 	{ varset__init(NewTVarset) },
 	mercury_output_term(Type, NewTVarset, no),
 	io__write_string(", "),
+	(
+		{ LldsInst = ground },
+		io__write_string("ground")
+	;
+		{ LldsInst = partial(Inst) },
 		% XXX Fake inst varset
 	{ varset__init(NewIVarset) },
-	mercury_output_inst(Inst, NewIVarset),
+		mercury_output_inst(Inst, NewIVarset)
+	),
 	io__write_string(")").
 
 :- pred output_temp_decls(int, string, io__state, io__state).
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.20
diff -u -b -r1.20 trace.m
--- trace.m	1999/04/30 08:23:55	1.20
+++ trace.m	1999/08/15 08:02:57
@@ -564,6 +564,7 @@
 		[VarInfo | VarInfos], tree(VarCode, VarsCode)) -->
 	code_info__produce_variable_in_reg_or_stack(Var, VarCode, Rval),
 	code_info__variable_type(Var, Type),
+	code_info__get_module_info(ModuleInfo),
 	{
 	( Rval = lval(LvalPrime) ->
 		Lval = LvalPrime
@@ -574,9 +575,18 @@
 		% The code that interprets layout information must know this.
 		% Lval = reg(r, 0)
 	),
-	varset__lookup_name(VarSet, Var, "V_", Name),
+	( varset__search_name(VarSet, Var, SearchName) ->
+		Name = SearchName
+	;
+		Name = ""
+	),
 	instmap__lookup_var(InstMap, Var, Inst),
-	LiveType = var(Var, Name, Type, Inst),
+	( inst_match__inst_is_ground(ModuleInfo, Inst) ->
+		LldsInst = ground
+	;
+		LldsInst = partial(Inst)
+	),
+	LiveType = var(Var, Name, Type, LldsInst),
 	VarInfo = var_info(direct(Lval), LiveType),
 	type_util__vars(Type, TypeVars),
 	set__insert_list(Tvars0, TypeVars, Tvars1)
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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/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 profiler
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 scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/queens.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp,v
retrieving revision 1.13
diff -u -b -r1.13 queens.exp
--- queens.exp	1999/06/30 17:13:29	1.13
+++ queens.exp	1999/08/15 08:07:16
@@ -31,8 +31,6 @@
        8:      5  4 DISJ pred queens:qdelete/3-0 (nondet) c2;d1;
 mdb> print *
        HeadVar__2             	[1, 2, 3, 4, 5]
-       V_11                   	[2, 3, 4, 5]
-       V_12                   	1
 mdb> level 1
    1       5       4    3 pred queens:qperm/2-0 (nondet) 
 Ancestor level set to 1.
@@ -69,8 +67,6 @@
       13:      7  5 DISJ pred queens:qdelete/3-0 (nondet) c2;d1;
 mdb> print *
        HeadVar__2             	[2, 3, 4, 5]
-       V_11                   	[3, 4, 5]
-       V_12                   	2
 mdb> 
       14:      7  5 EXIT pred queens:qdelete/3-0 (nondet) 
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/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