[gclist] Re: gclist-digest V3 #84

William D Clinger will@ccs.neu.edu
Tue, 20 Jun 2000 10:36:25 -0400


Douglas Atique wrote:
> If one says the root is an object
> which is pointed by the register R1 (more accurately, the root is the register
> R1) there is no doubt it is a pointer because the register contents are always
> interpreted (by convention) as an address and that register might never hold an
> integer. 

That is one way to do it.  Another way is to determine which registers
are pointers by using the program counter as an index into a table.
See below.

> But how does one know which locations in a stack are pointers?

There are various ways to know this.  The stack is usually divided into
frames (aka activation records).  Usually a return address is associated
with each frame (although the return address that corresponds to a frame
may be stored in the next frame or, for the topmost frame, kept in a
register).  Compilers often create tables that allow a debugger to
translate one of these return addresses into some description of the
contents of the frame.  This mechanism can be extended to allow garbage
collectors to determine which frame slots may represent pointers.

> But what about a stack which is always changing its
> configuration (can I say its "type"?) as scopes are entered and exited in the
> execution of a program?

Although the stack is changing, the "type" of the particular stack
frame that is associated with a particular return address is invariant.

> How does one describe it?

A sequence of bits, one for each register and one for each word in the
stack frame, usually suffices.

> Are there stack descriptors
> pointed to by the first word of the stack?

This also works, but adds one or two instructions to the frame setup so
it is usually faster to use return addresses as indexes into a table of
descriptors.

One more thing to keep in mind is that garbage collections, like thread
switches, may be restricted to certain static locations in the program.
For example, garbage collections may occur only when storage is allocated,
which would imply that the only program points at which a procedure can be
suspended when a garbage collection occurs are the allocation points, the
return points, and the thread resumption points.

These were good questions.  It would make sense to add this stuff to the
GC FAQ at http://www.iecc.com/gclist/GC-faq.html .

Will