The first step in optimisation is to trace, or record, the execution of the program. Each instruction executed is recorded, along with the values of the inputs and outputs of that instruction. Execution of the trace can stop for one of three reasons: * The VM sees the first instruction recorded again, in which case it has found a loop. * The VM decides to stop recording because it may have a better chance of finding a loop if it restarts recording. * An exception is raised, when it just gives up.
If the trace recording succeeds, in other words no exception is thrown, then optimisation proceeds to Specialisation