One embodiment of the present invention provides a system that facilitates
developing an application that implements garbage collection (such as a
virtual machine) using a first compiler and then compiling the application
with a second compiler that provides support for efficient garbage
collection. The system operates by developing the application using a
first compiler and proxy objects, so that during execution of the
application, pointers within the system stack point indirectly to data
objects through proxy objects. These proxy objects are used during the
garbage collection process to identify data objects that are referenced by
the pointers within the system stack. Next, the system provides a second
compiler that produces stack maps that identify pointers in the system
stack. This allows the garbage collection process to identify objects
referenced by the pointers in the system stack without using proxy
objects. The application is then compiled using the second compiler, so
pointers in the system stack point directly to objects instead of pointing
to the objects indirectly through proxy objects. This allows the
application to run faster because it eliminates the extra indirection
operations caused by proxy objects. Thus, the above-described system
allows programmers to develop an application using proxy objects, while
concurrently developing a second compiler that provides stack maps to
support garbage collection. When the second compiler is completed the
application can be compiled with the second compiler.