Compile-Time Decisions

Run-Time Information

Unit Activation

Activation Records

Language Issues

Static Storage Allocation

Activation Records for Languages that Support Recursion

Activation Records for Languages that Support Block Structure

Activation Records Whose Size Is Known at Unit Activation

Activation Records with Dynamically Varying Size

Activation Records for Concurrent Units

Storage Allocation for Lisp-like Languages

Storage Allocation for Arrays

12.3.7 Activation Records for Languages that Support Recursion

For languages that support recursion, it is necessary to be able to generate different data spaces since the data for each recrusive call are kept in the activation record.

Such activation records are typically kept on a stack.

When there is more than one recursive call which has not yet terminated, there will be more than one activation record, perhaps for the same code segment.

An extra piece of information must thus be stored in the activation record -- the address of the previous activation record. This pointer is called a dynamic link and points to the activation record of the calling procedure.

Languages such as Algol, Pascal, Modula, C and Ada all allow recursion and require at least the flexibility of a stack-based discipline for storage.

Example 2 shows a program and its stack of activation records when the program is executing at the point marked by the asterisks. The program is not in any particular language, but is pseudocode.

In Example 2, main's activation record contains space to store the values for the variables a and b. The activation record stacked on top of the activation record for main represents the activation record for the (first) call to P. P's parameter x has actual value a, and there is space for its value, as well as space for the local variables p1 and p2. The address of the previous activation record is stored in dynamic link.

On the other hand, the amount of storage required for each variable is know at translation time, so, like FORTRAN, the size of the activation record and a variable's offset is known at translation (compile) time. Since recursive calls require that more than one activation record for the same code segment be kept, it is not possible, as in FORTRAN, to know the offset of the activation record itself at compile-time. Variables in these languages are termed semistatic.