[m-dev.] Question about WAM style variables in Mercury

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 5 14:00:55 AEDT 2004


On 05-Feb-2004, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> For adding Herbrand types to the language, it would be good if WAM style
> variables didn't require heap allocation, but instead just formed direct
> pointer chains.
> 
> However, this would mean having pointers to the interior of cells rather
> than the start of a cell.

How so?  Could you explain in more detail?

> Question: is this a major no-no?

For the Boehm (et al) conservative collector, if the last remaining
pointer to a heap cell might point into the interior of the cell, then
the offset within the cell to which it points must be registered with
the collector at GC initialization time.  Each offset registered in this
way increases the chances of accidental retention due to non-pointers
being mis-identified as potential pointers, so it is desirable to minimize
the number of different offsets registered.  Currently we register only
the offsets up to 3 (for a 32-bit architecture) or 7 (for a 64-bit
architecture).  Registering these offsets allows us to use the bottom 2 or 3
bits of pointers as tags.

For the accurate collector, the basic requirement is this: given the type
and value of an object that may contain references to heap cell(s),
it must be possible to identify the type and address of the heap cell(s) that
it points (in)to, and to update the reference(s) to those heap cell(s) to point
(in)to a new heap address.  I think the way we currently handle forwarding
pointers also assumes that all pointers into a particular heap cell will point
to the same offset within the heap cell, but I think it would be reasonably
easy to relax that assumption if needed.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  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