! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?
|
|
- Marcus Norris
- 5 years ago
- Views:
Transcription
1 A Binding Question! Variables are bound (dynamically) to values Subprogram Activation! Those values must be stored somewhere! Therefore, variables must somehow be bound to memory locations! How? Function Activations! The lifetime of one execution of a function, from call to corresponding return, is called an activation of the function! When each activation has its own binding of a variable to a memory locations, it is an activation-specific variable! (Also called dynamic or automatic) Block Activations! For block constructs that contain code, we can speak of an activation of the block! The lifetime of one execution of the block! A variable might be specific to an activation of a particular block within a function: int fact(int n) { if (n=0) then return 1; else return fact(n-1)*n; Other Lifetimes For Variables! Most imperative languages have a way to declare a variable that is bound to a single memory location for the entire runtime! Obvious binding solution: static allocation (classically, the loader allocates these) Scope And Lifetime Differ! In most modern languages, variables with local scope have activation-specific lifetimes, at least by default! However, these two aspects can be separated, as in C: int count = 0; int nextcount() { count = count + 1; return count; int nextcount() { static int count = 0; count = count + 1; return count;
2 Other Lifetimes For Variables! Object-oriented languages use variables whose lifetimes are associated with object lifetimes! Some languages have variables whose values are persistent: they last across multiple executions of the program! Today, we will focus on activation-specific variables Subprogram Activation! General Semantics of Calls and Returns! Implementing Subprograms! Static Local Variables and Subprograms! Stack-Dynamic Local Variables! Scope Issues - Non-local Variable Access! Dynamically Scoped Languages! Nested Subprograms Blocks Subprogram Activation! Subprogam Definition! Defines interface and actions of subprogram! Subprogram Call! Explicit request that specific subprogram be executed! Active Subprogram! Subprogram that has been called, but has not completed its execution! Application can have multiple active subprograms! Subprogram Linkage of a Language! The subprogram call and return operations Subprogram Activation! Program Linkage! Call Semantics: Save the execution status of the caller Carry out the parameter-passing process Pass the return address to the callee Transfer control to the callee! Return Semantics: For pass-by-value-result parameters move formal parameter values into corresponding actual parameters For functions move functional value to a place the caller can access it Restore the execution status of the caller Transfer control back to the caller s! Language implementations usually allocate all the activation-specific variables of a function together as an activation record! The activation record also contains other activation-specific data, such as! Return address: where to go in the program when this activation returns! Link to caller!s activation record: more about this in a moment Block s! When a block is entered, space must be found for the local variables of that block! Various possibilities:! Preallocate in the containing function!s activation record! Extend the function!s activation record when the block is entered (and revert when exited)! Allocate separate block activation records! Our illustrations will show the first option
3 Subprogram Activation! (at a minimum)! Subprogram Code! Local Variables! Parameters! Functional value (return value)! Return address!! Layout of non-code storage! Instance (ARI)! Concrete example of an activation record! Collection of data for a particular activation int fun1(float x, int y) { const int IVAL = 2; static int fval = 10; float list[4]; int n = IVAL; return 20*x+list[n]; int fun2(int a) { float b; fun1(b, a); int fun3(float r) { int s, t; s = fun2(s); int main() { float p, r; r = fun3(p);! Static Local Variables and Subprograms main() Application Stack Application Code fun1() Application Memory fun2() fun3() main ARI fun1 ARI fun2 ARI Return Address Return Value Parameters Local Variables fun3 ARI! Static Local Variables and Subprograms! Provides Fast Access and Execution All memory for application and subprograms allocated at load time Compiler can determine addresses at compile time Linker can determine all offsets at link time! Can waste memory Functions might never be called Multiple functions may need large ARI (for array) but only one will ever be active at a time! Cannot Implement Recursion Only a single instance of a subprogram may be active at a time Stacks Of s! To support recursion, we need to allocate a new activation record for each activation! Dynamic allocation: activation record allocated when function is called! For many languages, like C, it can be deallocated when the function returns! A stack of activation records: stack frames pushed on call, popped on return
4 ! Stack-Dynamic Local Variables! More Complex Implementation Compiler must generate code for implicit allocation and deallocation of local variables Recursion must be supported Adds possibility of multiple simultaneous activations mat is static but its size may be dynamic! ARI must be dynamically created when subprogram is called (invoked)! Application Memory Partitioning Static Storage Dynamic Storage Subprogram Code Segments and System Code Segments Program Memory application stack stack growth free space (available for use) heap growth application heap heap bottom Start of Stack Block Allocated by subprogram invocation End of Stack Block Allocated by new operator! Code Segment for Subprogram! Executable Subprogram Code! Subprogram int fun1(float x, int y) { const int IVAL = 2; static int fval = 10; float list[4]; int n = IVAL; return 20*x+list[n]; Information concerning the current call (invocation) of subprogram fun1 is contained in its activation record.! Code Segment for Subprogram fun1! Code produced by compiler for subprogram Prologue Executable Subprogram Code Epilogue Housekeeping code to create an activation record Executable Code for each Subprogram Statement Housekeeping code to delete the activation record Storage for Constants (reverse order)! Memory Organization During Execution! Memory Organization During Execution System Data stack chain pointer dynamic link Program (old stack Call Sequence: pointer) Return point location OpSys! main() Return Value main()! fun3() Formal Parameters fun3()! fun2() fun2()! fun1() Local Variables Temporaries for Expression Evaluation Temporaries for Parameter Transmission Subprogram Code Segments and System Code Segments Activation record storage Activation record storage Activation record storage Activation record storage Free Space application application heap heap Start of Stack Block System Data stack ARI chain of Parent pointer dynamic ARI of Caller link (old stack pointer) Old Return Prog point Counter location (PC) Return int fun1 Value Formal float Parameters x int y (reverse order) float Local Variables list[0] float list[1] float list[2] float list[3] Temporaries for Expression int n = 2 Evaluation Temporaries for Expression Temporaries for Parameter Evaluation and Parameter Transmission Transmission int fun1(float x, int y) { const int IVAL = 2; static int fval = 10; float list[4]; int n = IVAL; return 20*x+list[n];
5 ! Subprogram! Block of storage containing local objects Local variables are accessed by their offset from the beginning of the activation record (local_offset) Compiler can determine local offset of a local variable! Template! s are Dynamic! Each invocation of subprogram results in! Creation of a new activation record! Static code generated by compiler is associated with the new activation record Data Structure of Compiler binds each identifier in subprogram with a storage location offset in activation record Template is stored in Code Segment Prologue fun1 Code Segment Static Storage fun1 fun1 fun1 Dynamic Storage! s Support Recursion int fact(int x) { if (x == 1) return 1; else return x * fact(x-1); Sample Call: fact(3) Scoping Issues : Non-Local Variable Access Dynamic Chains fact() Code Segment Static Storage fact(3) fact(2) fact(1) Dynamic Storage Successive invocations of subprogram Scope and s! First - Quick Review of Scope! Dynamic scope: Scope is determined by the execution of program! Static scope: Scope is dependent on the syntax of the program! Static Nested Scope: A variable is accessible in the function it is declared in, and all procedures internal to that function, except a new declaration of that variable name in an internal function will eliminate the new variable's scope from the scope of the outer variable.! Variable declared in function is local to function Scope and s! Two pointers manage scope in AR! Pointer (DL) Points to activation record that called (invoked) the current activation record! Pointer (SL) Points to the activation record that is global (parent) to the current activation record. Activation record of the subprogram containing the declaration of this subprogram.
6 Dynamically Scoped Languages!! Points to activation record of the caller! Used for returning from the subprogram! Used to access non-locals in Dynamic Scoping! Frequently implemented as old stack pointer! Dynamic Chain! Collection of dynamic links in the stack! Call Chain Dynamically Scoped Languages () () call call call () () () Scope Sub_S Dynamically Scoped Languages () () call call call () Dynamic Chain for Dynamic Chain for Scope Sub_S Dynamically Scoped Languages! Deep Access! Nonlocal references found on dynamic chain Length of chain cannot be statically determined Every ARI must have variable names! Shallow Access! Put locals in central place! Can be one stack for each variable name! Central table with entry for each variable name Dynamically Scoped Languages Scoping Issues : Non-Local Variable Access Static Chains and Displays
7 ! Nested Subprograms! Static semantic rules guarantee that all nonlocal variables that can be referenced have been allocated in some activation record instance that is on the stack when the reference is made! Locating Nonlocal Variables! Find the correct activation record instance! Determine the correct offset within that ARI! Pointer (SL)! Points to the activation record that is global (parent) to the current activation record.! The activation record of the subprogram containing the declaration of this subprogram.! Static Chain! A chain of static links that connect hierarchically related activation record instances! Chain of static links that connects activation record instances based on static ancestors.! Static Chain! Compiler knows static structure! Chains can be generated at compile time (not run-time).! Static Depth! Number of static levels representing the nesting level of the scope of interest.! References for non-local variables are obtained by following the static chain.! Non-Local reference can be slow if static depth is large. (Consistant, but slow)! Static Chain! Chain Offset (Nesting Depth) Difference between the static depth of a reference (to a variable) and the static depth of the scope in which it was declared.! Local Offset Offset in the activation record of the refernced variable.! Reference Pairs for Nonlocal Variables (chain_offset, local_offset) () () call call call () () () Scope Sub_S and exist, but not within static scope of SubS() () () call call call () () () Scope Sub_S
8 () () call call call () Static Chain for Dynamic Chain for Static Chain for Dynamic Chain for! Static Chain Maintenance! Build! is the old! is most recent ARI of static parent Search the dynamic chain until the first ARI for the static parent is found--easy, but slow Store Nesting Depth from Definition to Caller Transit Caller Static Chain to appropriate depth! Issues with Static Chain! Slow nonlocal reference if the number of scopes between reference and declaration is large! Time-critical code is difficult to verify Costs of nonlocal references are not equal Costs can an change with code upgrades and fixes Static Scope and Displays! Displays! Place static links in a separate stack that is part of the activation record. Previous level!s activation record!s display is copied and a pointer to the new activation record is pushed.! Entries are direct links to activation records of declarations.! Display Reference Pairs (display_offset, local_offset) Display Offset is same as Chain Offset Static Scope and Displays! Reference Mechanics:! Use display offset to get pointer to activation record of interest! Use local offset to get to the variable within that particular activation record.! Always a two-step process, independent of static nesting depth! Display can be kept in registers! If there are enough! Speeds up access and maintenance Static Scope and Displays! Comparing Static Chain and Display! References to locals Not much difference! References to nonlocals If it is one level away, they are equal If it is farther away, the display is faster! Display is better for time-critical code All nonlocal references cost the same
9 Static Scope and Displays! Subprogram Calls! One or two levels of depth, static chain is faster! Greater than two levels, display is faster! Subprogram Returns! Both have fixed time, but the static chain is slightly faster! Static chain is better, unless the display can be kept in registers Blocks! Code Blocks can define local scoping! Implementation can vary! Treat blocks as parameterless subprograms Use activation records! Allocate locals in the subprogram ARI { int temp = x; x = y; y = temp;
Chapter 10. Implementing Subprograms
Chapter 10 Implementing Subprograms Chapter 10 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables Nested Subprograms
More informationChapter 9. Def: The subprogram call and return operations of a language are together called its subprogram linkage
Def: The subprogram call and return operations of a language are together called its subprogram linkage Implementing FORTRAN 77 Subprograms Call Semantics: 1. Save the execution status of the caller 2.
More information12/4/18. Outline. Implementing Subprograms. Semantics of a subroutine call. Storage of Information. Semantics of a subroutine return
Outline Implementing Subprograms In Text: Chapter 10 General semantics of calls and returns Implementing simple subroutines Call Stack Implementing subroutines with stackdynamic local variables Nested
More informationImplementing Subroutines. Outline [1]
Implementing Subroutines In Text: Chapter 9 Outline [1] General semantics of calls and returns Implementing simple subroutines Call Stack Implementing subroutines with stackdynamic local variables Nested
More informationImplementing Subprograms
1 Implementing Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University CS315 Programming Languages Pinar Duygulu The General Semantics of Calls and Returns 2 The subprogram call and return
More informationChapter 10. Implementing Subprograms ISBN
Chapter 10 Implementing Subprograms ISBN 0-321-33025-0 Chapter 10 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables
More informationChapter 10 Implementing Subprograms
Chapter 10 Implementing Subprograms The General Semantics of Calls and Returns - Definition: The subprogram call and return operations of a language are together called its subprogram linkage Implementing
More informationSubprograms. Copyright 2015 Pearson. All rights reserved. 1-1
Subprograms Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments Parameter-Passing Methods Parameters That Are Subprograms Calling Subprograms Indirectly
More informationProgramming Languages: Lecture 12
1 Programming Languages: Lecture 12 Chapter 10: Implementing Subprograms Jinwoo Kim jwkim@jjay.cuny.edu Chapter 10 Topics 2 The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter
More informationPrinciples of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004
Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 CS 314, LS,BR,LTM: Scope and Memory 1 Review Functions as first-class objects What can you do with an integer?
More informationImplementing Subprograms
Implementing Subprograms 1 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables Nested Subprograms Blocks Implementing
More informationG Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing
More informationRun-time Environments - 2
Run-time Environments - 2 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of the Lecture n What is run-time
More informationScope, Functions, and Storage Management
Scope, Functions, and Storage Management Implementing Functions and Blocks cs3723 1 Simplified Machine Model (Compare To List Abstract Machine) Registers Code Data Program Counter (current instruction)
More informationExample. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; :
Runtime Environment Relationship between names and data objects (of target machine) Allocation & de-allocation is managed by run time support package Each execution of a procedure is an activation of the
More informationCSE 504: Compiler Design. Runtime Environments
Runtime Environments Pradipta De pradipta.de@sunykorea.ac.kr Current Topic Procedure Abstractions Mechanisms to manage procedures and procedure calls from compiler s perspective Runtime Environment Choices
More informationRun-Time Environments
1 Run-Time Environments Chapter 7 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2011 2 Procedure Activation and Lifetime A procedure is activated when called
More informationSeparate compilation. Topic 6: Runtime Environments p.1/21. CS 526 Topic 6: Runtime Environments The linkage convention
Runtime Environment The Procedure Abstraction and Separate Compilation Topics we will cover The procedure abstraction and linkage conventions Runtime storage convention Non-local data access (brief) These
More informationProcedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End
COMP 412 FALL 2017 Procedure and Function Calls, Part II Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationProcedure and Object- Oriented Abstraction
Procedure and Object- Oriented Abstraction Scope and storage management cs5363 1 Procedure abstractions Procedures are fundamental programming abstractions They are used to support dynamically nested blocks
More informationConcepts Introduced in Chapter 7
Concepts Introduced in Chapter 7 Storage Allocation Strategies Static Stack Heap Activation Records Access to Nonlocal Names Access links followed by Fig. 7.1 EECS 665 Compiler Construction 1 Activation
More informationCA Compiler Construction
CA4003 - Compiler Construction David Sinclair When procedure A calls procedure B, we name procedure A the caller and procedure B the callee. A Runtime Environment, also called an Activation Record, is
More informationThe Procedure Abstraction
The Procedure Abstraction Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures
More informationTopic 7: Activation Records
Topic 7: Activation Records Compiler Design Prof. Hanjun Kim CoreLab (Compiler Research Lab) POSTECH 1 Storage Organization Stack Free Memory Heap Static Code 2 ELF file format example Executable Object
More informationRun Time Environment. Procedure Abstraction. The Procedure as a Control Abstraction. The Procedure as a Control Abstraction
Procedure Abstraction Run Time Environment Records Procedure Linkage Name Translation and Variable Access Copyright 2010, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at
More informationRun-time Environments
Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction
More informationRun-time Environments
Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction
More informationRun-Time Environments
CS308 Run-Time Environments Li Jiang Department of Computer Science and Engineering Shanghai Jiao Tong University Current Progress Source Language Lexical Analyzer Syntax Analyzer Semantic Analyzer Intermediate
More informationRun-Time Data Structures
Run-Time Data Structures Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers, it is used for:
More informationRun Time Environments
Run Time Environments ALSU Textbook Chapter 7.1 7.3 Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Preliminaries During the execution of a program, the same name in the source
More informationSystem Software Assignment 1 Runtime Support for Procedures
System Software Assignment 1 Runtime Support for Procedures Exercise 1: Nested procedures Some programming languages like Oberon and Pascal support nested procedures. 1. Find a run-time structure for such
More informationImplementing Subprograms
Implementing Subprograms In Text: Chapter 10 Slide 1 Implementing Subprograms Call - Save registers - provide storage for parameters - provide storage for locals - save execution status of caller - provide
More informationUNIT 3
UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment
More informationCompilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1
Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for
More informationTHEORY OF COMPILATION
Lecture 10 Activation Records THEORY OF COMPILATION EranYahav www.cs.technion.ac.il/~yahave/tocs2011/compilers-lec10.pptx Reference: Dragon 7.1,7.2. MCD 6.3,6.4.2 1 You are here Compiler txt Source Lexical
More informationModule 27 Switch-case statements and Run-time storage management
Module 27 Switch-case statements and Run-time storage management In this module we will discuss the pending constructs in generating three-address code namely switch-case statements. We will also discuss
More informationRuntime Environments I. Basilio B. Fraguela
Runtime Environments I Basilio B. Fraguela Runtime System Responsibilities Allocation of storage for program data Sometimes also deallocation Garbage collection Management of data structures the compiled
More informationChapter 9 Subroutines and Control Abstraction. June 22, 2016
Chapter 9 Subroutines and Control Abstraction June 22, 2016 Stack layout Common to have subroutine activation record allocated on a stack Typical fare for a frame: arguments, return value, saved registers,
More informationRun Time Environment. Activation Records Procedure Linkage Name Translation and Variable Access
Run Time Environment Activation Records Procedure Linkage Name Translation and Variable Access Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University
More informationCSE 504. Expression evaluation. Expression Evaluation, Runtime Environments. One possible semantics: Problem:
Expression evaluation CSE 504 Order of evaluation For the abstract syntax tree + + 5 Expression Evaluation, Runtime Environments + + x 3 2 4 the equivalent expression is (x + 3) + (2 + 4) + 5 1 2 (. Contd
More informationThe basic operations defined on a symbol table include: free to remove all entries and free the storage of a symbol table
SYMBOL TABLE: A symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating
More informationCompilers and Code Optimization EDOARDO FUSELLA
Compilers and Code Optimization EDOARDO FUSELLA Contents Data memory layout Instruction selection Register allocation Data memory layout Memory Hierarchy Capacity vs access speed Main memory Classes of
More informationLecture #16: Introduction to Runtime Organization. Last modified: Fri Mar 19 00:17: CS164: Lecture #16 1
Lecture #16: Introduction to Runtime Organization Last modified: Fri Mar 19 00:17:19 2010 CS164: Lecture #16 1 Status Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces
More informationBinding and Storage. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill
Binding and Storage Björn B. Brandenburg The University of North Carolina at Chapel Hill Based in part on slides and notes by S. Olivier, A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts. What s
More informationRuntime management. CS Compiler Design. The procedure abstraction. The procedure abstraction. Runtime management. V.
Runtime management CS3300 - Compiler Design Runtime management V Krishna Nandivada IIT Madras Copyright c 2001 by Antony L Hosking Permission to make digital or hard copies of part or all of this work
More informationLecture 11: Subprograms & their implementation. Subprograms. Parameters
Lecture 11: Subprograms & their implementation Subprograms Parameter passing Activation records The run-time stack Implementation of static and dynamic scope rules Subprograms A subprogram is a piece of
More informationCompilation /15a Lecture 7. Activation Records Noam Rinetzky
Compilation 0368-3133 2014/15a Lecture 7 Activation Records Noam Rinetzky 1 Code generation for procedure calls (+ a few words on the runtime system) 2 Code generation for procedure calls Compile time
More informationChapter 5. Names, Bindings, and Scopes
Chapter 5 Names, Bindings, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Scope Scope and Lifetime Referencing Environments Named Constants 1-2 Introduction Imperative
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level
More informationRun-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13
Run-time Environments Lecture 13 by Prof. Vijay Ganesh) Lecture 13 1 What have we covered so far? We have covered the front-end phases Lexical analysis (Lexer, regular expressions,...) Parsing (CFG, Top-down,
More informationNaming in OOLs and Storage Layout Comp 412
COMP 412 FALL 2018 Naming in OOLs and Storage Layout Comp 412 source IR IR target Front End Optimizer Back End Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in
More informationAn Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables
Activation Records The storage (for formals, local variables, function results etc.) needed for execution of a subprogram is organized as an activation record. An Activation Record for Simple Subprograms.
More informationSpecial Topics: Programming Languages
Lecture #17 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 17 Lecture #17 1 Slide 1 Runtime Representations Variable Names Environment L-values Scope, Extent
More informationCS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11
CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Spring 2015 1 Handling Overloaded Declarations Two approaches are popular: 1. Create a single symbol table
More informationTypical Runtime Layout. Tiger Runtime Environments. Example: Nested Functions. Activation Trees. code. Memory Layout
Tiger Runtime Environments Compile-time environments are just symbol tables; they are used to assist static semantic analysis, code generation and code optimization. Run-time environments are about how
More informationCompiler Theory. (Semantic Analysis and Run-Time Environments)
Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful
More informationRun-Time Environements
Run-Time Environements Martin Sulzmann Martin Sulzmann Run-Time Environements 1 / 21 Overview Things to consider Static program code versus dynamic procedure activation. First-order functions (C). Nested
More informationInformatica 3 Marcello Restelli
Informatica 3 Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Operational Semantics We describe the semantics of a programming language by means of an abstract semantic
More informationCS 480 Fall Runtime Environments. Mike Lam, Professor. (a.k.a. procedure calls and heap management)
CS 480 Fall 2015 Mike Lam, Professor Runtime Environments (a.k.a. procedure calls and heap management) Subprograms General characteristics Single entry point Caller is suspended while subprogram is executing
More informationObject Oriented Paradigm Languages
Object Oriented Paradigm Languages The central design goal is to build inherent abstraction into the system, moving all the abstract implementation details from the user level (ad-hoc) to the system level
More informationRun-time Environment
Run-time Environment Prof. James L. Frankel Harvard University Version of 3:08 PM 20-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Storage Organization Automatic objects are
More informationProgramming Languages Third Edition. Chapter 10 Control II Procedures and Environments
Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing
More informationCS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Procedure Abstractions These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Where are we? Well understood Engineering Source Code
More informationCSE 307: Principles of Programming Languages
1 / 26 CSE 307: Principles of Programming Languages Names, Scopes, and Bindings R. Sekar 2 / 26 Topics Bindings 1. Bindings Bindings: Names and Attributes Names are a fundamental abstraction in languages
More informationPrinciples of Programming Languages
Principles of Programming Languages Lecture 06 Implementation of Block Structured Languages 1 Activations and Environment Aspects of Subroutines: Static vs Dynamic! Static subroutine: code (``reentrant
More informationMemory Management and Run-Time Systems
TDDD55 Compilers and Interpreters TDDB44 Compiler Construction Memory Management and Run-Time Systems Part of the Attribute Grammar Material Presented at the Beginning of this Lecture Peter Fritzson IDA,
More informationCIT Week13 Lecture
CIT 3136 - Week13 Lecture Runtime Environments During execution, allocation must be maintained by the generated code that is compatible with the scope and lifetime rules of the language. Typically there
More informationToday's Topics. CISC 458 Winter J.R. Cordy
Today's Topics Last Time Semantics - the meaning of program structures Stack model of expression evaluation, the Expression Stack (ES) Stack model of automatic storage, the Run Stack (RS) Today Managing
More informationLecture08: Scope and Lexical Address
Lecture08: Scope and Lexical Address Free and Bound Variables (EOPL 1.3.1) Given an expression E, does a particular variable reference x appear free or bound in that expression? Definition: A variable
More informationFunctions and Procedures
Functions and Procedures Function or Procedure A separate piece of code Possibly separately compiled Located at some address in the memory used for code, away from main and other functions (main is itself
More informationChapter 9 :: Subroutines and Control Abstraction
Chapter 9 :: Subroutines and Control Abstraction Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter09_Subroutines_and_Control_Abstraction_4e - Tue November
More informationRuntime Support for Algol-Like Languages Comp 412
COMP 412 FALL 2018 Runtime Support for Algol-Like Languages Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students
More informationThe Procedure Abstraction Part I: Basics
The Procedure Abstraction Part I: Basics Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing
More informationCOP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Robert van Engelen Overview Abstractions and names Binding time Object lifetime Object storage management Static allocation Stack allocation
More informationLecture 7: Binding Time and Storage
Lecture 7: Binding Time and Storage COMP 524 Programming Language Concepts Stephen Olivier February 5, 2009 Based on notes by A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts Goal of Lecture The
More informationProgramming Languages Third Edition. Chapter 7 Basic Semantics
Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol
More informationLecture 9: Procedures & Functions. CS 540 George Mason University
Lecture 9: Procedures & Functions CS 540 George Mason University Procedures/Functions Control Abstraction call/return semantics, parameters, recursion Controlled Namespace Scope (local/non-local), binding,
More informationTopic 3-a. Calling Convention 2/29/2008 1
Topic 3-a Calling Convention 2/29/2008 1 Calling Convention Calling convention is a standardized method for a program to pass parameters to a procedure and receive result values back from it. 2/29/2008
More informationCS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri
CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:
More informationWhat about Object-Oriented Languages?
What about Object-Oriented Languages? What is an OOL? A language that supports object-oriented programming How does an OOL differ from an ALL? (ALGOL-Like Language) Data-centric name scopes for values
More informationImperative Programming
Naming, scoping, binding, etc. Instructor: Dr. B. Cheng Fall 2004 1 Imperative Programming The central feature of imperative languages are variables Variables are abstractions for memory cells in a Von
More information6. Names, Scopes, and Bindings
Copyright (C) R.A. van Engelen, FSU Department of Computer Science, 2000-2004 6. Names, Scopes, and Bindings Overview Names Binding time Object lifetime Object storage management Static allocation Stack
More informationNames, Bindings, Scopes
Names, Bindings, Scopes Variables In imperative l Language: abstractions of von Neumann machine Variables: abstraction of memory cell or cells Sometimes close to machine (e.g., integers), sometimes not
More informationOptimizer. Defining and preserving the meaning of the program
Where are we? Well understood Engineering Source Code Front End IR Optimizer IR Back End Machine code Errors The latter half of a compiler contains more open problems, more challenges, and more gray areas
More informationChapter 3:: Names, Scopes, and Bindings
Chapter 3:: Names, Scopes, and Bindings Programming Language Pragmatics Michael L. Scott Some more things about NFAs/DFAs We said that a regular expression can be: A character (base case) A concatenation
More informationLECTURE 19. Subroutines and Parameter Passing
LECTURE 19 Subroutines and Parameter Passing ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments behind a simple name. Data abstraction: hide data
More informationAttributes of Variable. Lecture 13: Run-Time Storage Management. Lifetime. Value & Location
Attributes of Variable Lecture 13 Run-Time Storage Management CSC 131 Kim Bruce Scope Lifetime Location Value Done! Lifetime Value & Location FORTRAN - all allocated statically - Stack-based (C/C++/Java/Pascal/...)
More informationProcedures and Run-Time Storage
Procedures and Run-Time Storage Compiler Design CSE 504 1 Parameterless Procedures 2 Parameter Passing 3 Storage Organization Last modifled: Mon Mar 21 2016 at 12:11:19 EDT Version: 1.3 20:58:09 2012/04/09
More informationCSE 3302 Notes 5: Memory Management
CSE 0 Notes 5: Memory Management (Last updated 10/7/15 1:6 PM) References: Gabbrielli-Martini: 5 Wirth: 4 5.1. IMPLEMENTING SIMPLE SUBPROGRAMS Historical FORTRAN and COBOL Simple = no recursion static
More informationRun-time Environments - 3
Run-time Environments - 3 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of the Lecture n What is run-time
More informationThe Activation Record (AR)
The Activation Record (AR) [Notes adapted from R. Bodik] Code for function calls and function definitions depends on the layout of the activation record Very simple AR suffices for this language: The result
More informationCS 314 Principles of Programming Languages
CS 314 Principles of Programming Languages Lecture 13: Names, Scopes and Bindings Zheng (Eddy) Zhang Rutgers University February 28, 2018 Review: Names, Scopes and Binding What s in a name? Each name means
More informationSubroutines and Control Abstraction. CSE 307 Principles of Programming Languages Stony Brook University
Subroutines and Control Abstraction CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Subroutines Why use subroutines? Give a name to a task. We
More informationThe Procedure Abstraction Part I Basics
The Procedure Abstraction Part I Basics Procedure Abstraction The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures Procedures
More informationProcedures and Run-Time Storage
Procedures and Run-Time Storage Compiler Design CSE 504 1 Parameterless Procedures 2 Parameter Passing 3 Storage Organization Last modifled: Mon Mar 21 2016 at 12:11:19 EDT Version: 1.3 20:58:09 2012/04/09
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationNames and Abstractions: What s in a Name?
Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Names, Scopes, and Bindings Binding time Object lifetime Object storage management Static allocation Stack allocation Heap allocation
More informationMidterm II CS164, Spring 2006
Midterm II CS164, Spring 2006 April 11, 2006 Please read all instructions (including these) carefully. Write your name, login, SID, and circle the section time. There are 10 pages in this exam and 4 questions,
More informationProgramming Languages Semantics
Programming Languages Semantics The semantics of a program describe its meaning. This can be done formally (operational, axiomatic, & denotational semantics; see [Sebesta 96]) or informally. I. Control
More information