In a method for reducing code size, replaceable subsets of instructions at
first locations in areas of infrequently executed instructions in a set
of instructions and target subsets of instructions at second locations in
the set of instructions are identified, wherein each replaceable subset
matches at least one target subset. If multiple target subsets of
instructions match one replaceable subset of instructions, one of the
multiple matching target subsets is chosen as the matching target subset
for the one replaceable subset based on whether the multiple target
subsets are located in regions of frequently executed code. For each of
at least some of the replaceable subsets of instructions, the replaceable
subset of instructions is replaced with an instruction to cause the
matching target subset of instructions at the second location to be
executed.