[MLton] CPS in MLton

Stephen Weeks sweeks@sweeks.com
Wed, 18 Jan 2006 21:27:34 -0800


> I have been asked to take the MLton frontend and perform a CPS
> transformation on the IR in order to experiment with some
> optimizations techniques.  Before diving into the source code, I was
> wondering if you could provide any insight into how difficult it
> would be to do this.  Any insight into how to do this would also be
> greatly appreciated.

My guess is that the best way to get a meaningful result is to not CPS
convert, but to apply an analogous version of the optimization to
MLton's direct-style XML/SXML IL.  If you CPS convert the program, in
addition to the problems with defunctorization, flow analysis, and
closure conversion that Matthew mentioned, it will also cause stack
frames to be both immutable and heap allocated, which will introduce a
severe performance penalty for many programs.

You could compare the CPS converted programs with and without the
optimization, but it's not clear how much that would tell you.

> Then, I will either connect it back to the MLton backend, or write
> my own backend.

Again, for meaningful results, you would be much better off to connect
back to MLton.