Retrofitting JIT Compilers into C Interpreters
52 points by ltratt
52 points by ltratt
Great read! This is very clever.
Since video games have very tight performance constraints, many game engines are stuck with Lua 5.1 (the one that LuaJIT supports).
Something like this can be super useful for game engines and applications wanting higher performance out of embedded scripting languages.
JIT in games makes sense only in debug builds, they’re banned on most platforms (consoles and Apple's systems other than macOS) due to security concerns.
macOS has always allowed JITs. Even sandboxed apps can use JIT nowadays by adding an entitlement.
Also, I hear Windows is a popular game platform?
Which consoled ban JITs? Most of them aim to give games complete control over as much as possible. Every Xbox game, for example, runs in an isolated (encrypted) VM with device pass through to the GPU. The threat model is that it can do whatever it wants in that VM, it just can’t escape. The attacker is assumed to have arbitrary code execution in that VM.
MacOS does allow JIT. As long as JIT is fine within pthread_jit_write_protect_np.
E.g: Love2D usesLua JIT. It's one of the most popular game engines for Lua.
I know of a couple of other reverse register allocators:
A new register allocator for Rust's Cranelift backend – the algorithm is described in the preceding “regalloc II” post
It took me a minute to realize this meant interpreters written in C, and not interpreters of the C language.
This is great! I've been following along with yk's development for a few years now, after stumbling across it while working on my own (bad, shelved) meta-JIT library. Meta-JITs are extremely cool and it's really encouraging that yk is able to actually get sizable speedups in practice. Between this and weval it feels like the dream of HP Dynamo and other attempts at "just distill a faster program" are being revived a bit.
Great post. I'm a little sad to not see Skybison Python runtime mentioned but I suppose it only had a prototype JIT anyway.
I just read that and thought "I'm sure I mentioned Skybison" but... no. Oops! Fixed (and sorry!).