Patent ID: 7171649
Filing Date: 2007-01-30
Classification: G06F

Abstract:
1. A method for optimizing safe downcasting and similar programming idioms in an object-oriented programming language, comprising: receiving a source program written in the object-oriented programming language; compiling the source program into an intermediate representation using a compiler; examining the intermediate representation to identify a use of a virtual function call to determine if an object of a given base class is a member of a given derived class, wherein such usage facilitates safe downcasting of the object from the given base class to the given derived class, wherein examining the intermediate representation involves examining virtual function tables within a class hierarchy in the intermediate representation to locate identically named virtual functions within multiple classes wherein an identically named virtual function of one derived class of a base class returns a pointer to the object and identically named virtual functions of remaining derived classes of the base class return a null pointer; if the intermediate representation uses the virtual function call in this manner, replacing the virtual function call with a comparison of a virtual function table pointer associated with the object to an address of a virtual function table associated with the given derived class; completing compilation into the intermediate representation; linking the intermediate representation into an executable binary code; and storing the executable representation on a computer readable medium.