Patent ID: 7526760

Claim:
A method for implementing virtual method invocation when a compiled code of an invoked method is shared between class types that share a runtime representation, comprising method operations of: setting an entry of an inline cache to a reference to an object; modifying instructions for calling code; and setting the inline cache to be in one of an unresolved state, a monomorphic state, a shared monomorphic state, or a megamorphic state, wherein a routine that sets the inline cache to the monomorphic state includes, retrieving a reference to a runtime representation of a class type of a receiver of the invoked method, determining a code of the invoked method of the class type, modifying the instructions for setting the entry of the inline cache to instructions that set the entry of the inline cache to the reference to the runtime representation of the class type of the receiver, modifying the instructions for calling code to instructions that call an unverified entry point of the code of the invoked method of the class type; and calling a verified entry point of the code of the invoked method for the class type wherein an implementation of the unverified entry point includes, retrieving from the receiver of the invoked method a first reference to the runtime representation of the class type of the receiver, if a reference in the entry of the inline cache equals the first reference to the runtime representation of the class type of the receiver, branching execution to the verified entry point of the code of the invoked method, if the reference in the entry of the inline cache is not equal to the first reference to the runtime representation of the class type of the receiver, retrieving a reference to a first shared runtime representation of the class type from the runtime representation of the class type of the receiver, retrieving a reference to a second shared runtime representation of the class type from the entry of the inline cache, if the reference to the first shared runtime representation equals the reference to the second shared runtime representation, branching execution to a routine that handles cache misses by changing the inline cache to the shared monomorphic state, and if the reference to the first shared runtime representation is not equal to the reference to the second shared runtime representation, branching execution to a routine that handles cache misses by changing the inline cache to the megamorphic state.