[m-rev.] for review: stack slot optimization, part 1

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 13 17:38:15 AEDT 2002


On 09-Mar-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> compiler/live_vars.m:
> 	If the new option --opt-no-return-calls is set, then say that we do not
> 	need to save any values across erroneous calls.
...
> compiler/call_gen.m:
> compiler/code_info.m:
> compiler/continuation_info.m:
> compiler/var_locn.m:
> 	Allow the code generator to delete its last record of the location
> 	of a value when generating code to make an erroneous call, if the new
> 	--opt-no-return-calls option is set.

This option is not mentioned elsewhere in the log message.
It should be mentioned in the description of the changes for options.m.
If it is deliberately undocumented, then the log message for options.m
should say so; otherwise, it should be documented in doc/user_guide.texi.

> compiler/handle_options.m:
> 	Turn off stack slot optimizations when debugging.

... unless `--trace-optimized' is set?

> compiler/*.m:
> 	Minor changes to accomodate the placement of all back end specific
> 	information about goals in the new of store maps from goal_exprs.

I can't parse that sentence.

> Index: compiler/arg_info.m
...
> +arg_info__partition_proc_args(ProcInfo, ModuleInfo, Inputs, Outputs, Unuseds) :-
> +	proc_info_headvars(ProcInfo, Vars),
> +	proc_info_argmodes(ProcInfo, Modes),
> +	proc_info_vartypes(ProcInfo, VarTypes),
> +	map__apply_to_list(Vars, VarTypes, Types),
> +	(
> +		arg_info__partition_proc_args_2(Vars, Modes, Types, ModuleInfo,
> +			set__init, Inputs1, set__init, Outputs1,
> +			set__init, Unuseds1)
> +	->
> +		Inputs = Inputs1,
> +		Outputs = Outputs1,
> +		Unuseds = Unuseds1
> +	;
> +		error("arg_info__partition_proc_args: list length mismatch")
> +	).
> +
> +arg_info__partition_proc_call_args(ProcInfo, VarTypes, ModuleInfo, Vars,
> +		Inputs, Outputs, Unuseds) :-
> +	proc_info_argmodes(ProcInfo, Modes),
> +	map__apply_to_list(Vars, VarTypes, Types),
> +	(
> +		arg_info__partition_proc_args_2(Vars, Modes, Types, ModuleInfo,
> +			set__init, Inputs1, set__init, Outputs1,
> +			set__init, Unuseds1)
> +	->
> +		Inputs = Inputs1,
> +		Outputs = Outputs1,
> +		Unuseds = Unuseds1
> +	;
> +		error("arg_info__partition_proc_call_args: list length mismatch")
> +	).
> +
> +arg_info__partition_generic_call_args(ModuleInfo, Vars, Types, Modes,
> +		Inputs, Outputs, Unuseds) :-
> +	(
> +		arg_info__partition_proc_args_2(Vars, Modes, Types, ModuleInfo,
> +			set__init, Inputs1, set__init, Outputs1,
> +			set__init, Unuseds1)
> +	->
> +		Inputs = Inputs1,
> +		Outputs = Outputs1,
> +		Unuseds = Unuseds1
> +	;
> +		error("arg_info__partition_generic_call_args: list length mismatch")
> +	).

The code immediately above is duplicated three times.
This should be avoided.

> +:- type type_giving_arg --->	last_arg ; last_but_one_arg.
> +
> +code_gen__push_msg(ModuleInfo, PredId, ProcId) = PushMsg :-
> +	module_info_pred_info(ModuleInfo, PredId, PredInfo),
> +	pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
> +	pred_info_module(PredInfo, ModuleName),
> +	pred_info_name(PredInfo, PredName),
> +	pred_info_arity(PredInfo, Arity),
> +	(
> +		( PredName = "__Unify__", WhichArg = last_arg
> +		; PredName = "__Index__", WhichArg = last_but_one_arg
> +		; PredName = "__Compare__", WhichArg = last_arg
> +		)
> +	->
> +		pred_info_arg_types(PredInfo, ArgTypes),
> +		code_gen__find_arg_type_ctor(WhichArg, ArgTypes, TypeName),

Instead of this stuff with `type_giving_arg',
this code should use special_pred_get_type from special_pred.m.
(You may also need code_util__compiler_generated or
special_pred_name_and_arity.)

> +	(
> +		PredOrFunc = predicate,
> +		PredOrFuncString = "pred "
> +	;
> +		PredOrFunc = function,
> +		PredOrFuncString = "func "
> +	),

Use hlds_out__pred_or_func_to_str.

> +++ compiler/code_util.m	8 Mar 2002 04:04:12 -0000
> @@ -154,6 +154,13 @@
>  :- pred code_util__cannot_stack_flush(hlds_goal).
>  :- mode code_util__cannot_stack_flush(in) is semidet.
>  
> +	% Succeed if the given goal cannot encounter a context
> +	% that causes any variable to be flushed to its stack slot or to a
> +	% register.
> +
> +:- pred code_util__cannot_flush(hlds_goal).
> +:- mode code_util__cannot_flush(in) is semidet.

I don't know what it means for a goal to "encounter" a context,
so it's not clear what this comment is supposed to mean.

Do you mean "contain"?

Otherwise this part of the diff looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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