[m-dev.] for review: last call modulo constructors [1/3]
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Jun 24 22:06:12 AEST 1998
On 24-Jun-1998, Andrew Bromage <bromage at cs.mu.OZ.AU> wrote:
> Fergus Henderson wrote:
>
> > > +:- type aliasing
> > > + ---> unique % No aliases.
> > > + ; alias. % An alias exists.
> > > + % ; alias_many. % Many aliases - XXX to be added later.
> >
> > Does `alias' mean exactly one alias? At most one alias? At least one alias?
>
> It's actually a marker saying how that var must be updated.
>
> Roughly speaking, a free variable is `unique' if it's a normal free
> variable according to the current Mercury code generator. It is
> `alias' if is a free variable in a partially instantiated data
> structure. The idea is that a `unique' var has no representation,
> or is represented by junk. An `alias' var is represented by a
> reference (to junk).
>
> The `alias_many' is reserved for cases where not all the references
> are known in the current scope,
What about the case where all the references are known, but there is
more than one of them?
E.g. assuming we allow partially instantiated data structures:
p :-
A=f(X),
B=g(X),
% point 1
...
At point 1, X is aliased with the first field of A and the first
field of B. What inst should X have at this point?
...
> > Presumably whether or not a variable is aliased depends on what
> > else is in scope; so if X is aliased to Y, and then (as you traverse
> > down the goal) Y goes out of scope, then X is no longer aliased, right?
> > If so, does that mean that mode analysis must update all the
> > `free(alias)' insts whenever variables go out of scope?
>
> No. Once it's free(alias), it's "tainted" until it's bound.
>
> If X is aliased to f(Y), and X goes out of scope, Y is still free(alias),
> because when Y is bound, the value must be stored through a reference.
Why does the value have to be stored through a reference?
If there's nothing live that aliases Y, why does the cell refered to by
the reference need to be updated?
Couldn't the compiler just keep Y in a register?
--
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