Hello, JIT World: The Joy of Simple JITs (2012)
blog.reverberate.org
blog.reverberate.org
I hate twitter..
Here is my mandatory Brainfuck VM[1] and this is my opcode tables and probably what I like best about Nim metaprogramming[2]
[1]: https://github.com/numforge/laser/blob/9fbb8d2a/examples/ex0...
[2]: https://github.com/numforge/laser/blob/9fbb8d2a/laser/photon...
Basic JIT: https://news.ycombinator.com/item?id=18708410 (even simpler version of the above post)
Cult of the Bound Variable: https://news.ycombinator.com/item?id=18708366 (just pure insanity [pdf])
1. Set a breakpoint at the start of a loop that you want to compile.
2. Single-step one iteration of the loop, stepping down into every function call, logging everything that the code does.
3. Compile the log into native code.
Now any time you need to run this loop again, in the same way, you just branch to the generated code to efficiently "replay" the log of how it ran before.
The rest, as they say, is details...
http://www.ssw.jku.at/Research/Papers/Haeubl11/ (There's a link to the PDF at the bottom which seems to sometimes bypass the ACM paywall, for whatever reason.)
https://github.com/CraneStation/simplejit-demo
Cranelift hopes to become the WASM JIT for Firefox & the debug-mode compiler for rustc