[MLton-user] Tracking down allocations

Matthew Fluet fluet at tti-c.org
Sun Jul 15 09:32:34 PDT 2007


On Sun, 15 Jul 2007, Joe Hurd wrote:
> Update: I was able to eliminate the allocations by manually un-nesting
> the inner function in the obvious way:
>
> fun g intArrayRef1 intArrayRef2 i j k = ...big but non-recursive...
>
> fun f intArrayRef1 intArrayRef2 i =
> let
>   val j = ...
>   val k = ...
> in
>   g intArrayRef1 intArrayRef2 i j k
> end;
>
> However, I'm not going to leave the code like this, because it looks
> like a mess. So I wonder why MLton's internal un-nesting doesn't have
> the same effect?

I'm not sure why there is a difference here.  I would expect that, after 
closure conversion, the two programs would be nearly identical, since 
closure conversion lifts every lambda to top-level, first-order functions.
(One difference is that MLton would allocate g's closure as tuple, rather 
than as curried arguments, but that shouldn't have much difference.)

Again, looking at the SSA and SSA2 IL programs may shed some light on the 
difference between the two.  Also, feel free to post the program to
   http://mlton.org/TemporaryUpload
more eyes looking at it might turn up other observations.



More information about the MLton-user mailing list