Patent ID: 7810086

Claim:
A method comprising: converting, via a processor, a computer program authored in a type-safe and memory-safe programming language and stored in a memory coupled to the processor into an intermediate representation, the intermediate representation containing a first safety check of an object reference used in a first operation included in a first and a second instruction of the computer program, wherein the first safety check throws an exception to exit the program in a safe manner when the object reference is unsafe and the safety check comprises one of a null check, a zero check, a type check, a memory address check, and an array bounds check; defining a safety value in the intermediate representation corresponding to the first safety check; overloading the first operation in the first and the second instruction with a second operation that accepts the safety value as an additional argument: determining a second safety check of the object reference associated with the second instruction is redundant with respect to the first safety check; identifying a reason why the second safety check is redundant; associating an additional safety value with the identified reason; eliminating the second safety check from the intermediate representation; and performing code-motion optimization on the first and the second instruction.