[m-dev.] [reuse] for review: reuse cells with different tags

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Mar 13 05:42:08 AEDT 2001


That looks good, Pete.
I do have a couple of suggestions:

On 12-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> +++ compiler/hlds_goal.m	2001/03/12 17:11:10
> @@ -524,7 +524,7 @@
>  :- type cell_to_reuse
>  	---> cell_to_reuse(
>  		prog_var,
> -		cons_id,
> +		list(cons_id),
>  		list(bool)      % A `no' entry means that the corresponding
>  				% argument already has the correct value
>  				% and does not need to be filled in.

You should document the meaning of the list(cons_id) field.

> Index: compiler/ml_unify_gen.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
> retrieving revision 1.16.2.10
> diff -u -r1.16.2.10 ml_unify_gen.m
> --- compiler/ml_unify_gen.m	2001/03/09 14:11:46	1.16.2.10
> +++ compiler/ml_unify_gen.m	2001/03/12 17:11:13
> @@ -1061,12 +1067,16 @@
>  
>  		ml_gen_var(Var, Var1Lval),
>  		ml_gen_var(ReuseVar, Var2Lval),
> -		{ ReusePrimaryTag = PrimaryTag ->
> +
> +		{ list__filter((pred(ReuseTag::in) is semidet :-
> +				ReuseTag \= PrimaryTag
> +			), ReusePrimaryTags, DifferentTags) },
> +		{ DifferentTags = [] ->
>  			Var2Rval = lval(Var2Lval)
>  		;
>  			Var2Rval = mkword(PrimaryTag,
> -					binop(body, lval(Var2Lval),
> -					ml_gen_mktag(ReusePrimaryTag)))
> +					unop(std_unop(strip_tag),
> +					lval(Var2Lval)))
>  		},

`strip_tag' is slightly more expensive that `body', so you should try to
use `body' when possible, i.e. when the old tag is known.  In particular,
in the else case here you should call list__remove_duplicates on
ReusePrimaryTags, and then see if the result is a singleton list;
if so, the contents of that list is the old tag value and you
should use `body' to remove it.

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