8.4 STACK ALLOCATION


8.3 STATIC ALLOCATION

In static allocation, the names are bound to specific storage locations as the program is compiled. These storage locations cannot be changed during the program's execution. Since the binding does not change at run time, every time a procedure is called, its names are bound to the same storage locations. Hence, if the local names are allocated statically, then their values will be retained throughout the activation of a procedure. The compiler uses the name type to determine the amount of storage to set aside for that name. The address of this storage consists of an offset from an end-of-activation record for the procedure. The compiler must decide where the activation records go relative to the target code and relative to other activation records. Once this decision is made, the storage position for each name in the record is fixed. Therefore, at compile time, it is possible to fill in both the address at which the target code can find the data and the address at which information is saved. However, there are some limitations to using static allocation:

  1. The size of the data object and any constraints on its position in memory must be known at compile time.

  2. Recursive procedures cannot be permitted, because all activations of a procedure use the same binding for local names.

  3. Data structures cannot be created dynamically, since there is no mechanism for storage allocation at run time.




Algorithms for Compiler Design
Algorithms for Compiler Design (Electrical and Computer Engineering Series)
ISBN: 1584501006
EAN: 2147483647
Year: 2005
Pages: 108
Authors: O G Kakde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net