[Haskell-cafe] LFVM-STG Compilation

james faure james.faure at epitech.eu
Thu May 9 12:54:01 UTC 2019

I want to introduce the STG backend I am currently working on:
I'd love to see how much interest there is for this, to receive any comments, and find out if I've missed anything !

The goal is to massively speed up compilation times and generate faster and clearer code, and in that respect I am already quite successful. Llvm is very well suited for encoding a (lazy) functional language, however the evaluation mechanism is very different to ghc's stg, there is notably no continuation passing nor result registers. In LFVM, all non constant let bindings are given an llvm function. I believe this approach is more natural, the llvm more accurately reflects the source code and we get proper stack traces in a debugger.

The project is barely a month old, and I'm working to support everything ghc's code generation supports.
The STG is heavily based on the one found in ghc and, at this time and as far as I can tell, supports everything except multithreading, a gc and lazy evaluation. The current idea I think is very promising is to use an inferred pi calculus to elegantly implement all 3 missing parts at once.

Pi calculus [1] (process calculus) In the STG

  *   Multithreading occurs for arguments of functions with >1 arity
  *   Perfect garbage collection is quite probably possible [2], where allocation creates a new pi name, and its uses are modeled by pi calculus communication
  *   Perfect Lazy evaluation (in the sense that the wrapper and associated wrapped type overhead is coerced away after the first evaluation) is possible in the pi calculus and closely linked the gc model. I intend to make strict evaluation the default, If you want lazy (for MonadFix or infinite lists or whatever), you must request it.

[1]: https://en.wikipedia.org/wiki/%CE%A0-calculus
[2]: https://www.researchgate.net/publication/228514964_Resources_garbage-collection_and_the_pi-calculus

James Faure (Discord: J4#0303)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190509/60fb05dd/attachment.html>

More information about the Haskell-Cafe mailing list