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:
- 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
- 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:
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
- Definition of procedure
- Declaration of a name or variable
- Scope of declaration
- Activation of procedure
- Binding of a name
- Lifetime of a binding
- 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 are those arising from the evaluation of expressions, in case where those temporaries cannot be held in registers.
- The local data is a data that is local to the execution of a procedure which is stored in activation record.
- 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.
- 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
- it is an optional link
- It points to the activation record of the calling procedure
- It is also known as dynamic link field
- 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 the results from called procedure to calling procedure
- It is used to store the result of a function call
- 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
0 comments:
Post a Comment