[MLton-devel] teaching a compiler course using MLton
Thu, 19 Sep 2002 10:29:22 -0700
> I'd rather not have students directly mimic MLton's compilation
> strategy since I think it's sufficiently different/complex to make
> it infeasible for a first-year grad. course. Instead, I've been
> thinking of a project along more classical lines:
> -- convert source to CPS (A-normal form)
> -- implement 0CFA
> -- flow-directed inlining, uncurrying
> -- closure conversion
> -- simple first-order optimizations -- loop-invariance, common
> subexpression, useless argument, ...
> -- code generation
It looks to me like the major difference from MLton's strategy is that
you put flow-directed inlining before closure conversion. I suspect
that is harder than putting it after (as MLton does).
> The idea here is that we use the MLton backend for code generation;
I think it would be cooler to have MLton more tightly integrated than
just as a backend. Here are a couple of ways I see to do this.
1. At the end of each pass, have the students target one of MLton's
ILs, or some suitably sanitized version that you write a translator
for. This way they can test correctess and real performance impact at
2. Focus on adding a language feature (e.g. laziness) and pushing it
all the way through the real compiler. This way, students can see a
lot, and what they do will have immediate, realistic impact. Then
look at how various SSA optimizations affect performance. They can
write a real optimization that affects real programs.
My worry is that if you just do what you propose, there is a lot of
overhead for the students in learning how to work with MLton without a
lot of payoff.
Will most of the students already have had one compiler course? If
not, then (1) seems better. If so, then (2) seems better -- there is
no need to have the students implement all the steps of compilation in
detail. It would probably be more instructive and fun to work on a
Note, I am not saying that (2) should have any research component at
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
MLton-devel mailing list