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.