METHOD AND APPARATUS FOR
DISTINGUISHING REFERENCE VALUES
FROM NON-REFERENCE VALUES IN A
FIELD OF THE INVENTION
The present invention relates to runtime environments for computer systems; more particularly, the present invention relates to an a runtime environment that distinguishes reference values from non-reference values. 10
BACKGROUND OF THE INVENTION
Many prior art runtime environments provide partitioning of registers into volatile registers and non-volatile registers. The partition of registers into volatile and non-volatile is 15 typically performed once and is not subsequently changed. Volatile registers are typically used to pass parameters during subroutine calls and returns, provided the parameters fit. Parameters that do not fit in the volatile registers are passed in memory. Non-volatile registers store information 20 that is maintained across subroutine calls. If a subroutine uses a non-volatile register, the subroutine saves the value stored in the non-volatile register and restores the value prior to returning to the calling routine.
Rigid partitioning of registers into volatile and nonvolatile partitions provides predictability as to what registers are to be saved by called routines and what registers are to be saved by calling routines. However, rigid partitioning of registers does not provide information as to which registers ^ are used for references to objects memory and which registers are used for storing values used by a routine or subroutine. For this reason, conservative garbage collection is often used in runtime environments that provide rigid partitioning of registers. 35
Garbage collection is the automatic recovery of memory space that is no longer required by a computation, routine or subroutine. Thus, garbage is the memory space that has been used, but is no longer required by a computation, routine or subroutine that has not yet been reclaimed by the memory 4Q manager of the runtime environment. Conservative garbage collection is based on an algorithm that overestimates the amount of live data in memory where garbage collection takes place. Conservative garbage collection is typically used where a compiler provides little support as to registers 45 and memory locations that provide pointers to objects in memory.
Because overestimation of live data in memory (i.e., conservative garbage collection) results in sub-optimal memory management, support for non-conservative 50 (perfect) garbage collection is desirable. Anon-conservative garbage collector can take one of two forms. A non-copying collector that requires that unique references from a stack to a heap be identified so that heap objects that are in use are not accidentally collected. Alternatively, a copying collector 55 additionally requires that non-unique references be identified so that they can be modified if the item referenced moves.
Some prior art runtime environments have provided support for garbage collection by providing tags that indicate 60 whether a register or stack entry is a reference value or a non-reference value. However, maintaining tags increases the overhead required for memory management and in some cases reduces the number of bits available to represent data by using a most significant or least significant bit as a tag. 65
Prior art runtime environments have also provided support for garbage collection by providing a rigid reference/
non-reference partitioning of registers. For example, the 68000 microprocessor available from Motorola, Inc. of Schaumburg, 111. provides 16 data (non-reference) and 16 address (reference) registers. Runtime environments based on the 68000 provide 16 data and 16 address registers. Rigid reference/non-reference partitioning, however, is not based on the needs of a particular routine or subroutine, and therefore can provide sub-optimal register partitioning.
What is needed is a runtime environment that supports non-conservative garbage collection without the overhead associated with tags or tables to designate reference and non-reference values. The present invention provides such a runtime environment by providing volatile and non-volatile registers, each of which is further partitioned into reference and non-reference registers. The reference/non-reference partitioning of non-volatile registers is accomplished dynamically.
SUMMARY OF THE INVENTION
A method and apparatus for distinguishing reference values from non-reference values in a runtime environment is described. A set of volatile registers and a set of nonvolatile registers are statically determined. The set of volatile registers is partitioned into reference and non-reference register partitions statically. The set of non-volatile registers is partitioned into reference and non-reference partitions dynamically.
BRIEF DESCRIPTION OF THE DRAWINGS
The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings in which like reference numerals refer to similar elements.
FIG. 1 is one embodiment of a computer system.
FIG. 2 is one embodiment of a layout for an object in a runtime environment.
FIG. 3 is one embodiment of an alternative layout for an object in a runtime environment.
FIG. 4 is one embodiment of an object header for an object in a runtime environment.
FIG. 5 is one embodiment of a stack frame using the calling convention of the present invention within a runtime environment.
FIG. 6 is one embodiment of a computer system is which a routine calls a subroutine.
FIG. 7 is one embodiment of a computer system in which a garbage collection program.
A method and apparatus for distinguishing reference values from non-reference values in a runtime environment is described. In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention can be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the present invention.
Briefly, the runtime environment of the present invention partitions registers in to volatile and non-volatile registers. The runtime environment of the present invention further partitions registers into reference and non-reference registers. The four-way partitioning is used by garbage collection