deoptimization

When a just-in-time compiler throws away optimised machine code because the assumptions it was built on no longer hold, and falls back to slower code.

In more detail

Optimised code assumes things seen so far, such as the types of values, will stay true. When one turns out false, the runtime must undo the optimisation, and frequent deoptimization wastes time recompiling.

Example

In V8, passing an object of a new shape, or a string where a number was always seen, sends TurboFan code back to Ignition bytecode; node --trace-deopt shows it happening.

Related terms

Taught in

References