All procedures can be classified in one of two categories: leaf
or non-leaf. A leaf procedure is one that makes no
additional calls, while a non-leaf procedure is one that does make
additional calls. Although simple, the distinction is essential because the
two cases entail considerably different requirements regarding (among other
things) stack allocation and usage.
Every non-leaf procedure requires the allocation of an additional
stack frame in order to preserve necessary execution values and arguments.
A stack frame is not always necessary for a leaf procedure. The
recognition of a procedure as fitting into either the leaf or
non-leaf category and the determination of the necessary frame size
is done at compile time.
As will become evident throughout this document, it is often the case that much
of a procedure's state information is saved in the caller's frame. This helps
to avoid unnecessary stack usage. A general picture of the top of the stack for
one call, including the frames belonging to the caller (previous) and callee
(new), is shown in Figure 2-1.
Figure 2-1 General Stack Layout