Block Structure and Non-Block Structure Storage Allocation

Estudies4you
Block Structure and Non-Block Structure Storage Allocation:
  • Compiler must carry out the storage allocation and provide access to variables and data
  • Allocation can be done in two ways:
Compiler Time Allocation or Static Storage Allocation
  • A static storage allocation decision is taken by the compiler by looking only at the text of the program, but not by looking at what the program does when it executes
  • Allocation is done at compile time
Runtime Allocation or Dynamic Storage Allocation
  • A storage allocation decision is dynamic if it can be decided only while program is running
  • Allocation is done at runtime 
  • Storage allocation can be done for two types of data variable:
                Local data
                Non local data
  • The local data can be handled using activation record where as non-local data can be handled using scope information
  • The block structured storage allocation can be done using static scope
  • The non-block structured allocation can be done using dynamic scope
Scope storage allocation includes,
  • Definition of procedure
  • Declaration of a name or variable
  • Scope of declaration
Dynamic storage allocation includes,
  • Activation of procedure
  • Binding of a name
  • Lifetime of a binding
Activation Record
  • Information needed for each execution of a procedure is stored in a record called activation record
  • Procedure calls and returns are usually managed by a runtime stack called the control stack
  • Each live activation has an activation record or a frame
  • The root of activation tree is a the bottom of the stack
  • The current execution path specifies the content of the stack with the last activation as record in the top of the stack
  • Activation record contains 7 fields which are:

Returned
Actual parameters
Control link
Access link
Machine status
Local data
Temporary data
  • Size of each field of activation record can be estimated at compile time.
Temporary Values: 
  • Temporary values are those arising from the evaluation of expressions, in case where those temporaries cannot be held in registers.
Local Data: 
  • The local data is a data that is local to the execution of a procedure which is stored in activation record.
Machine Status: 
  • It holds the information regarding the status of the machine just before the call to a procedure. It contains the machine registers and program counter.
Access Link:
  • It is an optional link
  • It locates data needed by the called procedure which is found somewhere else i.e., in another activation record
  • It also known as static link field
Control Link:
  • it is an optional link
  • It points to the activation record of the calling procedure
  • It is also known as dynamic link field
Actual Parameters:
  • The parameters of a calling procedure are known as actual parameters
  • Actual parameters are passed to the called procedure
  • These values are not placed in the activation record but rather in registers
Return Values:
  • Return values return the results from called procedure to calling procedure
  • It is used to store the result of a function call
Note:
  • Not all fields mentioned are used by all compilers or languages. Registers can take the place of one or more fields.
  • Sizes of almost all fields can be determined at compile time. An execution arises when the procedure has a local array whose size is determined by the value of an actual parameter that is available only when the procedure is called at runtime
Example:
Block Structure and Non-Block Structure Storage Allocation,Static Storage Allocation,Compiler Time Allocation,Runtime Allocation,Dynamic Storage Allocation,Scope storage allocation includes,Dynamic storage allocation includes,Activation Record in symbol table,Activation record contains 7 fields,Temporary Values in symbol table,local data in symbol table, machine status in symbol table, access link in symbol table, control link in symbol table,actual parameters in symbol table, return values in symbol table, r16 jntuh compiler design notes, jntuh r16 compiler design lecture notes,jntu compiler design notes pdf, estudies4you
To Top