[m-rev.] diff/for post-commit review: no stack slots for dummy types

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Sep 2 14:30:35 AEST 2004


Optimize away stack slots storing dummy values; values of the io__state and
store__store types.

compiler/stack_alloc.m:
	Allocate distinct negative stack slot numbers to values of dummy types.
	We need

compiler/hlds_pred.m:
	Add a predicate for testing whether a value is of a dummy type.

compiler/code_into.m:
	When constructing the list of live locations after a call, do not
	include the negative stack slots containing dummy values. The list
	of live locations is used by the (future) native collector, which
	should ignore dummy types, and by the debugger. The debugger can't
	do anything with these dummy values on the stack except tell the
	user about their existence, which doesn't do the debugger user any
	good.

	We still keep liveness information about dummy values in registers
	at calls and returns, since both the procedural and declarative
	debuggers need to know procedures' full argument lists.

	With respect to the list of live locations before the call, which
	was used only by the (now extinct) value numbering optimization,
	filter out all dummy types, since their values need not be preserved.

compiler/trace.m:
	Do not ask the code generator to preserve values of dummy types,
	since doing so would require referring to negative stack slots.

compiler/unify_gen.m:
compiler/var_locn.m:
	Fix a couple of situations in which we could refer to the negative
	stack slots we now allocate to dummy values.

compiler/call_gen.m:
	Reorder some code to make the source match what happens at runtime.

compiler/llds_out.m:
	Fix the formatting of the sanity check for negative stack slots.

compiler/handle_options.m:
	Since the --debug-opt-pred-id option is useless without --debug-opt,
	make --debug-opt-pred-id option imply --debug-opt. This was useful
	in debugging this diff.

trace/mercury_trace.c:
	Adapt the test for whether a retry is across I/O. We used to base the
	test on whether the retried predicate has any I/O state arguments,
	and if so, whether the original I/O state variable is still around
	on the stack. After this change, the answer to the second half of
	that question would always be "no", so we now use only the first half:
	whether the retried predicate has any I/O state arguments. This
	requires us to consider more retries to be retries across I/O, but
	from the point of view of a user who may not remember whether the I/O
	predicate has done any I/O so far or not, is arguably more consistent
	than our previous policy.

	Allow retries even if a value of type store.store is missing, since
	store.store is a dummy type just as io.state is.

trace/mercury_trace.c:
compiler/type_util.m:
	Document the fact that you need to update both these files if you
	want to modify the set of dummy types.

tests/debugger/retry.{inp,exp,exp2}:
	Due to the change in mercury_trace.c, one retry in this test case
	changes to being retry over I/O. Update the test input to force this
	retry over I/O, and expect the expanded input to be echoed in the
	output.

tests/debugger/nondet_stack.{exp,exp2}:
	Update these expected outputs to account for the fact that we now need
	fewer stack slots to hold old I/O states when debugging is enabled.

Zoltan.

cvs server: Diffing .
cvs server: Diffing analysis
cvs server: Diffing bindist
cvs server: Diffing boehm_gc
cvs server: Diffing boehm_gc/Mac_files
cvs server: Diffing boehm_gc/cord
cvs server: Diffing boehm_gc/cord/private
cvs server: Diffing boehm_gc/doc
cvs server: Diffing boehm_gc/include
cvs server: Diffing boehm_gc/include/private
cvs server: Diffing boehm_gc/tests
cvs server: Diffing browser
cvs server: Diffing bytecode
cvs server: Diffing compiler
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.160
diff -u -b -r1.160 call_gen.m
--- compiler/call_gen.m	14 Jun 2004 04:15:57 -0000	1.160
+++ compiler/call_gen.m	2 Sep 2004 04:09:32 -0000
@@ -211,15 +211,6 @@
 	code_info__get_next_label(ReturnLabel, !CI),
 	goal_info_get_context(GoalInfo, Context),
 	goal_info_get_goal_path(GoalInfo, GoalPath),
-	CallCode = node([
-		livevals(LiveVals)
-			- "",
-		call(CodeAddr, label(ReturnLabel), ReturnLiveLvalues,
-			Context, GoalPath, CallModel)
-			- "Setup and call",
-		label(ReturnLabel)
-			- "Continuation label"
-	]),
 
 		% Figure out what variables will be live at the return point,
 		% and where, for use in the accurate garbage collector, and
@@ -232,6 +223,16 @@
 		% after the call.
 	call_gen__handle_return(OutArgsInfos, GoalInfo, NonLiveOutputs,
 		ReturnInstMap, ReturnLiveLvalues, !CI),
+
+	CallCode = node([
+		livevals(LiveVals)
+			- "",
+		call(CodeAddr, label(ReturnLabel), ReturnLiveLvalues,
+			Context, GoalPath, CallModel)
+			- "Setup and call",
+		label(ReturnLabel)
+			- "Continuation label"
+	]),
 
 		% If the call can fail, generate code to check for and
 		% handle the failure.
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.292
diff -u -b -r1.292 code_info.m
--- compiler/code_info.m	30 Aug 2004 05:44:34 -0000	1.292
+++ compiler/code_info.m	2 Sep 2004 04:09:32 -0000
@@ -3322,7 +3322,8 @@
 		Detism = erroneous,
 		OptNoReturnCalls = yes
 	->
-		StackVarLocs = []
+		RealStackVarLocs = [],
+		DummyStackVarLocs = []
 	;
 		code_info__compute_forward_live_var_saves(!.CI, OutVarSet,
 			ForwardVarLocs),
@@ -3344,18 +3345,40 @@
 				StackVarLocs)
 		;
 			StackVarLocs = ForwardVarLocs
-		)
 	),
-
+		VarTypes = code_info__get_var_types(!.CI),
+		list__filter(valid_stack_slot(VarTypes),
+			StackVarLocs, RealStackVarLocs, DummyStackVarLocs)
+	),
 	code_info__get_var_locn_info(!.CI, VarLocnInfo0),
 	code_info__var_arg_info_to_lval(InArgInfos, InArgLocs),
-	list__append(StackVarLocs, InArgLocs, AllLocs),
-	var_locn__place_vars(AllLocs, Code,
+	list__append(RealStackVarLocs, InArgLocs, AllRealLocs),
+	var_locn__place_vars(DummyStackVarLocs ++ AllRealLocs, Code,
 		VarLocnInfo0, VarLocnInfo),
 	code_info__set_var_locn_info(VarLocnInfo, !CI),
-	assoc_list__values(AllLocs, LiveLocList),
+	assoc_list__values(AllRealLocs, LiveLocList),
 	set__list_to_set(LiveLocList, LiveLocs).
 
+:- pred valid_stack_slot(vartypes::in, pair(prog_var, lval)::in) is semidet.
+
+valid_stack_slot(VarTypes, Var - Lval) :-
+	map__lookup(VarTypes, Var, Type),
+	( is_dummy_argument_type(Type) ->
+		fail
+	;
+		(
+			( Lval = stackvar(N)
+			; Lval = framevar(N)
+			),
+			N < 0
+		->
+			error("valid_stack_slot: nondummy var " ++
+				"in dummy stack slot")
+		;
+			true
+		)
+	).
+
 :- pred code_info__setup_call_args(assoc_list(prog_var, arg_info)::in,
 	call_direction::in, set(lval)::out, code_tree::out,
 	code_info::in, code_info::out) is det.
@@ -3498,7 +3521,10 @@
 	set(prog_var)::in, set(lval)::out) is det.
 
 code_info__generate_call_stack_vn_livevals(CI, OutputArgs, LiveVals) :-
-	code_info__get_known_variables(CI, KnownVarList),
+	code_info__get_known_variables(CI, KnownVarList0),
+	VarTypes = code_info__get_var_types(CI),
+	list__filter(var_is_of_dummy_type(VarTypes), KnownVarList0,
+		_, KnownVarList),
 	set__list_to_set(KnownVarList, KnownVars),
 	set__difference(KnownVars, OutputArgs, LiveVars),
 	set__to_sorted_list(LiveVars, LiveVarList),
@@ -3538,7 +3564,9 @@
 code_info__generate_return_live_lvalues(CI, OutputArgLocs, ReturnInstMap,
 		OkToDeleteAny, LiveLvalues) :-
 	code_info__variable_locations(CI, VarLocs),
-	code_info__get_known_variables(CI, Vars),
+	code_info__get_known_variables(CI, Vars0),
+	VarTypes = code_info__get_var_types(CI),
+	list__filter(var_is_of_dummy_type(VarTypes), Vars0, _, Vars),
 	code_info__get_active_temps_data(CI, Temps),
 	code_info__get_proc_info(CI, ProcInfo),
 	code_info__get_globals(CI, Globals),
@@ -3552,8 +3580,7 @@
 
 code_info__generate_resume_layout(Label, ResumeMap, !CI) :-
 	code_info__get_globals(!.CI, Globals),
-	globals__lookup_bool_option(Globals, agc_stack_layout,
-		AgcStackLayout),
+	globals__lookup_bool_option(Globals, agc_stack_layout, AgcStackLayout),
 	( AgcStackLayout = yes ->
 		code_info__get_active_temps_data(!.CI, Temps),
 		code_info__get_instmap(!.CI, InstMap),
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.209
diff -u -b -r1.209 handle_options.m
--- compiler/handle_options.m	16 Aug 2004 08:51:07 -0000	1.209
+++ compiler/handle_options.m	2 Sep 2004 04:09:32 -0000
@@ -699,6 +699,13 @@
 		[]
 	),
 
+	globals__io_lookup_int_option(debug_opt_pred_id, DebugOptPredId),
+	( { DebugOptPredId > 0 } ->
+		globals__io_set_option(debug_opt, bool(yes))
+	;
+		[]
+	),
+
 	globals__io_lookup_int_option(dump_hlds_pred_id, DumpHLDSPredId),
 	( { DumpHLDSPredId >= 0 } ->
 		globals__io_lookup_string_option(dump_hlds_options,
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.150
diff -u -b -r1.150 hlds_pred.m
--- compiler/hlds_pred.m	20 Jul 2004 04:41:00 -0000	1.150
+++ compiler/hlds_pred.m	2 Sep 2004 04:09:32 -0000
@@ -1992,6 +1992,9 @@
 	% becasue the debugger ignores unnamed variables.
 :- pred ensure_all_headvars_are_named(proc_info::in, proc_info::out) is det.
 
+	% Test whether the variable is of a dummy type, based on the vartypes.
+:- pred var_is_of_dummy_type(vartypes::in, prog_var::in) is semidet.
+
 :- implementation.
 :- import_module check_hlds__mode_errors.
 
@@ -2639,6 +2642,10 @@
 		varset__name_var(!.VarSet, Var, Name, !:VarSet)
 	),
 	ensure_all_headvars_are_named_2(Vars, SeqNum + 1, !VarSet).
+
+var_is_of_dummy_type(VarTypes, Var) :-
+	map__lookup(VarTypes, Var, Type),
+	is_dummy_argument_type(Type).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.238
diff -u -b -r1.238 llds_out.m
--- compiler/llds_out.m	30 Aug 2004 05:44:36 -0000	1.238
+++ compiler/llds_out.m	2 Sep 2004 04:09:32 -0000
@@ -4613,7 +4613,7 @@
 output_lval(reg(Type, Num)) -->
 	output_reg(Type, Num).
 output_lval(stackvar(N)) -->
-	{ (N < 0) ->
+	{ N =< 0 ->
 		error("stack var out of range")
 	;
 		true
@@ -4622,7 +4622,7 @@
 	io__write_int(N),
 	io__write_string(")").
 output_lval(framevar(N)) -->
-	{ (N =< 0) ->
+	{ N =< 0 ->
 		error("frame var out of range")
 	;
 		true
Index: compiler/stack_alloc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_alloc.m,v
retrieving revision 1.8
diff -u -b -r1.8 stack_alloc.m
--- compiler/stack_alloc.m	30 Jun 2004 02:48:14 -0000	1.8
+++ compiler/stack_alloc.m	2 Sep 2004 04:09:32 -0000
@@ -39,6 +39,7 @@
 :- implementation.
 
 :- import_module check_hlds__goal_path.
+:- import_module check_hlds__type_util.
 :- import_module hlds__code_model.
 :- import_module hlds__hlds_data.
 :- import_module hlds__hlds_goal.
@@ -91,18 +92,53 @@
 	(
 		MaybeReservedVarInfo = yes(ResVar - _),
 		set__singleton_set(ResVarSet, ResVar),
-		set__insert(LiveSets0, ResVarSet, LiveSets)
+		set__insert(LiveSets0, ResVarSet, LiveSets1)
 	;
 		MaybeReservedVarInfo = no,
-		LiveSets = LiveSets0
+		LiveSets1 = LiveSets0
 	),
+	proc_info_vartypes(!.ProcInfo, VarTypes),
+	filter_out_dummy_values(VarTypes, LiveSets1, LiveSets, DummyVars),
 	graph_colour__group_elements(LiveSets, ColourSets),
 	set__to_sorted_list(ColourSets, ColourList),
 	proc_info_interface_code_model(!.ProcInfo, CodeModel),
 	allocate_stack_slots(ColourList, CodeModel, NumReservedSlots,
-		MaybeReservedVarInfo, StackSlots),
+		MaybeReservedVarInfo, StackSlots1),
+	allocate_dummy_stack_slots(DummyVars, CodeModel, -1,
+		StackSlots1, StackSlots),
 	proc_info_set_stack_slots(StackSlots, !ProcInfo).
 
+:- pred filter_out_dummy_values(vartypes::in,
+	set(set(prog_var))::in, set(set(prog_var))::out,
+	list(prog_var)::out) is det.
+
+filter_out_dummy_values(VarTypes, LiveSet0, LiveSet, DummyVars) :-
+	set__to_sorted_list(LiveSet0, LiveList0),
+	filter_out_dummy_values_2(VarTypes, LiveList0, LiveList,
+		set__init, Dummies),
+	set__list_to_set(LiveList, LiveSet),
+	set__to_sorted_list(Dummies, DummyVars).
+
+:- pred filter_out_dummy_values_2(vartypes::in,
+	list(set(prog_var))::in, list(set(prog_var))::out,
+	set(prog_var)::in, set(prog_var)::out) is det.
+
+filter_out_dummy_values_2(_VarTypes, [], [], !Dummies).
+filter_out_dummy_values_2(VarTypes, [LiveSet0 | LiveSets0], LiveSets,
+		!Dummies) :-
+	filter_out_dummy_values_2(VarTypes, LiveSets0, LiveSets1, !Dummies),
+	set__to_sorted_list(LiveSet0, LiveList0),
+	list__filter(var_is_of_dummy_type(VarTypes), LiveList0,
+		DummyVars, NonDummyVars),
+	set__insert_list(!.Dummies, DummyVars, !:Dummies),
+	(
+		NonDummyVars = [],
+		LiveSets = LiveSets1
+	;
+		NonDummyVars = [_ | _],
+		LiveSets = [list_to_set(NonDummyVars) | LiveSets1]
+	).
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -203,5 +239,24 @@
 	),
 	map__det_insert(!.StackSlots, Var, Locn, !:StackSlots),
 	allocate_same_stack_slot(Vars, CodeModel, Slot, !StackSlots).
+
+% We must not allocate the same stack slot to dummy variables. If we do,
+% then the code that saves variables on the stack at calls will get confused.
+% After saving one dummy variable on the stack, it will try to save the next
+% in the same stack slot; believing the first variable to still be live, it
+% will move it away.
+%
+% In ordinary grades, it is possible to have one value of type io__state
+% and another of type store__store live at the same time; in debugging grades,
+% due to our policy of extending variable lifetimes, more than one io__state
+% may be live at the same time.
+
+:- pred allocate_dummy_stack_slots(list(prog_var)::in, code_model::in,
+	int::in, stack_slots::in, stack_slots::out) is det.
+
+allocate_dummy_stack_slots([], _, _, !StackSlots).
+allocate_dummy_stack_slots([Var | Vars], CodeModel, N0, !StackSlots) :-
+	allocate_same_stack_slot([Var], CodeModel, N0, !StackSlots),
+	allocate_dummy_stack_slots(Vars, CodeModel, N0 - 1, !StackSlots).
 
 %-----------------------------------------------------------------------------%
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.67
diff -u -b -r1.67 trace.m
--- compiler/trace.m	14 Jun 2004 04:16:40 -0000	1.67
+++ compiler/trace.m	2 Sep 2004 04:09:32 -0000
@@ -127,7 +127,7 @@
 	% except those that can be totally clobbered during the evaluation
 	% of the procedure (those partially clobbered may still be of interest,
 	% although to handle them properly we need to record insts in stack
-	% layouts).
+	% layouts), and those of dummy types.
 :- pred trace__fail_vars(module_info::in, proc_info::in,
 		set(prog_var)::out) is det.
 
@@ -247,10 +247,11 @@
 	proc_info_headvars(ProcInfo, HeadVars),
 	proc_info_argmodes(ProcInfo, Modes),
 	proc_info_arg_info(ProcInfo, ArgInfos),
+	proc_info_vartypes(ProcInfo, VarTypes),
 	mode_list_get_final_insts(Modes, ModuleInfo, Insts),
 	(
 		trace__build_fail_vars(HeadVars, Insts, ArgInfos,
-			ModuleInfo, FailVarsList)
+			ModuleInfo, VarTypes, FailVarsList)
 	->
 		set__list_to_set(FailVarsList, FailVars)
 	;
@@ -943,16 +944,20 @@
 %-----------------------------------------------------------------------------%
 
 :- pred trace__build_fail_vars(list(prog_var)::in, list(inst)::in,
-	list(arg_info)::in, module_info::in, list(prog_var)::out) is semidet.
+	list(arg_info)::in, module_info::in, vartypes::in,
+	list(prog_var)::out) is semidet.
 
-trace__build_fail_vars([], [], [], _, []).
+trace__build_fail_vars([], [], [], _, _, []).
 trace__build_fail_vars([Var | Vars], [Inst | Insts], [Info | Infos],
-		ModuleInfo, FailVars) :-
-	trace__build_fail_vars(Vars, Insts, Infos, ModuleInfo, FailVars0),
+		ModuleInfo, VarTypes, FailVars) :-
+	trace__build_fail_vars(Vars, Insts, Infos, ModuleInfo, VarTypes,
+		FailVars0),
 	Info = arg_info(_Loc, ArgMode),
 	(
 		ArgMode = top_in,
-		\+ inst_is_clobbered(ModuleInfo, Inst)
+		\+ inst_is_clobbered(ModuleInfo, Inst),
+		map__lookup(VarTypes, Var, Type),
+		\+ is_dummy_argument_type(Type)
 	->
 		FailVars = [Var | FailVars0]
 	;
Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.140
diff -u -b -r1.140 type_util.m
--- compiler/type_util.m	30 Aug 2004 05:44:38 -0000	1.140
+++ compiler/type_util.m	2 Sep 2004 04:09:32 -0000
@@ -854,6 +854,9 @@
 :- pred type_util__is_dummy_argument_type_2(string::in, string::in, arity::in)
 	is semidet.
 
+% The list of dummy types should be kept in sync with MR_is_dummy_type
+% in trace/mercury_trace.c.
+%
 % XXX should we include aditi:state/0 in this list?
 type_util__is_dummy_argument_type_2("io", "state", 0).    % io:state/0
 type_util__is_dummy_argument_type_2("store", "store", 1). % store:store/1.
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.143
diff -u -b -r1.143 unify_gen.m
--- compiler/unify_gen.m	14 Jun 2004 04:16:41 -0000	1.143
+++ compiler/unify_gen.m	2 Sep 2004 04:09:32 -0000
@@ -865,9 +865,30 @@
 	;
 		Tag = no_tag,
 		( Args = [Arg], Modes = [Mode] ->
-			Type = code_info__variable_type(!.CI, Arg),
-			unify_gen__generate_sub_unify(ref(Var), ref(Arg),
-				Mode, Type, Code, !CI)
+			VarType = code_info__variable_type(!.CI, Var),
+			( is_dummy_argument_type(VarType) ->
+				% We must handle this case specially. If we
+				% didn't, the generated code would copy the
+				% reference to the Var's current location,
+				% which may be stackvar(N) or framevar(N) for
+				% negative N, to be the location of Arg, and
+				% since Arg may not be a dummy type, it would
+				% actually use that location. This can happen
+				% in the unify/compare routines for e.g.
+				% io__state.
+
+				( variable_is_forward_live(!.CI, Arg) ->
+					code_info__assign_const_to_var(Arg,
+						const(int_const(0)), !CI)
+				;
+					true
+				),
+				Code = empty
+			;
+				ArgType = code_info__variable_type(!.CI, Arg),
+				unify_gen__generate_sub_unify(ref(Var),
+					ref(Arg), Mode, ArgType, Code, !CI)
+			)
 		;
 			error("unify_gen__generate_det_deconstruction: " ++
 				"no_tag: arity != 1")
@@ -1021,9 +1042,7 @@
 	code_info__produce_variable(Var, SourceCode, Source, !CI),
 	code_info__materialize_vars_in_rval(lval(Lval0), NewLval,
 		MaterializeCode, !CI),
-	(
-		NewLval = lval(Lval)
-	->
+	( NewLval = lval(Lval) ->
 		Code = tree(
 			tree(SourceCode, MaterializeCode),
 			node([
Index: compiler/var_locn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.20
diff -u -b -r1.20 var_locn.m
--- compiler/var_locn.m	30 Aug 2004 05:44:39 -0000	1.20
+++ compiler/var_locn.m	2 Sep 2004 04:09:32 -0000
@@ -1280,10 +1280,22 @@
 	;
 		get_spare_reg(!.VLI, Target),
 		record_copy(Lval, Target, !VLI),
+		(
+			( Lval = stackvar(N)
+			; Lval = framevar(N)
+			),
+			N < 0
+		->
+			% We must not copy from invalid lvals. The value we
+			% would copy is a dummy in any case, so Target won't
+			% be any more valid if we assigned Lval to it.
+			Code = empty
+		;
 		Code = node([
 			assign(Target, lval(Lval))
 				- "Freeing up the source lval"
 		])
+		)
 	).
 
 % Find a variable in the given list that is currently stored directly in Lval
cvs server: Diffing compiler/notes
cvs server: Diffing debian
cvs server: Diffing deep_profiler
cvs server: Diffing deep_profiler/notes
cvs server: Diffing doc
cvs server: Diffing extras
cvs server: Diffing extras/aditi
cvs server: Diffing extras/cgi
cvs server: Diffing extras/complex_numbers
cvs server: Diffing extras/complex_numbers/samples
cvs server: Diffing extras/complex_numbers/tests
cvs server: Diffing extras/concurrency
cvs server: Diffing extras/curs
cvs server: Diffing extras/curs/samples
cvs server: Diffing extras/curses
cvs server: Diffing extras/curses/sample
cvs server: Diffing extras/dynamic_linking
cvs server: Diffing extras/error
cvs server: Diffing extras/graphics
cvs server: Diffing extras/graphics/mercury_glut
cvs server: Diffing extras/graphics/mercury_opengl
cvs server: Diffing extras/graphics/mercury_tcltk
cvs server: Diffing extras/graphics/samples
cvs server: Diffing extras/graphics/samples/calc
cvs server: Diffing extras/graphics/samples/gears
cvs server: Diffing extras/graphics/samples/maze
cvs server: Diffing extras/graphics/samples/pent
cvs server: Diffing extras/lazy_evaluation
cvs server: Diffing extras/lex
cvs server: Diffing extras/lex/samples
cvs server: Diffing extras/lex/tests
cvs server: Diffing extras/logged_output
cvs server: Diffing extras/moose
cvs server: Diffing extras/moose/samples
cvs server: Diffing extras/moose/tests
cvs server: Diffing extras/morphine
cvs server: Diffing extras/morphine/non-regression-tests
cvs server: Diffing extras/morphine/scripts
cvs server: Diffing extras/morphine/source
cvs server: Diffing extras/odbc
cvs server: Diffing extras/posix
cvs server: Diffing extras/quickcheck
cvs server: Diffing extras/quickcheck/tutes
cvs server: Diffing extras/references
cvs server: Diffing extras/references/samples
cvs server: Diffing extras/references/tests
cvs server: Diffing extras/stream
cvs server: Diffing extras/trailed_update
cvs server: Diffing extras/trailed_update/samples
cvs server: Diffing extras/trailed_update/tests
cvs server: Diffing extras/xml
cvs server: Diffing extras/xml/samples
cvs server: Diffing java
cvs server: Diffing java/runtime
cvs server: Diffing library
cvs server: Diffing profiler
cvs server: Diffing robdd
cvs server: Diffing runtime
cvs server: Diffing runtime/GETOPT
cvs server: Diffing runtime/machdeps
cvs server: Diffing samples
cvs server: Diffing samples/c_interface
cvs server: Diffing samples/c_interface/c_calls_mercury
cvs server: Diffing samples/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/c_interface/mercury_calls_c
cvs server: Diffing samples/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/c_interface/mercury_calls_fortran
cvs server: Diffing samples/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/diff
cvs server: Diffing samples/muz
cvs server: Diffing samples/rot13
cvs server: Diffing samples/solutions
cvs server: Diffing samples/tests
cvs server: Diffing samples/tests/c_interface
cvs server: Diffing samples/tests/c_interface/c_calls_mercury
cvs server: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/tests/c_interface/mercury_calls_c
cvs server: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs server: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/tests/diff
cvs server: Diffing samples/tests/muz
cvs server: Diffing samples/tests/rot13
cvs server: Diffing samples/tests/solutions
cvs server: Diffing samples/tests/toplevel
cvs server: Diffing scripts
cvs server: Diffing tests
cvs server: Diffing tests/benchmarks
cvs server: Diffing tests/debugger
Index: tests/debugger/nondet_stack.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/nondet_stack.exp,v
retrieving revision 1.10
diff -u -b -r1.10 nondet_stack.exp
--- tests/debugger/nondet_stack.exp	10 Mar 2004 04:30:43 -0000	1.10
+++ tests/debugger/nondet_stack.exp	2 Sep 2004 04:09:32 -0000
@@ -81,14 +81,14 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  14
+sp = det  13
 curfr = non 135
 maxfr = non 135
 mdb> nondet_stack -d
@@ -183,7 +183,7 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
@@ -303,14 +303,14 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  21
+sp = det  20
 curfr = non  26
 maxfr = non 217
 mdb> nondet_stack -d
@@ -472,7 +472,7 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
@@ -491,7 +491,7 @@
 non 272: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non 268: temp
  redoip: label UNKNOWN
  redofr: non  26
@@ -630,14 +630,14 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  14
+sp = det  13
 curfr = non 284
 maxfr = non 284
 mdb> nondet_stack -d
@@ -651,7 +651,7 @@
 non 272: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non 268: temp
  redoip: label UNKNOWN
  redofr: non  26
@@ -851,7 +851,7 @@
 non  14: temp
  redoip: label UNKNOWN
  redofr: non  10
- detfr:  det  14
+ detfr:  det  13
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
Index: tests/debugger/nondet_stack.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/nondet_stack.exp2,v
retrieving revision 1.11
diff -u -b -r1.11 nondet_stack.exp2
--- tests/debugger/nondet_stack.exp2	10 Mar 2004 04:30:43 -0000	1.11
+++ tests/debugger/nondet_stack.exp2	2 Sep 2004 04:09:32 -0000
@@ -81,14 +81,14 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  22
+sp = det  21
 curfr = non 162
 maxfr = non 162
 mdb> nondet_stack -d
@@ -183,7 +183,7 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
@@ -303,14 +303,14 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  32
+sp = det  31
 curfr = non  29
 maxfr = non 258
 mdb> nondet_stack -d
@@ -472,7 +472,7 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
@@ -491,7 +491,7 @@
 non 325: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non 321: temp
  redoip: label UNKNOWN
  redofr: non  29
@@ -630,14 +630,14 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
  succip: label wrapper_not_reached
  succfr: non   4
 mdb> stack_regs
-sp = det  22
+sp = det  21
 curfr = non 341
 maxfr = non 341
 mdb> nondet_stack -d
@@ -651,7 +651,7 @@
 non 325: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non 321: temp
  redoip: label UNKNOWN
  redofr: non  29
@@ -851,7 +851,7 @@
 non  14: temp
  redoip: unnamed label
  redofr: non  10
- detfr:  det  22
+ detfr:  det  21
 non  10: ordinary, 6 words
  redoip: label global_fail
  redofr: non  10
Index: tests/debugger/retry.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.exp,v
retrieving revision 1.9
diff -u -b -r1.9 retry.exp
--- tests/debugger/retry.exp	20 Jul 2004 04:41:36 -0000	1.9
+++ tests/debugger/retry.exp	2 Sep 2004 04:09:32 -0000
@@ -60,7 +60,7 @@
 mdb> stack
    0       pred retry.det_with_cut/2-0 (det)
    1       pred retry.main/2-0 (det)
-mdb> retry 1
+mdb> retry -f 1
       E1:     C1  1 CALL pred retry.main/2-0 (det)
 mdb> break det_with_cut_2
  0: + stop  interface pred retry.det_with_cut_2/2-0 (det)
Index: tests/debugger/retry.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.exp2,v
retrieving revision 1.10
diff -u -b -r1.10 retry.exp2
--- tests/debugger/retry.exp2	2 Aug 2004 07:33:02 -0000	1.10
+++ tests/debugger/retry.exp2	2 Sep 2004 04:09:32 -0000
@@ -64,7 +64,7 @@
 mdb> stack
    0       pred retry.det_with_cut/2-0 (det)
    1       pred retry.main/2-0 (det)
-mdb> retry 1
+mdb> retry -f 1
       E1:     C1  1 CALL pred retry.main/2-0 (det)
 mdb> break det_with_cut_2
  0: + stop  interface pred retry.det_with_cut_2/2-0 (det)
Index: tests/debugger/retry.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.inp,v
retrieving revision 1.4
diff -u -b -r1.4 retry.inp
--- tests/debugger/retry.inp	20 Jul 2004 04:41:37 -0000	1.4
+++ tests/debugger/retry.inp	2 Sep 2004 04:09:32 -0000
@@ -24,7 +24,7 @@
 retry 1
 finish
 stack
-retry 1
+retry -f 1
 break det_with_cut_2
 continue -a
 delete *
cvs server: Diffing tests/debugger/declarative
cvs server: Diffing tests/dppd
cvs server: Diffing tests/general
cvs server: Diffing tests/general/accumulator
cvs server: Diffing tests/general/string_format
cvs server: Diffing tests/general/structure_reuse
cvs server: Diffing tests/grade_subdirs
cvs server: Diffing tests/hard_coded
cvs server: Diffing tests/hard_coded/exceptions
cvs server: Diffing tests/hard_coded/purity
cvs server: Diffing tests/hard_coded/sub-modules
cvs server: Diffing tests/hard_coded/typeclasses
cvs server: Diffing tests/invalid
cvs server: Diffing tests/invalid/purity
cvs server: Diffing tests/misc_tests
cvs server: Diffing tests/mmc_make
cvs server: Diffing tests/mmc_make/lib
cvs server: Diffing tests/recompilation
cvs server: Diffing tests/tabling
cvs server: Diffing tests/term
cvs server: Diffing tests/valid
cvs server: Diffing tests/warnings
cvs server: Diffing tools
cvs server: Diffing trace
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.72
diff -u -b -r1.72 mercury_trace.c
--- trace/mercury_trace.c	20 Jul 2004 04:41:54 -0000	1.72
+++ trace/mercury_trace.c	2 Sep 2004 04:09:32 -0000
@@ -75,6 +75,7 @@
 static  MR_bool     MR_in_traced_region(const MR_Proc_Layout *proc_layout,
                         MR_Word *base_sp, MR_Word *base_curfr);
 static  MR_bool     MR_is_io_state(MR_PseudoTypeInfo pti);
+static  MR_bool     MR_is_dummy_type(MR_PseudoTypeInfo pti);
 static  MR_bool     MR_find_saved_io_counter(const MR_Label_Layout *call_label,
                         MR_Word *base_sp, MR_Word *base_curfr,
                         MR_Unsigned *saved_io_counter_ptr);
@@ -537,6 +538,7 @@
     base_maxfr = MR_saved_maxfr(saved_regs);
     return_label_layout = MR_unwind_stacks_for_retry(top_layout,
         ancestor_level, &base_sp, &base_curfr, &base_maxfr, problem);
+
 #ifdef  MR_DEBUG_RETRY
     MR_print_stack_regs(stdout, saved_regs);
 #endif
@@ -588,22 +590,24 @@
             saved_regs, base_sp, base_curfr,
             call_label->MR_sll_var_nums[i], &succeeded);
 
-        if (! succeeded) {
             if (MR_is_io_state(MR_var_pti(call_label, i))) {
-                /*
-                ** Since I/O state input arguments are not used,
-                ** we can leave arg_value containing garbage.
-                */
-
                 has_io_state = MR_TRUE;
                 found_io_action_counter = MR_find_saved_io_counter(
                         call_label, base_sp, base_curfr,
                         &saved_io_action_counter);
-            } else {
+        }
+
+        if (! succeeded) {
+            if (! MR_is_dummy_type(MR_var_pti(call_label, i))) {
                 *problem = "Cannot perform retry because the "
                     "values of some input arguments are missing.";
                 goto report_problem;
             }
+
+            /*
+            ** Since values of dummy types are not actually used,
+            ** we can leave arg_value containing garbage.
+            */
         }
 
         if (i < MR_long_desc_var_count(call_label)) {
@@ -667,8 +671,14 @@
                     answer = MR_trace_getline(
                             "Are you sure you want to do it? ", in_fp, out_fp);
 
+                    if (answer == NULL) {
+                        /* the user has pressed EOF */
+                        allow_retry = MR_FALSE;
+                    } else {
                     allow_retry = (answer[0] == 'y' || answer[0] == 'Y');
                     MR_free(answer);
+                    }
+
                     if (! allow_retry) {
                         *problem = "Retry aborted.";
                         goto report_problem;
@@ -900,15 +910,47 @@
 MR_is_io_state(MR_PseudoTypeInfo pti)
 {
     MR_TypeCtorInfo type_ctor_info;
+    MR_ConstString  module;
+    MR_ConstString  type;
 
     if (MR_PSEUDO_TYPEINFO_IS_VARIABLE(pti)) {
         return MR_FALSE;
     }
 
     type_ctor_info = MR_PSEUDO_TYPEINFO_GET_TYPE_CTOR_INFO(pti);
+    module = MR_type_ctor_module_name(type_ctor_info);
+    type = MR_type_ctor_name(type_ctor_info);
+
+    return (MR_streq(module, "io") && MR_streq(type, "state"));
+}
 
-    return (MR_streq(MR_type_ctor_module_name(type_ctor_info), "io")
-        && MR_streq(MR_type_ctor_name(type_ctor_info), "state"));
+static MR_bool
+MR_is_dummy_type(MR_PseudoTypeInfo pti)
+{
+    MR_TypeCtorInfo type_ctor_info;
+    MR_ConstString  module;
+    MR_ConstString  type;
+
+    if (MR_PSEUDO_TYPEINFO_IS_VARIABLE(pti)) {
+        return MR_FALSE;
+    }
+
+    type_ctor_info = MR_PSEUDO_TYPEINFO_GET_TYPE_CTOR_INFO(pti);
+    module = MR_type_ctor_module_name(type_ctor_info);
+    type = MR_type_ctor_name(type_ctor_info);
+
+    /*
+    ** These tests should be kept in sync with is_dummy_argument_type_2
+    ** in compiler/type_util.m.
+    */
+
+    if (MR_streq(module, "io") && MR_streq(type, "state")) {
+            return MR_TRUE;
+    } else if (MR_streq(module, "store") && MR_streq(type, "state")) {
+            return MR_TRUE;
+    }
+
+    return MR_FALSE;
 }
 
 static MR_bool
cvs server: Diffing util
cvs server: Diffing vim
cvs server: Diffing vim/after
cvs server: Diffing vim/ftplugin
cvs server: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list