Chapter_7 - Chapter 7 Runtime Environments 1 Each execution of a procedure is referred to as an activation of the procedure If the procedure is

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 7: Runtime Environments
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Activation Record - a contiguous block of storage recording the state of an activation of a function, not all the compilers set the same fields. Each execution of a procedure is referred to as an activation of the procedure . If the procedure is recursive, several of its activation may be alive at the same time.
Background image of page 2
3 What is the contents of the activation record? temporary values local data saved machine status optional access link to refer to non-local data held in other activation records optional control link to refer to the activation actual parameters returned value
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
General Organization of a Activation Record Old SP Return value Return address Argument count Parameter t n ................. Parameter t 2 Parameter t 1 0 2 n -1 .. .. .. SP Direction of Growth caller’s responsibility callee’s duty
Background image of page 4
5 So, local data are accessed by negative offsets from SP (stack pointer, a register holding a particular position of currently activated procedure). A local name X can be referenced by X[SP] ([SP] means the address of SP), where X is the (negative) offset for the name from the location pointed to by SP. Parameter can be referred to by an positive offset from SP. That is, the ith parameter can be referenced by (4+n-i)[SP] (assume each entry takes one unit of space)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Suppose the Memory structure for C program is organized as below, where function P calls Q and Q calls R 0 .. Static area for programs and global (static) data .. 2 n -1 Top Extra storage for R Activation for R Direction Extra storage for Q Activation for Q SP of growth Extra storage for P Activation for P (fp) (sp)
Background image of page 6
TOP is a register holding the top address of the stack . SP is also a permanently allocated register (stack pointer) holding a specific address in the activation record of the currently active procedure. We use SP to indirectly refer to the local variables, parameters, etc. Extra storage is used for storing pointers on
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/28/2011 for the course ENGINEERIN 100 taught by Professor Yangwei during the Spring '10 term at National Cheng Kung University.

Page1 / 31

Chapter_7 - Chapter 7 Runtime Environments 1 Each execution of a procedure is referred to as an activation of the procedure If the procedure is

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online