<Li> space for the local variables of the routine (if any). </Li> <P> When stack frame sizes can differ, such as between different functions or between invocations of a particular function, popping a frame off the stack does not constitute a fixed decrement of the stack pointer . At function return, the stack pointer is instead restored to the frame pointer, the value of the stack pointer just before the function was called . Each stack frame contains a stack pointer to the top of the frame immediately below . The stack pointer is a mutable register shared between all invocations . A frame pointer of a given invocation of a function is a copy of the stack pointer as it was before the function was invoked . </P> <P> The locations of all other fields in the frame can be defined relative either to the top of the frame, as negative offsets of the stack pointer, or relative to the top of the frame below, as positive offsets of the frame pointer . The location of the frame pointer itself must inherently be defined as a negative offset of the stack pointer . </P> <P> In most systems a stack frame has a field to contain the previous value of the frame pointer register, the value it had while the caller was executing . For example, the stack frame of DrawLine would have a memory location holding the frame pointer value that DrawSquare uses (not shown in the diagram above). The value is saved upon entry to the subroutine and restored upon return . Having such a field in a known location in the stack frame enables code to access each frame successively underneath the currently executing routine's frame, and also allows the routine to easily restore the frame pointer to the caller's frame, just before it returns . </P>

The dynamic storage allocation approach creates space for a method when the method is invoked