EP1589425A2

Method and apparatus for determining frequency of execution for compiled methods within a virtual machine

Abstract

One embodiment of the present invention provides a system that facilitates determining a frequency of execution of compiled methods within a virtual machine. The system starts by determining if a compiled method is executing. If so, the system sets a flag corresponding to the compiled method to indicate that the compiled method is executing. Periodically, the system scans the flag and increments the value of a corresponding counter if the flag is set, and then resets the flag. Finally, the system analyzes the value of the counter to determine a frequency of execution of the compiled method.

EP1589425A2, drawing sheet 1
Sheet 1 of 4

Term

Term ended

Projected expiry passed 28 February 2025, 1.6 years ago.

  1. Priority
  2. Filed
  3. Published
  4. Projected expiry
  5. Today

17 claims: 12 independent, 5 dependent

  1. 1
    A method for determining a frequency of execution of compiled methods within a virtual machine, the method comprising:when a compiled method is executed, setting a flag corresponding to the compiled method to indicate that the compiled method is executing;periodically, scanning the flag and incrementing the value of a corresponding counter if the flag is set, and then resetting the flag;and analyzing the value of the counter to determine a frequency of execution of the compiled method.
  2. 4
    The method of any preceding claim, wherein determining when the compiled method is executed further involves executing an instruction when the compiled method is called by a second compiled method, wherein the instruction sets the flag corresponding to the compiled method.
  3. 5
    The method of any preceding claim, wherein determining when the compiled method is executed further involves executing an instruction when returning to a second compiled method from the compiled method, wherein the instruction sets the flag corresponding to the compiled method.
  4. 6
    The method of any preceding claim, wherein determining when the compiled method is executed further involves executing an instruction when returning to the compiled method from a second compiled method, wherein the instruction sets the flag corresponding to the compiled method.
  5. 7
    The method of any preceding claim, wherein determining when the compiled method is executed further involves executing an instruction when initiating a backward branch within the compiled method, wherein the instruction sets the flag corresponding to the compiled method.
  6. 8
    The method of any preceding claim, wherein determining when the compiled method is executed further involves executing an instruction at a target for a backward branch within the compiled method, wherein the instruction sets the flag corresponding to the compiled method.
  7. 9
    The method of any preceding claim, further comprising evicting the compiled method if the frequency of execution of the compiled method is below a predetermined threshold, so that the method must be subsequently recompiled or interpreted if the compiled method is executed again.
  8. 11
    The method of any preceding claim, further comprising periodically decreasing the counter to introduce decay, thereby fading the relevance of historical execution of the compiled method over time.
  9. 13
    The method of any preceding claim, further comprising periodically increasing a weight value assigned to the flag so that subsequent executions of the compiled method count more than prior executions of the compiled method.
  10. 14
    A computer program for implementing the method of any preceding claim.
  11. 15
    A computer-readable storage medium storing instructions that when executed by a computer cause the computer to perform a method for determining a frequency of execution of compiled methods within a virtual machine, the method comprising:when a compiled method is executed, setting a flag corresponding to the compiled method to indicate that the compiled method is executing;periodically, scanning the flag and incrementing the value of a corresponding counter if the flag is set, and then resetting the flag;and analyzing the value of the counter to determine a frequency of execution of the compiled method.
  12. 16
    Apparatus for determining a frequency of execution of compiled methods within a virtual machine, comprising:a determination mechanism configured to determine when a compiled method is executed;a flag setting mechanism configured to set a flag corresponding to the compiled method to indicate that the compiled method is executing, if the compiled method is executing;a scanning mechanism configured to periodically scan the flag and increment the value of a corresponding counter if the flag is set, and to reset the flag;and an analysis mechanism configured to analyze the value of the counter to determine a frequency of execution of the compiled method.
  13. 17
    Apparatus configured to implement the method of any of claims 1 to 13.