A JIT for Deterministic Automata using PeachPy
For a lesson about JITs in a colleague's compiler course I wrote a small just-in-time compiler for deterministic finite automata in Python, using PeachPy. I planned to write a complete blog post about them, but it doesn't seem to quite be happening, so below is the code. It has a few comments at least.
The idea is to show a few of the typical things a JIT can do that a static compiler can't: - switching between interpreter and compiled code - profiling to find out which part of the program are executed most commonly - deoptimization back to the interpreter - patching of existing code if new code is added
Here's the code: