lecture11 - CS 143 Lecture 11 1 Run-time Envir onments...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: CS 143 Lecture 11 1 Run-time Envir onments Lecture 11 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 Well do code generation first . . . CS 143 Lecture 11 3 Run-time envir onments 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 CS 143 Lecture 11 4 Outline Management of run-time resources Correspondence between static (compile-time) and dynamic (run-time) structures Storage organization CS 143 Lecture 11 5 Run-time Resour ces 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) CS 143 Lecture 11 6 Memor y Layout Low Address High Address Memor y Code Other Space CS 143 Lecture 11 7 N otes 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 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 CS 143 Lecture 11 9 Code Gener ation Goals Two goals: Correctness Speed Most complications in code generation come from trying to be fast as well as correct 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 1. When a procedure is called, control eventually returns to the point immediately after the call Do these assumptions always hold? 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 I ncluding all the steps in procedures P calls CS 143 Lecture 11 12 Lifetimes of Var iables 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 CS 143 Lecture 11 13 Activation Tr ees 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 CS 143 Lecture 11 14 Example Class Main { g() : I nt { 1 }; f(): I nt { g() }; main(): I nt {{ g(); f(); }}; } Main f g g CS 143...
View Full Document

Page1 / 50

lecture11 - CS 143 Lecture 11 1 Run-time Envir onments...

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

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