[MLton] bool array size

Stephen Weeks MLton@mlton.org
Thu, 16 Mar 2006 15:10:40 -0800


> What makes MLton decide to do the flattening or not. 

It's a complicated whole-program flow analysis plus some local
conditions to ensure space safety.  Frankly, I'm not very happy with
it, and it is far too brittle.

> In the case with the
> 	{ key: Word.word, ord: int }
> elements, I never handle any of the elements except in the array so
> if it didn't flatten them, I can't imagine when it would.  Certainly
> there was no sharing.

I agree; I would expect it to flatten such a case.  I just checked the
following simple program, and the array is flattened, so it at least
happens sometimes.

----------------------------------------------------------------------
val a = Array.tabulate (13, fn i => (i, i + 1, i + 2))
val (x, y, z) = Array.sub (a, 10)
val 33 = x + y + z
----------------------------------------------------------------------

The thing to look for is a "large" word array type in the RSSA.  For
the above code, I see the following line in the RSSA

  pt_10 = Array {elt = Word96, hasIdentity = true}

That says that there is an array that has 96-byte elements (i.e. 3
words).


There's not much more I can say about your code without seeing it.