Each execution of a procedure is referred to as an activation of the procedure. This is different from the procedure definition, which in its simplest form is the association of an identifier with a statement; the identifier is the name of the procedure, and the statement is the body of the procedure.
If a procedure is non-recursive, then there exists only one activation of procedure at any one time. Whereas if a procedure is recursive, several activations of that procedure may be active at the same time. The information needed by a single execution or a single activation of a procedure is managed using a contiguous block of storage called an "activation record" or fiactivation framefl consisting of the collection of fields. (Very often, registers take the place of one or more of the fields in the activation record.) The activation record contains the following information:
-
Temporary values, such as those arising during the evaluation of the expression.
-
Local data of a procedure.
-
The information about the machine state (i.e., the machine status) just before a procedure is called, including PC values and the values of these registers that must be restored when control is relinquished after the procedure.
-
Access links (optional) referring to non-local data that is held in other activation records. This is not required for a language like FORTRAN, because non-local data is kept in fixed place. But it is required for Pascal.
-
Actual parameters (i.e., the parameters supplied to the called procedure). These parameters may also be passed in machine registers for greater efficiency.
-
The return value used by called procedure to return a value to calling procedure. Again, for greater efficiency, a machine register may be used for returning values.
The size of almost all of the fields of the activation record can be determined at compile time. An exception is if a called procedure has a local array whose size is determined by the values of the actual parameters.
The information in the activation record is organized in a manner that enables easy access at execution time. A pointer to the activation record is required. This pointer is called the current environment pointer (CEP), and it points to one of the fixed fields in the activation record. Using the proper offset from this pointer, and depending upon the format of the activation record, the contents of the activation record can be accessed. Figure 1 shows the organization of information in a typical activation record.