[m-dev.] diff: fix reuse codegen problem

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 9 01:38:49 AEDT 2001


On 08-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> On Thu, Mar 08, 2001 at 11:50:35PM +1100, Fergus Henderson wrote:
> > On 08-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > 
> > > compiler/ml_unify_gen.m:
> > >     Change from using the depreceated body binop to the unmkbody unop.
> > 
> > s/depreceated/deprecated/
> > 
> > What makes you think that the `body' binop is deprecated?
> > If it is, why is it deprecated?
>
> Because mlds_output_binop no longer handles this case,

Ah, I see.

> and it used to work at some previous point,

Hmm, I'm quite skeptical about that.
It looks to me like it can never have worked.

> so I assumed that we were no longer using this operator.
> 
> > > +++ compiler/ml_unify_gen.m	2001/03/08 09:36:41
> > > @@ -1065,8 +1065,8 @@
> > >  			Var2Rval = lval(Var2Lval)
> > >  		;
> > >  			Var2Rval = mkword(PrimaryTag,
> > > -					binop(body, lval(Var2Lval),
> > > -					ml_gen_mktag(ReusePrimaryTag)))
> > > +					unop(std_unop(unmkbody),
> > > +					lval(Var2Lval)))
> > 
> > Could you explain that one for me in more detail?
>
> When reusing a cell, we must ensure that the tag is correct.  If the tag
> on the cell we wish to reuse is different to the one which should be on
> the new cell, then we replace the old tag with the new tag.

OK, that much I understood.  I understand what the code is intended to do.
What I don't understand is how your modification helps it to do that.
The old code there

  			Var2Rval = mkword(PrimaryTag,
					binop(body, lval(Var2Lval),
					ml_gen_mktag(ReusePrimaryTag)))

looks fine to me.  If mlds_to_c is not handling the `body' binop,
then mlds_to_c should be fixed, not the code here.

The new code that you replaced it with, namely

  			Var2Rval = mkword(PrimaryTag,
					unop(std_unop(unmkbody),
					lval(Var2Lval)))

looks completely wrong.  You can't just replace `body'
with `unmkbody', since they do opposite things.

In particular,

	(1) the argument to `unmkbody' is supposed to be something that
	resulted from a call to `mkbody', i.e. something without a tag.
	But the argument that you pass to it, i.e. `Var2Lval', might have
	a tag on it.

	(2) the second argument to `mkword' is supposed to be either
	a pointer or something that resulted from a call to `mkbody',
	but you pass it the result of a call to `unmkbody', which
	is neither of those two.

-- 
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