[MLton-devel] datatype variant tag optimization

Stephen Weeks MLton@mlton.org
Sat, 16 Nov 2002 13:46:12 -0800


> The object types are really just object masks indicating size and
> pointers.  If we ever wanted a type-safe/directed GC, then we would
> likely need a lot more object types, although I suspect still well
> below 2^19.

Agreed (on both counts).

> I wouldn't say 2 has no additional limitations.  If I had a datatype with
> 100 value carrying variants, all with the same pointer mask, then you're
> going to induce 100 different object types, because each one needs it's
> own variant tag.  So, you still cut into total number of object types.
> The advantage of 2 is that it is "dynamic" with respect to the program
> being compiled.

Agreed.

> Also, it's not clear that you need the extra memory reference to get the
> variant tag.  If each variant tag corresponds to a unique type index, why
> not just use the type index as the variant? 

An excellent idea.

> All we do with it is compare it for equality on pattern matches, so
> the actual number isn't important.

Not entirely agreed.  :-)

Both gcc and the native backend sometimes use the fact that the
variant tags are consecutive integers in order to build a jump table.
But, there is no reason why we couldn't arrange the type indices to be
consecutive.  It would still save us the extra memory reference.


-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel