Master the fundamental concepts of jit compilation through this focused micro-challenge.
Self-hosting JITs compile their own optimizing tiers to native code. LuaJIT's FFI and HotSpot's C2 eventually run as generated machine code. The bootstrap compiles a minimal compiler, then uses it to compile the full compiler for speed.
Stage 0: C interpreter. Stage 1: minimal JIT enough to compile stage 2. Stage 2: full optimizer emits code for itself and user programs.
cLoading…
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement a self-hosting JIT that compiles its own compiler logic. This exercise requires bootstrapping from a minimal emitter to a JIT that generates native code for compiler functions themselves.
Implement self-hosting JIT compiler.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github