One embodiment of the present invention provides a system that facilitates
code verification and garbage collection in a platform-independent
virtual machine. The system operates by first receiving a code module
written in a platform-independent language. Next, the system examines the
code module to locate calls to program methods within the code module.
The system then transforms the code module so that all operands remaining
on the evaluation stack only relate to the called method when the method
is called, thereby simplifying verification and garbage collection of the
code module.