The idea is to pre-compile small code snippet functions with LLVM and then stitch them together. They use CPS with GHC calling convention so that function calls and returns are jumps, and arguments are passed through using registers. Using linker information, they can replace the targets of those return jumps to stitch control flow together. Code snippets can be parameterized over constants that they can patch in.

The performance of the generated code is an order of magnitude better than an AST interpreter, while having almost zero compilation cost compared to generating the AST in the first place.

Sign in to participate in the conversation

A Mastodon instance for programming language theorists and mathematicians. Or just anyone who wants to hang out.