Out-of-order execution
In short: A modern processor does not execute instructions strictly in program order but pulls forward instructions whose data is ready, then reorders the results afterwards.
In more detail: If an instruction must wait for slow data from memory, a strict processor would stall. The out-of-order processor handles independent instructions in the meantime and ensures the visible result still matches the program logic.
In Depth
- Reorder buffer: Collects results and commits them in the right order (“retirement”).
- Register renaming: Removes false dependencies between instructions.
- Speculation: At branches the processor guesses the path and computes ahead. If it was wrong, everything is discarded.
- Security: Speculative execution enabled attacks such as Spectre and Meltdown via timing differences in the cache.
- Consequence for code: Predictable branches and predictable memory access run faster.
See also: Memory hierarchy and cache lines