Patent ID: 7693919

Claim:
A method for modifying a program to employ eager reference-counting garbage collection, the method comprising: in a computer, introducing reference-counting updates into the program, wherein locations at which the reference-counting updates are introduced in the program are based at least in part on a static analysis of when references in the program are live, and wherein introducing reference-counting updates into the program comprises: preprocessing the program into a normal form, wherein preprocessing the program comprises: replacing call statements for statements that call functions which return references such that the replaced call statements capture returned references; inserting, into one or more functions in the program, fake initializations for formal reference parameters in the one or more functions; and generating shadow references for interior pointers in the program; performing a live-range analysis on the program to determine liveness information for references used in the program; and injecting reference-counting updates into the program based at least in part on the liveness information; wherein injecting reference-counting updates comprises the computer injecting a reference-counting decrement for a reference after a statement in the program across which the reference dies and before a subsequent statement from the program, and wherein the method is performed on an intermediate representation of the program.