Patent ID: 7725887

Claim:
A method for reducing code size, the method comprising the acts of: determining areas of infrequently executed instructions and areas of frequently executed instructions in a set of instructions; identifying a first ordered group of consecutive instructions at a first location in an area of infrequently executed instructions in the set of instructions, wherein the first ordered group of consecutive instructions is identical to one or more second ordered groups of consecutive instructions at one or more second locations in the set of instructions and each of the plurality of second locations is either an area of infrequently executed instructions or an area of frequently executed instructions in the set of instructions; if the first ordered group of consecutive instructions is identical to one or more of the second ordered groups of consecutive instructions in an area of frequently executed code: removing the first ordered group of consecutive instructions from the set of instructions, and replacing the first ordered group of consecutive instructions with an instruction having an offset parameter and a length parameter, the offset parameter identifying an offset between the first location and the second location and the length parameter indicating how many instructions are included in the second ordered group of instructions, wherein when the instruction is executed by a processor, the instruction causes the processor to use the offset parameter to modify a program counter of the processor to point to the second ordered group of consecutive instructions at the second location that is an area of frequently executed instructions and that causes the processor to use the length parameter to determine how many instructions of the second ordered group of consecutive instructions to execute before setting the program counter to a return location adjacent to the instruction that replaced the first ordered group of consecutive instructions; wherein, if more than one second ordered group of consecutive instructions is identical to the first ordered group of consecutive instructions, the method comprises choosing one of the second ordered group of consecutive instructions to minimize the offset parameter.