IT lexicon › Programming › Deoptimization

Deoptimization

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

When a JIT compiler throws away optimised code mid-execution because an assumption it relied on turned out false, and hands control back to slower code.

A JIT optimises on hunches: that a variable is always an integer, that a method is never overridden, that a branch is never taken. Each hunch is protected by a guard. When a guard fails, execution must carry on as if the optimised code never existed, which means reconstructing the interpreter's stack frames from registers and optimised values — including for functions that were inlined out of existence.

The technique comes from Self, where Urs Hölzle and colleagues described it in 1992, originally so optimised code could be debugged. The same people carried it over to HotSpot. The hazard is the deopt loop: code gets optimised, the guard fails, it gets reoptimised under the same assumption, and the program ends up slower than a plain interpreter.

← Back to the lexicon