Java Reference
In-Depth Information
The local variables and control information area contains space for all local
variables. It also contains space for the return address register, and the value
of the caller's frame pointer. The value of a static link or display register may
be saved here if they are needed. The stack top may be reset, upon return, by
adding the size of the parameter area to the frame pointer. (On the MIPS, as
well as on many other computers, the stack grows downward , from high to low
addresses.)
The details of subroutine calls are exploredmore thoroughly in Section 11.1
on page 418 (at the bytecode level) and Section 13.1.3 on page 496 (at the
machine code level).
Because the Java Virtual Machine (JVM) is designed to run on a wide
variety of architectures and only interacts with external code through a well-
defined native interface, the exact details of its runtime frame layout are un-
specified. A particular implementation (such as the JVM running on a MIPS
processor), chooses a particular layout, similar to that shown in Figure 12.9.
Some languages allow the size of a frame to be expandedduring execution.
In C, for example, alloca allocates space on demand on the stack. Space is
pushed beyond the end of the frame. Upon return, this space is automatically
freed when the frame is popped.
Some languages allow the creation of dynamic arrays whose bounds are
set at runtime when a frame is pushed (e.g., int data[max(a,b)]). At the
start of a subprogram's execution, array bounds are evaluated and necessary
space is pushed in the dynamic area of the frame.
CandC
allow subroutines like printf and scanf to have a variable
number of arguments. The MIPS frame design supports such routines, since
parameter values are placed, in order, just above the frame pointer.
Non-scalar return values can be handled by treating the return value as
the “zero-th parameter.” As an optimization, calls to functions that return a
non-scalar result sometimes pass an address as the zero-th parameter. This
represents a place where the return value can be stored prior to return. Other-
wise, the return value is left on the stack by the function.
++
12.3 Arrays
12.3.1 Static One-Dimensional Arrays
One of the most fundamental data structures in programming languages is the
array. The simplest kind of array is one that has a single index and constant
bounds.Anexample(inCorC
++
)is:
int a[100];
 
 
 
Search WWH ::




Custom Search