How JIT Compilers are Implemented and Fast: Pypy, LuaJIT, Graal and More
Created on 2020-08-20T02:31:18.078674
- Hot Code: code which is run very frequently; it is in the "hot path" of the program meaning it contributes to slow-down. Similar to the "critical path" in PERT.
- Guard: a test that some performance assertions are true. For example checks that false is indeed still false, before running code that will kerplode if it isn't.
- Tracing: when the system looks at what instructions are *actually* executed, excluding safety checks, and records this "trace" as an optimized set of instructions to run.
- Meta-tracing: when a tracing runtime/compiler is used to implement a tracing runtime/compiler.
- Deoptimize: falling back to a bytecode interpreter if a function seems too hopeless to run in a clever way.
- Type feedback: looking at types which have been coming out of subroutine calls to optimize around those.
- Inlining: taking the contents of a function and copying/integrating it with a call site.
- Tiering: multiple execution strategies; running off a bytecode interpreter, running low quality code that you shit out quickly and include profiling code, running fast quality code you compiled slowly after learning about how a particular function runs.
- Meta tracing/compilation can be used on the interpreter that runs the "slow path," meaning the runtime optimizes itself against what it learns your program does when taking slow paths.
- Difficulty: dynamic languages allow doing stupid things like redefining "false."