Run-time Environments - Compiler Construction - Lecture Slides, Slides of Compiler Construction

Main points of this lecture are: Run-Time Environments, Lexical Analysis, Parsing, Semantic Analysis, Back-End Phases, Optimization, Code Generation, Generation First, Code Generation, Trying Generate

Typology: Slides

2012/2013

Uploaded on 04/25/2013

rajnikanth
rajnikanth 🇮🇳

4.3

(32)

135 documents

1 / 39

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Run-time Environments
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download Run-time Environments - Compiler Construction - Lecture Slides and more Slides Compiler Construction in PDF only on Docsity!

Run-time Environments

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...

Outline

  • Management of run-time resources
  • Correspondence between static (compile-time) and dynamic (run-time) structures
  • Storage organization

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”)

Notes

  • Our 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
  • In some textbooks lower addresses are at bottom

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

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?

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 that P calls

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

Example

Class Main {

g() : Int { 1 }; f(): Int { g() }; main(): Int {{ g(); f(); }};

} Main

g f

g

Example

Class Main {

g() : Int { 1 }; f(): Int { g() }; main(): Int {{ g(); f(); }};

} Main Stack Main

Example

Class Main {

g() : Int { 1 }; f(): Int { g() }; main(): Int {{ g(); f(); }};

} Main

g

Stack Main g

Example

Class Main {

g() : Int { 1 }; f(): Int { g() }; main(): Int {{ g(); f(); }};

} Main

g f

g

Stack Main f g

Notes

  • The activation tree depends on run-time behavior
  • The activation tree may be different for every program input
  • Since activations are properly nested, a stack can track currently active procedures