{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter_7 - Chapter 7 Runtime Environments 1 Each execution...

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

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

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

View Full Document Right 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.
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
Image of page 3

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

View Full Document Right Arrow Icon
General Organization of a Activation Record Local & temp. data 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
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)
Image of page 5

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

View Full Document Right 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)
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.
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern