IT lexicon › Programming › Tracing JIT

Tracing JIT

Programming På svenska → Updated: 2026-11-06

A JIT compiler that compiles not functions but the actual paths a program takes through a hot loop.

Once a loop proves hot, the interpreter records exactly what happens in one iteration: which branches were taken, what types the values had, which calls were made. The recording is a straight line with no branches — dream material for an optimiser. Every assumption is protected by a guard; when one fails, execution leaves the trace through a side exit back to the interpreter, and if that exit gets hot, a new trace is recorded from it.

The idea came from HP Labs' Dynamo binary translator around 1999. Firefox 3.5 shipped TraceMonkey in 2009, LuaJIT 2 made the technique famous for its speed, and PyPy traces its own interpreter rather than the user's program. The weakness is branchy code, where traces multiply out of control. Mozilla went back to method compilation within two years; LuaJIT remains hard to beat.

← Back to the lexicon