A computer program product for use in connection with a computer to provide a code generator for generating, from code in a program, native code executable by a computer system, the computer system including a memory subsystem including a heap in which objects are stored and a stack in which method variables are stored, the computer program product comprising a computer-readable medium having encoded thereon:
- A. a code portion receiver module configured to enable the computer to receive a portion of the program code for which the native executable code is to be generated;
- B. an object instantiation detector module configured to enable the computer to determine whether the received program code portion includes an operator for enabling instantiation of a new object;
- C. a variable promotion eligibility detector module configured to enable the computer to, in response to a positive determination by said object instantiation detector, determine whether the object to be instantiated contains a variable to be used in processing of the received program code portion which can be promoted to a method variable, and
- D. a native code generator module configured to enable the computer to, in response to positive determination by said variable promotion eligibility detector, generate native code to enable said variable to be instantiated on the stack.