Java Reference
In-Depth Information
12
Runtime Support
We now consider how program structures are implemented in a computer's
memory. The evolution of programming language design has led to the cre-
ation of increasingly sophisticated methods of runtime storage organization.
Arrays, for example, can be allocated as a single fixed-size block of memory.
Newer languages allow array sizes to be set during execution. Flex arrays can
even be expanded as needed by a program.
Originally, all data were global , with a lifetime that spanned the entire pro-
gram. Correspondingly, all storage allocation was static . During translation,
a data object or instruction sequence was simply placed at a fixed memory
address for the entire execution of a program.
In the 1960's, languages like Lisp and Algol 60 introduced local variables ,
which are accessible only during the execution of a subprogram. This feature
led to the notion of stack allocation . When a procedure or method is called,
anew frame is pushed on a runtime stack. A frame contains space for all of
the local variables in a particular procedure. When a procedure returns, its
frame is popped and the space taken by its locals is reclaimed. Therefore, only
procedures that are actually executing are allocated space. Inactive procedures
claim no data space, making large programs far more space e
cient than in
earlier translations, which used only static allocation. Moreover, recursive
procedures , which require multiple frames for separate nested activations of
the same procedure, can be implemented cleanly and naturally.
445
 
 
Search WWH ::




Custom Search