A just-in-time (JIT)
compiler typically generates code from bytecodes that have a sequence of
assembly instructions forming a "template". It has been discovered that a just-in-time (JIT)
compiler generates a small number, approximately 2.3,
assembly instructions per
bytecode. It has also been discovered that, within a template, the
assembly instructions are almost always dependent on the next assembly instruction. The absence of a dependence between instructions of different templates is exploited to increase the size of issue groups using scheduling. A fast method for scheduling program instructions is useful in just-in-time (JIT) compilers. Scheduling of instructions is generally useful for just-in-time (JIT) compilers that are targeted to in-order
superscalar processors because the code generated by the JIT compilers is often sequential in nature. The disclosed fast scheduling method has a complexity, and therefore an
execution time, that is proportional to the number of instructions in an instruction block (N complexity), a substantial improvement in comparison to the N2 complexity of conventional
compiler schedulers. The described fast scheduler advantageously reorders instructions with a
single pass, or few passes, through a basic instruction block while a conventional compiler scheduler such as the DAG scheduler must iterate over an instruction
basic block many times. A fast scheduler operates using an analysis of a sliding window of three instructions, applying two rules within the three
instruction window to determine when to reorder instructions. The analysis includes acquiring the opcodes and operands of each instruction in the three
instruction window, and determining register usage and definition of the operands of each instruction with respect to the other instructions within the window. The rules are applied to determine ordering of the instructions within the window.