摘要 |
One embodiment of the present invention provides a system that reduces the number of heap handles in a program. First, the system builds an intermediate representation of the program. The system then analyzes the intermediate representation to determine whether executing a function may cause a garbage-collection operation. If so, the system further analyzes the program to determine whether a heap handle in the program is defined and/or used in proximity to a call to the function. Next, the system determines whether the heap handle can be replaced by an ordinary pointer, in order to facilitate subsequently converting the heap handle to an ordinary pointer, if possible. Note that converting a heap handle to an ordinary pointer reduces the space requirements for the program and increases the speed and efficiency of the program and garbage collection operations. |