[m-dev.] for review: last call modulo constructors [1/3]

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jun 23 12:32:08 AEST 1998


On 23-Jun-1998, Andrew Bromage <bromage at cs.mu.OZ.AU> wrote:
> 
> Fergus Henderson wrote:
> 
> > > 	Disallow scheduling of constructions of partially instantiated
> > > 	data structures until we come up with a better algorithm for
> > > 	when this should be done and when it shouldn't.
> > 
> > Could you explain the rationale for this change in a bit more detail?
> > What would be wrong with say scheduling such constructions at the
> > earliest point possible?
> 
> One important reason is bad register behaviour in one very common
> case:
> 
> :- mode foo(in, out).
> 
> foo(X, foo(A,B,C,D,E,F,G,H)) :-
> 	some_call(X),
> 	some_other_call(X),
> 	produce(X,A,B,C,D,E,F,G,H).
> 
> By constructing foo/8 as early as possible, all those output variables
> have to be saved across the calls to some_call and some_other_call.
> 
> Arguably, it should be the job of the optimiser to move the construction
> as late as possible.

Actually I'd argue that the code generator should do a better job of
avoiding unnecessary saves for things with inst free(alias) across calls.
If the cached location of a variable C is `field 3 of variable HeadVar2',
then the code generator need not compute the address of field 3 of
variable HeadVar2 and save that in a stack slot, it is enough to just
save HeadVar2 in a stack slot so that the address to store C in can be
computed after the call.

But of course your comment below still applies:

> since we don't do
> that yet, making this NYI seems like a good design choice to me.

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



More information about the developers mailing list