lecture11 - Status We have covered the front-end phases...

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

View Full Document Right Arrow Icon
1 Profs. Aiken CS 143 Lecture 11 1 Run-time Environments Lecture 11 Profs. Aiken CS 143 Lecture 11 2 Status We have covered the front-end phases Lexical analysis – Parsing Semantic analysis Next are the back-end phases – Optimization Code generation We’ll do code generation first . . . Profs. Aiken CS 143 Lecture 11 3 Run-time environments Before discussing code generation, we need to understand what we are trying to generate There are a number of standard techniques for structuring executable code that are widely used Profs. Aiken CS 143 Lecture 11 4 Outline Management of run-time resources Correspondence between static (compile-time) and dynamic (run-time) structures Storage organization Profs. Aiken CS 143 Lecture 11 5 Run-time Resources Execution of a program is initially under the control of the operating system When a program is invoked: The OS allocates space for the program The code is loaded into part of the space The OS jumps to the entry point (i.e., “main”) Profs. Aiken CS 143 Lecture 11 6 Memory Layout Low Address High Address Memory Code Other Space
Image of page 1

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

View Full Document Right Arrow Icon
2 Profs. Aiken CS 143 Lecture 11 7 Notes By tradition, pictures of machine organization have: Low address at the top High address at the bottom Lines delimiting areas for different kinds of data These pictures are simplifications E.g., not all memory need be contiguous Profs. Aiken CS 143 Lecture 11 8 What is Other Space? Holds all data for the program Other Space = Data Space Compiler is responsible for: Generating code Orchestrating use of the data area Profs. Aiken CS 143 Lecture 11 9 Code Generation Goals Two goals: – Correctness – Speed Most complications in code generation come from trying to be fast as well as correct Profs. Aiken CS 143 Lecture 11 10 Assumptions about Execution 1. Execution is sequential; control moves from one point in a program to another in a well- defined order 2. When a procedure is called, control eventually returns to the point immediately after the call Do these assumptions always hold? Profs. Aiken CS 143 Lecture 11 11 Activations An invocation of procedure P is an activation of P • The lifetime of an activation of P is All the steps to execute P Including all the steps in procedures P calls Profs. Aiken CS 143 Lecture 11 12 Lifetimes of Variables • The lifetime of a variable x is the portion of execution in which x is defined Note that Lifetime is a dynamic (run-time) concept Scope is a static concept
Image of page 2
3 Profs. Aiken CS 143 Lecture 11 13 Activation Trees Assumption (2) requires that when P calls Q , then Q returns before P does Lifetimes of procedure activations are properly nested Activation lifetimes can be depicted as a tree Profs. Aiken CS 143 Lecture 11 14 Example Class Main { g() : Int { 1 }; f(): Int { g() }; main(): Int {{ g(); f(); }}; } Main f g g Profs. Aiken
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
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