
Hello, JIT World: The Joy of Simple JITs (2012) - codezero
http://blog.reverberate.org/2012/12/hello-jit-world-joy-of-simple-jits.html
======
swah
I remember a decade ago there were awesome blog posts about programming
languages all the time... Andy Wingo talking about Scheme, Ola Bini talking
about Iota, Steve Dekorte about Io, Slava Pestov on Factor, _why had potion,
Ruby was "fresh", and Steve Yegge writing long posts about languages as
well...

I hate twitter..

~~~
bjoli
Wingo is Still at it, and recently there has been a flow of interesting JIT
posts since guile 3.0 will have a JIT.

------
mratsim
I played with JITs in Nim recently I found it quite enjoyable.

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...](https://github.com/numforge/laser/blob/9fbb8d2a/examples/ex07_jit_brainfuck_vm.nim)

[2]:
[https://github.com/numforge/laser/blob/9fbb8d2a/laser/photon...](https://github.com/numforge/laser/blob/9fbb8d2a/laser/photon_jit/x86_64/x86_64_ops.nim)

------
mrfredward
For rustaceans out there who are interested, check out
[https://github.com/CensoredUsername/dynasm-
rs](https://github.com/CensoredUsername/dynasm-rs) as a nice rust replacement
for dynasm.

------
codezero
I submitted a bunch of stream of consciousness JIT and related posts today, if
this interests you, check out these too:

Basic JIT:
[https://news.ycombinator.com/item?id=18708410](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](https://news.ycombinator.com/item?id=18708366)
(just pure insanity [pdf])

~~~
huntie
Do you know of anything that goes over tracing JIT?

~~~
lukego
Tangentially, here is one way to think about how tracing JIT works:

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...

------
__s
& on a bit of a tangent, Cranelift now builds on stable Rust if you want to
write your JIT in not-C

[https://github.com/CraneStation/simplejit-
demo](https://github.com/CraneStation/simplejit-demo)

Cranelift hopes to become the WASM JIT for Firefox & the debug-mode compiler
for rustc

