What is an Activation Record?

Compiler DesignProgramming LanguagesComputer Programming

An Activation Record is a data structure that is activated/ created when a procedure/function is invoked, and it includes the following data about the function.

Activation Record in 'C' language consist of

  • Actual Parameters
  • Number of Arguments
  • Return Address
  • Return Value
  • Old Stack Pointer (SP)
  • Local Data in a function or procedure

Here, Old SP stores the value of stack pointer of Activation Record of procedure which has called this procedure which leads to the generation of this Activation Record, i.e., It is a pointer to the activation record of the caller.

In Stack Allocation Scheme, when procedure A calls Procedure B, the activation record for B will be pushed above the activation record for A. When Procedure B calls procedure C, C’s activation record will be pushed above B’s activation record as in figure −

Two pointers are required for Stack Allocation Scheme −

  • top− It points to the top of the stack. top points to the top of the top activation record. In the figure, the top pointer will point to the top of the C Activation Record.
  • Stack Pointer (SP) − It points to the activation record of the currently active procedure.

In the figure, procedure C is currently an active procedure. So, pointer SP will point to the activation record for C.

Pointer SP on activation record for procedure C contains the value of old SP. Here old SP refers to the value of the previous stack pointer, i.e., previous activation record which is B. So, old SP in an activation record for C contains the value of SP in an activation record for B.

The space for global data is fixed and statically allocated at the corner of the stack.

Saved Machine status− It holds the status about the state of a machine just before the procedure is called. This information involves the value of a program counter and machine register that have to be restored when control returns from the procedure.

Optional access link− It defines non-local data held in other activation records.

Optional control link− It points to the activation record of the caller.

Actual Parameter− It is used by the calling procedure to supply parameters to the called procedure.

Return value− This field is used by the called procedure to return a value to the calling procedure. The size of each of the above fields is determined at the time when the procedure is called. The size of almost all the fields can be decided at compilation time.

Updated on 08-Nov-2021 10:16:59