Master the fundamental concepts of jit compilation through this focused micro-challenge.
Dynamic languages call methods with unknown targets. Inline caching stores the last seen callee at the call site; monomorphic sites jump direct after one comparison. JSC and V8 use ICs for obj.method() dispatch.
Call site stub checks receiver's class/map against cached class. Match: jump to cached function. Miss: call runtime to resolve and patch cache.
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 inline caching for dynamic dispatch. This exercise asks you to patch call sites with class checks and direct jumps to cached callee code on the monomorphic fast path.
Implement a simple inline cache simulator in C.
Requirements:
Test:
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