Patent ID: 7480902

Claim:
A method comprising: (a) analyzing a first binary version of a program and unwind information associated with the first binary version of the program, the unwind information further comprising language-independent information related to unwinding the program, associated with each unwind region of each procedure of the program, wherein analyzing includes: (i) generating a representation of the program, including a representation of instructions, basic blocks, and procedures; (ii) identifying a basic block type of each represented basic block and marking the representation with the basic block type; (iii) generating unwind state data and unwind attributes for each unwind region of each procedure of the program; (iv) associating unwind state data and attributes with representations of the instructions of the program; and (v) associating unwind state data and attributes with representations of procedures of the program; (b) performing optimization on the first binary version of the program to produce a second binary version of the program based at least in part on the results of the analysis; and (c) generating updated unwind information for the second binary version of the program based at least in part on the results of the analysis and at least in part on the optimization performed; wherein performing optimization on the first binary version of the program to produce the second binary version of the program based at least in part on the results of the analysis further comprises: (i) protecting instructions with associated unwind attributes from deletion during optimization; (ii) if a first instruction with associated unwind attributes is duplicated to create a second instruction during optimization, then creating a representation of the second instruction and unwind attributes associated with the representation of the second instruction based at least in part on the unwind attributes associated with the representation of the first instruction; (iii) preventing any instruction from being moved from a basic block of one basic block type to a basic block of a different basic block type during optimization; and (iv) if a procedure in the first binary version of the program is split into two new procedures during optimization, then generating a representation of each new procedure, unwind state data and attributes for the representation of each new procedure based at least in part on the unwind state data and attributes for the representation of the procedure in the first binary version of the program and at least in part on an unwind rule for the instruction at which the split is made.