[MLton] Tagged ref and array pointers

Matthew Fluet fluet at tti-c.org
Wed Nov 12 16:25:15 PST 2008


On Wed, 12 Nov 2008, Wesley W. Terpstra wrote:
> I was debugging what I thought was a space leak when I discovered that
> MLton doesn't seem to use the lower 2 bits of a pointer to ref/array
> objects.

I don't know if it is that MLton doesn't use the lower 2 bits of a pointer 
to ref/array objects of if it is that MLton doesn't use the lower 2 bits 
of a pointer out of a vector; there is a {forceBox = true} when computing 
the representation of vector elements (that may, or may not, be relevant 
here).

> Produces the memory layout in the attached png file. You can see that
> it represents the datatype using an intermediate heap object instead
> of packing the flag into the low bits of the pointer to the ref cell.
> I've seen the same behaviour with datatypes to a vector. MLton does
> the right thing other times (tracking the variants of a datatype the
> low bits of the pointer) for recursive datatypes and a few other
> cases. Is there a good reason for it not performing this optimization
> here?

Seems like it would be a valid representation decision.  I haven't a clue 
how to coerce packed-representation.fun into making it.



More information about the MLton mailing list