[mercury-users] Another Mercury Modes Problem

Ralph Becket rafe at cs.mu.OZ.AU
Tue Jun 4 12:13:57 AEST 2002

Bob McKay, Friday, 31 May 2002:
> On Friday, May 31, 2002, at 04:19 PM, Ralph Becket wrote:
> >Bob McKay, Friday, 31 May 2002:
> >>
> >
> >Garbage is any data that is not reachable - that is, via a pointer on
> >the stack or a live local variable.  Garbage is collected and the space
> >is reused.
> >
> >Glad to have cleared that one up.
> So just to ensure that I understand this clearly (since I don't know
> about the innards of the compiler, I'm not certain what is reachable,
> because I don't know for sure how the stack is implemented): space is
> eligible for garbage collection as soon as there is no call forward
> of that point that refers to it (or is this true only in determinate
> contexts?)

When procedure A calls procedure B, A's local variables are preserved on
the stack.  The currently executing procedure will have its local
variables stored on the top of the stack or in registers.  When B
returns, A restores its local variables from the stack (that is, the
stack grows on a procedure call and shrinks on a procedure return.)

The subset of the values on the stack and in registers that contain
pointers constitutes the root set, in garbage collection parlance.

Liveness is defined inductively:
- a value is live if it is pointed to by a member of the root set;
- a value is live if it is pointed to from another live value;
- and that's it.

Garbage is data that is not live and the space it occupies can be
reclaimed by the garbage collector for use later.

- Ralph
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list