Master the fundamental concepts of jit compilation through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksOptimized JIT code assumes types, shapes, and constant values. When reality diverges, deoptimization reconstructs the interpreter frame and resumes in the safe tier. HotSpot's uncommon_trap and V8's deopt points are critical for correctness.
Record mapping from optimized registers and stack slots back to interpreter locals. On guard failure, call runtime to rebuild frame, invalidate optimized code, continue interpreting.
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 deoptimization in your JIT. This exercise asks you to emit guard checks, maintain deopt maps, and transfer control back to the interpreter when speculative assumptions fail.
Implement deoptimization: run speculatively optimised code, and when one of its assumptions fails, rebuild the exact interpreter state at the failing instruction and finish the call in the interpreter: without the program noticing anything except speed.
cLoading…
Functions are straight-line; instructions are numbered from pc 0. Several func and run lines may appear, functions before the runs that use them.
+ - * on two integers gives an integer, anything involving a float gives a float.[-2³¹, 2³¹-1]. A failing check is a deopt with reason NAME is float (the first failing operand, using its name, or its literal text) or overflow.One line per run:
cLoading…
Arguments and values print as integers, or with %g if they are floats. The frame lists parameters then locals, in order of definition. After the second deopt of a function, append -> NAME marked not optimizable to that line.
Input:
cLoading…
Output:
cLoading…
Hidden tests cover a deopt in the middle of a function (so the frame contains computed locals), 32-bit overflow, float literals in the code, and a function that hits the deopt limit.