[MLton-devel] datatype variant tag optimization

Matthew Fluet fluet@CS.Cornell.EDU
Sat, 16 Nov 2002 11:58:14 -0500 (EST)


> There are two ways we could do it.  As a reminder, the "type index"
> field in the object header currently has 19 bits, limiting us to 2^19
> different object types.  We only use about 100 in a self-compile, and
> so there are a lot to spare.

Careful with terminology.  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.

> 1. We could steal a few bits from the type index
> 2. We could store it in the object type
>
> The advantage of 1 is fast access, but limitations on the number of
> variants and further limitations on the number of object types.
>
> The advantage of 2 is no additional limitations.  It just costs us
> extra memory references at runtime to get the variant tag from the
> object type table.

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.

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?  All we do with it is compare
it for equality on pattern matches, so the actual number isn't important.



-------------------------------------------------------
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