Patent ID: 7124407

Claim:
A computer-implemented method for executing computer code by a virtual machine that uses an interpreter to execute virtual machine program instructions, the computer-implemented method comprising: obtaining, by an interpreter, a virtual machine program instruction to be executed by the virtual machine; determining, by the interpreter, whether the virtual machine program instruction is a branch instruction; determining, by the interpreter, whether a basic block is present in a code cache that stores native code corresponding to virtual machine program instructions when it is determined that the virtual machine program instruction is a branch instruction to be executed by said virtual machine, wherein the basic block is associated with a case block of the interpreter, wherein the case block corresponds to the virtual machine program instruction and the basic block includes native code corresponding to the virtual machine program instruction that has been previously interpreted and executed by the interpreter, thereby determining by the interpreter whether native code needed to execute the virtual machine program instructions is available in the code cache; executing the native code included in the basic block present in the code cache when it is determined by the interpreter that the basic block is present in the code cache and the virtual machine program instruction is a branch instruction; interpreting, by the interpreter, the virtual machine instruction when said determining determines that the basic block associated with the case block of the interpreter is not present in the code cache, wherein said interpreting generates native code for the virtual machine instruction; and copying the native code generated by the interpreter into the code cache after the interpreting of the virtual machine program instruction by the interpreter when said determining determines that the basic block associated with the case block of the interpreter is not present in the code cache so that subsequently the native code can be obtained from the code cache, thereby enhancing the performance of the virtual machine.