big arrays [was Re: bug found]

Stephen Weeks MLton@sourcelight.com
Tue, 27 Nov 2001 15:31:03 -0800


> What we really want is to be able to distinguish between normal
> objects, stacks/conts, and arrays from a pointer to the first data
> word of the object and to be able to distinguish between object
> headers and array lengths from a pointer to the word preceeding the
> first data word of an object.

Yes.

I believe my proposal does this.  Here it is.

Header word
              mark
        31 30 29
normal   1  0  
stack    1  1  
array	 0  0

Length word
        31
         0

All objects (arrays, stacks, normals) are preceded by a header word.
Array header words are preceded by a length.

Bits 0-28 are used in normal and array headers as they are now, to
indicate the number of words or bytes nonpointers and the number of
pointers.

Locating the header given a pointer to the first data word is easy.
The header is the preceeding word.

Locating the header given a pointer to the beginning of the object is
easy.  If the high bit is set, we are looking at the header.  If not,
the next word is the header.

I believe it is more important to make GC_getHeader fast than toData
fast, since the former happens once per pointer during a GC while the
latter happens only once per object.