SlideShare a Scribd company logo
1 of 16
Run-Time Environments Chapter 7 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2009
Procedure Activation and Lifetime ,[object Object],[object Object],[object Object]
Procedure Activations: Example program sort(input, output)   var a : array [0..10] of integer;   procedure readarray;   var i : integer;   begin   for i := 1 to 9 do read(a[i])   end;   function partition(y, z : integer) : integer   var i, j, x, v : integer;   begin …   end   procedure quicksort(m, n : integer);   var i : integer;   begin   if (n > m) then begin   i := partition(m, n);   quicksort(m, i - 1);   quicksort(i + 1, n)   end   end;   begin   a[0] := -9999; a[10] := 9999;   readarray;   quicksort(1, 9)   end. Activations: begin sort  enter readarray  leave readarray  enter quicksort(1,9)   enter partition(1,9)   leave partition(1,9)   enter quicksort(1,3)   …   leave quicksort(1,3)   enter quicksort(5,9) …   leave quicksort(5,9)  leave quicksort(1,9) end sort.
Activation Trees: Example s q(1,9) q(1,3) p(1,3) q(1,0) q(2,3) q(2,1) p(2,3) q(3,3) p(1,9) r q(5,9) p(5,9) q(5,5) q(7,9) q(7,7) p(7,9) q(9,9) Activation tree for the sort program Note: also referred to as the dynamic call graph
Control Stack s q(1,9) q(1,3) p(1,3) q(1,0) q(2,3) p(1,9) r Activations: begin sort  enter readarray  leave readarray  enter quicksort(1,9)   enter partition(1,9)   leave partition(1,9)   enter quicksort(1,3)   enter partition(1,3)   leave partition(1,3)   enter quicksort(1,0) leave quicksort(1,0)   enter quicksort(2,3)   … Control stack: Activation tree: s q(1,9) q(1,3) q(2,3)
Scope Rules ,[object Object],program prg;   var y : real; function x(a : real) : real;   begin … end; procedure p;   var x : integer;   begin   x := 1;   …   end; begin y := x(0.0);   … end. Variable  x  locally declared in  p A function  x
Mapping Names to Values name storage value environment state var i; … i := 0; … i := i + 1;
Mapping Names to Values name storage value environment state var i; … i := 0; … i := i + 1; At compile time At run time
Static and Dynamic Notions of Bindings Static Notion Dynamic Notion Definition of a procedure Activations of the procedure Declaration of a name Bindings of the name Scope of a declaration Lifetime of a binding
Stack Allocation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Activation Records (Subroutine Frames) Caller’s responsibility to initialize Callee’s responsibility to initialize fp (frame pointer) Returned value Actual parameters Optional control link Optional access link Save machine status Local data Temporaries
Control Links fp sp Control link Stack growth Callee’s activation record Caller’s activation record The control link is the old value of the fp
Scope with Nested Procedures program sort(input, output)   var a : array [0..10] of integer;   x : integer;   procedure readarray;   var i : integer;   begin … end;   procedure exchange(i, j : integer);   begin x := a[i]; a[i] := a[j]; a[j] := x end;   procedure quicksort(m, n : integer);   var k, v : integer;   function partition(y, z : integer) : integer   var i, j : integer;   begin … exchange(i, j) … end   begin   if (n > m) then begin   i := partition(m, n);   quicksort(m, i - 1);   quicksort(i + 1, n)   end   end;   begin   …   quicksort(1, 9)   end.
Access Links (Static Links) The access link points to the activation record of the static parent procedure: s  is parent of  r ,  e , and  q q  is parent of  p s a x q(1,9)  access   k v s a x q(1,9)  access   k v q(1,3)  access   k v s a x q(1,9)  access   k v q(1,3)  access   k v p(1,3)  access   i j s a x q(1,9)  access   k v q(1,3)  access   k v p(1,3)  access   i j e(1,3)  access
Accessing Nonlocal Data ,[object Object],[object Object],[object Object]
Parameter Passing Modes ,[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksEelco Visser
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generationIffat Anjum
 
Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Intel® Software
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in JavaRuntime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in JavaJuan Fumero
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignmentKarthi Keyan
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisEelco Visser
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronizationcscarcas
 
Code generation in Compiler Design
Code generation in Compiler DesignCode generation in Compiler Design
Code generation in Compiler DesignKuppusamy P
 

What's hot (20)

Compiler Design Unit 4
Compiler Design Unit 4Compiler Design Unit 4
Compiler Design Unit 4
 
Unit iv(simple code generator)
Unit iv(simple code generator)Unit iv(simple code generator)
Unit iv(simple code generator)
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
 
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in JavaRuntime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignment
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler unit 5
Compiler  unit 5Compiler  unit 5
Compiler unit 5
 
Pipeline
PipelinePipeline
Pipeline
 
Compiler unit 4
Compiler unit 4Compiler unit 4
Compiler unit 4
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
Code generation in Compiler Design
Code generation in Compiler DesignCode generation in Compiler Design
Code generation in Compiler Design
 
Code optimization
Code optimization Code optimization
Code optimization
 
Unit iii mca 1st year
Unit iii mca 1st yearUnit iii mca 1st year
Unit iii mca 1st year
 

Viewers also liked

Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationRamchandraRegmi
 
Threaded Awesome
Threaded AwesomeThreaded Awesome
Threaded AwesomeAman Gupta
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture NotesFellowBuddy.com
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generationIffat Anjum
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
 
code optimization
code optimization code optimization
code optimization Sanjeev Raaz
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 
How Functions Work
How Functions WorkHow Functions Work
How Functions WorkSaumil Shah
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow GraphsJenny Galino
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
Code Optimization
Code OptimizationCode Optimization
Code Optimizationguest9f8315
 

Viewers also liked (20)

Program activation records
Program activation recordsProgram activation records
Program activation records
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Run time storage
Run time storageRun time storage
Run time storage
 
Threaded Awesome
Threaded AwesomeThreaded Awesome
Threaded Awesome
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
code optimization
code optimization code optimization
code optimization
 
The Stack Frame
The Stack FrameThe Stack Frame
The Stack Frame
 
Code generator
Code generatorCode generator
Code generator
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
How Functions Work
How Functions WorkHow Functions Work
How Functions Work
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Ch5a
Ch5aCh5a
Ch5a
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Code generation
Code generationCode generation
Code generation
 

Similar to Ch7

memory_allocation_use1.ppt
memory_allocation_use1.pptmemory_allocation_use1.ppt
memory_allocation_use1.pptKanchanTiwari45
 
Continuations
ContinuationsContinuations
Continuationsopenbala
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8franciscoortin
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202Mahmoud Samir Fayed
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsashukiller7
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 

Similar to Ch7 (20)

memory_allocation_use1.ppt
memory_allocation_use1.pptmemory_allocation_use1.ppt
memory_allocation_use1.ppt
 
Continuations
ContinuationsContinuations
Continuations
 
Run time
Run timeRun time
Run time
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Os lab final
Os lab finalOs lab final
Os lab final
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
06slide.ppt
06slide.ppt06slide.ppt
06slide.ppt
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
7 functions
7  functions7  functions
7 functions
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202The Ring programming language version 1.8 book - Part 88 of 202
The Ring programming language version 1.8 book - Part 88 of 202
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
 

More from kinnarshah8888 (16)

Yuva Msp All
Yuva Msp AllYuva Msp All
Yuva Msp All
 
Yuva Msp Intro
Yuva Msp IntroYuva Msp Intro
Yuva Msp Intro
 
Ch6
Ch6Ch6
Ch6
 
Ch9c
Ch9cCh9c
Ch9c
 
Ch8a
Ch8aCh8a
Ch8a
 
Ch9b
Ch9bCh9b
Ch9b
 
Ch9a
Ch9aCh9a
Ch9a
 
Ch10
Ch10Ch10
Ch10
 
Ch3
Ch3Ch3
Ch3
 
Ch2
Ch2Ch2
Ch2
 
Ch4b
Ch4bCh4b
Ch4b
 
Ch4a
Ch4aCh4a
Ch4a
 
Ch8b
Ch8bCh8b
Ch8b
 
Ch5b
Ch5bCh5b
Ch5b
 
Ch4c
Ch4cCh4c
Ch4c
 
Ch1
Ch1Ch1
Ch1
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Ch7

  • 1. Run-Time Environments Chapter 7 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2009
  • 2.
  • 3. Procedure Activations: Example program sort(input, output) var a : array [0..10] of integer; procedure readarray; var i : integer; begin for i := 1 to 9 do read(a[i]) end; function partition(y, z : integer) : integer var i, j, x, v : integer; begin … end procedure quicksort(m, n : integer); var i : integer; begin if (n > m) then begin i := partition(m, n); quicksort(m, i - 1); quicksort(i + 1, n) end end; begin a[0] := -9999; a[10] := 9999; readarray; quicksort(1, 9) end. Activations: begin sort enter readarray leave readarray enter quicksort(1,9) enter partition(1,9) leave partition(1,9) enter quicksort(1,3) … leave quicksort(1,3) enter quicksort(5,9) … leave quicksort(5,9) leave quicksort(1,9) end sort.
  • 4. Activation Trees: Example s q(1,9) q(1,3) p(1,3) q(1,0) q(2,3) q(2,1) p(2,3) q(3,3) p(1,9) r q(5,9) p(5,9) q(5,5) q(7,9) q(7,7) p(7,9) q(9,9) Activation tree for the sort program Note: also referred to as the dynamic call graph
  • 5. Control Stack s q(1,9) q(1,3) p(1,3) q(1,0) q(2,3) p(1,9) r Activations: begin sort enter readarray leave readarray enter quicksort(1,9) enter partition(1,9) leave partition(1,9) enter quicksort(1,3) enter partition(1,3) leave partition(1,3) enter quicksort(1,0) leave quicksort(1,0) enter quicksort(2,3) … Control stack: Activation tree: s q(1,9) q(1,3) q(2,3)
  • 6.
  • 7. Mapping Names to Values name storage value environment state var i; … i := 0; … i := i + 1;
  • 8. Mapping Names to Values name storage value environment state var i; … i := 0; … i := i + 1; At compile time At run time
  • 9. Static and Dynamic Notions of Bindings Static Notion Dynamic Notion Definition of a procedure Activations of the procedure Declaration of a name Bindings of the name Scope of a declaration Lifetime of a binding
  • 10.
  • 11. Activation Records (Subroutine Frames) Caller’s responsibility to initialize Callee’s responsibility to initialize fp (frame pointer) Returned value Actual parameters Optional control link Optional access link Save machine status Local data Temporaries
  • 12. Control Links fp sp Control link Stack growth Callee’s activation record Caller’s activation record The control link is the old value of the fp
  • 13. Scope with Nested Procedures program sort(input, output) var a : array [0..10] of integer; x : integer; procedure readarray; var i : integer; begin … end; procedure exchange(i, j : integer); begin x := a[i]; a[i] := a[j]; a[j] := x end; procedure quicksort(m, n : integer); var k, v : integer; function partition(y, z : integer) : integer var i, j : integer; begin … exchange(i, j) … end begin if (n > m) then begin i := partition(m, n); quicksort(m, i - 1); quicksort(i + 1, n) end end; begin … quicksort(1, 9) end.
  • 14. Access Links (Static Links) The access link points to the activation record of the static parent procedure: s is parent of r , e , and q q is parent of p s a x q(1,9) access k v s a x q(1,9) access k v q(1,3) access k v s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j e(1,3) access
  • 15.
  • 16.