Java Reference
In-Depth Information
. . .
Parameter 6
Memory Addresses
Parameter 5
Parameters 1−4
Frame Pointer
Register Save
Area
Local Variables
and
Control Information
Dynamic Area
Top of Stack
Figure 12.9: Layout for MIPS R3000
properly deallocated when their thread is terminated. Since Java guarantees
that all temporaries and locals are contained within a method's frame, stack
management is limited to proper allocation and deallocation of frames.
A Detailed Frame Layout The layout of a frame is normally standardized
for a given architecture. This is necessary to support calls to subprograms
translated by di
erent compilers. Since languages and compilers vary in
the features they support, the frame layout chosen as standard must be very
general and inclusive. As an example, consider Figure 12.9, which illustrates
the frame layout used by the MIPS architecture.
By convention, the first four parameters, if they are scalars or pointers
to structures or arrays, are passed in registers. Additional parameters are
passed through the stack. Parameters that cannot fit in registers, such as
structures or arrays passed by value, are also passed on the stack. The slots for
parameters 1-4 can be used to save parameter registers when a call is made
fromwithin a subprogram. The register save area is used at two di
ff
erent times.
Registers are commonly partitioned into caller-save registers (for which a
caller is responsible) and callee-save registers (for which a called subprogram
is responsible). When execution of a subprogram begins, callee-save registers
used by the subroutine itself are saved in the register save area. When a call
is made from within the subprogram, caller-save registers that are in use are
saved in the register save area. At di
ff
erent registers may be
in use. The register save area must be large enough to handle all calls within
a particular subroutine. Often a fixed-size register save area, big enough to
accommodate all caller-save and callee-save registers, is used. This may waste
a bit of space, but only registers actually in use are saved.
ff
erent call sites, di
ff
 
Search WWH ::




Custom Search