Claims
- 1. A method for gathering code usage information to facilitate removing compiled code that has not been recently used, wherein the method operates in a mixed-mode system that supports execution of both compiled code and interpreter code, the method comprising:
gathering usage information for compiled methods within an application while the application is executing; identifying compiled methods to be removed based on the usage information; and removing the identified compiled methods so that interpreter code is executed for the compiled methods instead of compiled code; whereby removing the compiled methods frees up the memory space used to store the compiled methods.
- 2. The method of claim 1, wherein the method operates during a garbage collection operation that removes unreachable objects from the memory space of the application in addition to removing compiled methods.
- 3. The method of claim 2,
wherein gathering the usage information involves keeping track of how many times each method has been garbage collected without being executed; and wherein identifying the compiled methods to be removed involves identifying compiled methods that have been garbage collected more than a threshold number of times without being executed.
- 4. The method of claim 3, wherein keeping track of how many times a given method has been executed involves:
replacing an instruction in the given method with a trap instruction that causes the instruction to be restored to replace the trap instruction when the given method is executed after garbage collection; and if the instruction has not been replaced since a preceding garbage collection operation, incrementing a counter associated with the trap instruction so that the counter indicates how many times the given method has been garbage collected without being executed.
- 5. The method of claim 4, wherein the counter is stored in a pointer associated with the trap instruction so that additional memory space is not required to store the counter.
- 6. The method of claim 1,
wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the method further comprises de-optimizing the activation record; wherein de-optimizing the activation record involves converting the activation record from being described by the given compiled method to being described by the interpreter.
- 7. The method of claim 1, wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the method does not remove the given compiled method, thereby avoiding the expense of de-optimizing the activation record.
- 8. The method of claim 1, wherein the method further comprises:
determining a total amount of memory used by compiled methods; and removing compiled methods if the total amount of memory used by compiled methods exceeds a threshold value.
- 9. The method of claim 1, wherein the method further comprises:
determining a total amount of memory used by live user data; and removing compiled methods if the total amount of memory used by live user data exceeds a threshold value, thereby freeing additional memory space to accommodate live user data.
- 10. A computer-readable storage medium storing instructions that when executed by a computer cause the computer to perform a method for gathering code usage information to facilitate removing compiled code that has not been recently used, wherein the method operates in a mixed-mode system that supports execution of both compiled code and interpreter code, the method comprising:
gathering usage information for compiled methods within an application while the application is executing; identifying compiled methods to be removed based on the usage information; and removing the identified compiled methods so that interpreter code is executed for the compiled methods instead of compiled code; whereby removing the compiled methods frees up the memory space used to store the compiled methods.
- 11. The computer-readable storage medium of claim 10, wherein the method operates during a garbage collection operation that removes unreachable objects from the memory space of the application in addition to removing compiled methods.
- 12. The computer-readable storage medium of claim 11,
wherein gathering the usage information involves keeping track of how many times each method has been garbage collected without being executed; and wherein identifying the compiled methods to be removed involves identifying compiled methods that have been garbage collected more than a threshold number of times without being executed.
- 13. The computer-readable storage medium of claim 12, wherein keeping track of how many times a given method has been executed involves:
replacing an instruction in the given method with a trap instruction that causes the instruction to be restored to replace the trap instruction when the given method is executed after garbage collection; and if the instruction has not been replaced since a preceding garbage collection operation, incrementing a counter associated with the trap instruction so that the counter indicates how many times the given method has been garbage collected without being executed.
- 14. The computer-readable storage medium of claim 13, wherein the counter is stored in a pointer associated with the trap instruction so that additional memory space is not required to store the counter.
- 15. The computer-readable storage medium of claim 10,
wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the method further comprises de-optimizing the activation record; wherein de-optimizing the activation record involves converting the activation record from being described by the given compiled method to being described by the interpreter.
- 16. The computer-readable storage medium of claim 10, wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the method does not remove the given compiled method, thereby avoiding the expense of de-optimizing the activation record.
- 17. The computer-readable storage medium of claim 10, wherein the method further comprises:
determining a total amount of memory used by compiled methods; and removing compiled methods if the total amount of memory used by compiled methods exceeds a threshold value.
- 18. The computer-readable storage medium of claim 10, wherein the method further comprises:
determining a total amount of memory used by live user data; and removing compiled methods if the total amount of memory used by live user data exceeds a threshold value, thereby freeing additional memory space to accommodate live user data.
- 19. An apparatus for gathering code usage information to facilitate removing compiled code that has not been recently used, wherein the apparatus operates in a mixed-mode system that supports execution of both compiled code and interpreter code, the apparatus comprising:
a monitoring mechanism that is configured to gather usage information for compiled methods within an application while the application is executing; and a method removal mechanism that is configured to,
identify compiled methods to be removed based on the usage information, and to remove the identified compiled methods so that interpreter code is executed for the compiled methods instead of compiled code, whereby removing the compiled methods frees up the memory space used to store the compiled methods.
- 20. The apparatus of claim 19, wherein the apparatus is part of a garbage collection mechanism that removes unreachable objects from the memory space of the application in addition to removing compiled methods.
- 21. The apparatus of claim 20,
wherein the monitoring mechanism is configured to keep track of how many times each method has been garbage collected without being executed; and wherein the method removal mechanism is configured to identify compiled methods that have been garbage collected more than a threshold number of times without being executed.
- 22. The apparatus of claim 21, wherein the monitoring mechanism is configured to:
replace an instruction in a given method with a trap instruction that causes the instruction to be restored to replace the trap instruction when the given method is executed after garbage collection; and if the instruction has not been replaced since a preceding garbage collection operation, to increment a counter associated with the trap instruction so that the counter indicates how many times the given method has been garbage collected without being executed.
- 23. The apparatus of claim 22, wherein the counter is stored in a pointer associated with the trap instruction so that additional memory space is not required to store the counter.
- 24. The apparatus of claim 19, further comprising a de-optimization mechanism;
wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the de-optimization mechanism is configured to de-optimize the activation record; wherein de-optimizing the activation record involves converting the activation record from being described by the given compiled method to being described by the interpreter.
- 25. The apparatus of claim 19, wherein if a given compiled method to be removed describes an activation record that is active on the execution stack, the method removal mechanism is configured not to remove the given compiled method, thereby avoiding the expense of de-optimizing the activation record.
- 26. The apparatus of claim 19, wherein the method removal mechanism is additionally configured to:
determine a total amount of memory used by compiled methods; and to remove compiled methods if the total amount of memory used by compiled methods exceeds a threshold value.
- 27. The apparatus of claim 19, wherein the method removal mechanism is additionally configured to:
determine a total amount of memory used by live user data; and to remove compiled methods if the total amount of memory used by live user data exceeds a threshold value, thereby freeing additional memory space to accommodate live user data.
RELATED APPLICATION
[0001] This application hereby claims priority under 35 U.S.C. §119 to U.S. Provisional Patent Application No. 60/332,925, filed on Nov. 14, 2001, entitled “Improving Performance In Virtual Machines,” by inventors Lars Bak, Jacob R. Andersen, Kasper V. Lund and Steffen Grarup.
Provisional Applications (1)
|
Number |
Date |
Country |
|
60332925 |
Nov 2001 |
US |