[Haskell-cafe] Code generation and optimisation for compiling Haskell
nominolo at googlemail.com
Wed Jan 11 16:20:48 CET 2012
Based on your stated background, the best start would be the (longer)
paper on the Spineless Tagless G-machine . It describes how graph
reduction is actually implemented efficiently. Since then there have
been two major changes to this basic implementation: Use of eval/apply
(a different calling convention)  and constructor tagging 
(which drastically reduces the number of indirect branches from the
original STG approach).
In addition to this fairly low-level stuff, there are very powerful
optimisations performed at a higher level. For a taste see stream
If you're done with these, feel free to ask for more. :)
On 10 January 2012 17:25, Steve Horne <sh006d3592 at blueyonder.co.uk> wrote:
> Although I'm far from being an expert Haskell programmer, I think I'm ready
> to look into some of the details of how it's compiled. I've a copy of Modern
> Compiler Design (Grune, Bal, Jacobs and Langendoen) - I first learned a lot
> of lexical and parsing stuff from it quite a few years ago. Today, I started
> looking through the functional languages section - I've read it before, but
> never absorbed much of it.
> Graph reduction, lambda lifing, etc - it seems pretty simple. Far too
> simple. It's hard to believe that decent performance is possible if all the
> work is done by a run-time graph reduction engine.
> Simon Peyton Jones has written a couple of books on implementing functional
> languages which are available for free download. At a glance, they seem to
> covers similar topics in much more detail. However, they're from 1987 and
> 1992. Considering SPJs period "of despair" when he couldn't get practical
> performance for monadic I/O, these seem very dated.
> Some time ago, I made a note to look up the book "Functional Programming and
> Parallel Graph Rewriting" (I forget why) but again that's from the early
> 90's. I've also got a note to look up Urban Boquists thesis.
> SPJ also has some papers on compilation -
> - and the papers on optimisation by program transformation have caught my
> Are there any current text-books that describe the techniques used by
> compilers like GHC to generate efficient code from functional languages?
> It's OK to assume some knowledge of basic compiler theory - the important
> stuff is code generation and optimisation techniques for lazy functional
> languages in particular.
> Also, what papers should I read? Am I on the right lines with the ones I've
> mentioned above?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Push the envelope. Watch it bend.
More information about the Haskell-Cafe