Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1
|
|
- Blaze Fox
- 6 years ago
- Views:
Transcription
1 Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1
2 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for cooperation with it The run-time environment communicates with the operating system and maybe with the hardware Main tasks Storage management Handling of run-time errors Provide information for symbolic debugging Real Time (RTD) resp. Post Mortem Debugger (PMD) Hardware extensions Emulated instructions, virtual registers Laszlo Böszörmenyi Compilers Run-time - 2
3 Design questions for imperative languages Are procedures recursive? Are functions (procedures returning a value) supported? What should happen with local names (variables) of a procedure after return? Can non-local names be referenced? What kind of parameter passing modes and return-types are supported? Can be procedures passed as parameters or returned as a function value? Is dynamic memory management desirable? Is unused memory to be de-allocated explicitly or is a garbage-collector required? further questions for not procedure-oriented languages Laszlo Böszörmenyi Compilers Run-time - 3
4 Kinds of Storage Static storage Code (immutable) Static instance (or module) variables Semi-dynamic storage (stack) Allocated on procedure activation and de-allocated on return Dynamic storage (heap) Storage allocated explicitly at run time E.g. new in Java, malloc in C De-allocated explicitly E.g. free in C Or implicitly, e.g. in Java and C# By a garbage collector Code Static Data Heap free Stack Usual subdivison of run-time memory Heap and stack may be co-managed by a VMM Laszlo Böszörmenyi Compilers Run-time - 4
5 Activation Tree and Control Stack The activation tree describes the flow of control over the procedure call-chains 1. Each call is represented by a node 2. The root represents the activation of the main procedure 3. Node a is a parent of b iff the flow of control goes from a to b (a is calling b) 4. Node a is to the left to b iff a terminates before b Control-Stack That set of the active procedures of a call-chain Push at call (activation) Pop at return Laszlo Böszörmenyi Compilers Run-time - 5
6 Sketch of Quicksort class sort { int Arr[11]; // Array to be sorted: Arr[1].. Arr[9] void readarray (); { int i; } // Reads 9 integers in Arr[i]; 1 i 9 // Let assume: < Arr[i] < 9999 int partition (int m, int n); { // Partitions Arr[m..n] over a separator value V: } // Arr[m..p-1] < V and Arr[p+1..n] V; returns p void quicksort (int m, int n); { int i; if (n > m) // As long not sorted (left-right partitions distinct) i = partition(m, n); // Partition quicksort(m, i-1); // Call quicksort recursively on the left quicksort(i+1, n) // and on the right partition } } main () { readarray(); // Initialize Arr Arr[0] := -9999; Arr[10] := 9999; // Sentinel values (accelerate tests) (- and + ) quicksort(1, 9) // Initial call of quicksort on 9 elements } // class sort Laszlo Böszörmenyi Compilers Run-time - 6
7 Activation tree and control stack for quicksort Activation tree Control stack at q(2,3) Laszlo Böszörmenyi Compilers Run-time - 7
8 Activation record of a procedure At call: push activation record 1. Reserve place for return values If not returned in a register 2. Push actual parameters 3. Push actual status (registers) Temporary results of an expression 4. Push return address PC (program counter) 5. Set access (static) link Points to surrounding scope 6. Set control (dynamic) link Points to the caller s local data 7. Local and temporary variables Variable-length data: indirection: A pointer to stack or heap On return: pop in similar steps push C a ll e r C a ll e e Set by callee Returned values Actual parameters Saved status Return address static link dynamic link Local variables Temp. variables Laszlo Böszörmenyi Compilers Run-time - 8
9 Stack of activation records - Example Code for readarray Code for partition Code for quicksort Code for main Control stack at q(2,3) Arr[0].. Arr[10] parameter m: 1 parameter n: 9 status local variable i parameter m: 1 parameter n: 3 status local variable i parameter m: 2 parameter n: 3 status local variable i Laszlo Böszörmenyi Compilers Run-time - 9
10 Scoping Names are valid in a certain scope Static scoping The validity area is defined by the place in program text Nested block can access outer names (via access link) Dynamic scoping Validity is defined by actual state of variables Dynamic binding of a variable to a type e.g. class membership E.g. ((Student)person).matrNum valid, if person is instance of Student Mapping of names of variables to storage areas The compiler generates relative addresses (offsets) Run-time environment maps these to storage address During execution values are assigned to variables Name Offset Storage Value XYZ (int XYZ:= 25) Laszlo Böszörmenyi Compilers Run-time - 10
11 Static (lexical scoping) program sort(input, output); n = 0 var Arr : array [1.. 10] of integer; x: integer; procedure readarray; n = 1 var i: integer; begin Arr end {readarray} ; procedure exchange (i, j: integer); n = 1 begin x := Arr[i]; Arr[i] : = Arr[j]; Arr[j] := x end {exchange}; procedure quicksort(m, n: integer); n = 1 var k, v : integer; function partition(y, z: integer): integer; n = 2 var i, j : integer ; begin k, v,. exchange(i, j); end {partition} ; begin... end {quicksort} ; n: nesting begin end {sort}. level Which k and v? Arr[1].. Arr[10] x q(1, 9) access link k, v (1,9) q(1, 3) access link k, v (1,3) p(1, 3) access link i,j e(1, 3) access link Points to the valid set of q s locals Laszlo Böszörmenyi Compilers Run-time - 11 X
12 Fast static scoping (Display) Display d[i] points to the actual activation record at nesting level i Nesting level known at compilation Fast, but predefined length of d At call of a procedure Store d[i] in the activation record Let d[i] point to the new activation record Before returning Restore d[i] d[0] d[1] d[2] null Arr[1].. Arr[10] x q(1, 9) saved d[1] k, v (1,9) q(1, 3) saved d[1] k, v (1,3) p(1, 3) saved d[2] i,j e(1, 3) saved d[1] Laszlo Böszörmenyi Compilers Run-time - 12
13 Parameter passing modes Call by value 1. Value of actual parameter is computed 2. Value is assigned to formal parameter As an initialized local variable Call by reference The address of the actual parameter is passed Assignment to the formal parameter effects the act. par. Call by name (textual replacement, as a macro ) Out-dated mode Copy restore (used in remote procedure calls) Call by value and use locally Before return assign formal par. to act. par. Laszlo Böszörmenyi Compilers Run-time - 13
14 Parameter passing - Examples VAR i: INTEGER; a: ARRAY [1.. 2] of INTEGER; PROCEDURE P (x: INTEGER); BEGIN i := i + 1; x := x + 2; END P;... BEGIN a[1] := 10; a[2] := 20; i := 1; P(a[i]) (* P (VAR x: INTEGER);*) a[1]: 10 a[2]: 20 Call by value: a = (10, 20) Call by reference: a = (12, 20) Call by name: a = (10, 22) Copy restore: a = (12, 20) (same as ref. not always!) Laszlo Böszörmenyi Compilers Run-time - 14
15 Dynamic Storage Allocation Explicit allocation of variable-length blocks External (global) fragmentation Allocation methods First-fit (fast), Best-fit, Worst-fit Explicit allocation of fixed-length blocks Continuous runs for large areas Internal fragmentation Compromise: Buddy algorithm Variable length of blocks is limited to power of 2 Virtual memory management solves fragmentation Fixed-length blocks, linked together with hardware support Laszlo Böszörmenyi Compilers Run-time - 15
16 Garbage Collection Explicit de-allocation is error-prone Memory leaks Memory never released Bad in server code Dangling references Pointing at released memory very bad! Java, C#, Modula-3, ML, Prolog use g.c. Difficulties Careful memory usage Avoid too long pause Tree in use p q List unused r Laszlo Böszörmenyi Compilers Run-time - 16
17 Reachability of Data Root set Data accessed directly, without a pointer E.g. in Java the static field members + stack The root set is always reachable Transitive (recursive) reachability Data that can be reached via the reachable set is reachable Set of reachable data changes at Object allocations Parameter passing and return values Reference assignments Procedure returns Laszlo Böszörmenyi Compilers Run-time - 17
18 Mark and Sweep Mark all reachable data function DFS(x) if x is a pointer pointing to the heap if record x is not marked Mark x for each field fi of record x DFS(x.fi) Sweep: release all unmarked data p:= first address in heap while p < last address in heap if record p is marked unmark p else let f1 be the first word of p (* is unused, because free! *) p.f1:= freelist; (* set p on the freelist:= p; front of the free list *) p:= p + (size of record p) Laszlo Böszörmenyi Compilers Run-time - 18
19 Let be Price for mark and sweep H: Heap size R: Size of all reachable blocks C1,C2: Number of required instructions for mark resp. sweep Cost = (C1*R + C2*H) / (H R) (usually C1 > C2) If H >> R (which is desirable): Cost ~ C2 If H >> R not true Try to get memory from the operating system Problem of the recursive algorithm Depth of recursion could be H in the worst case! Stack must be rather built explicitly on the heap itself Traversed record points back to predecessor (pointer reversal) On return, the reversed pointers have to reset (reversed again) Needs only a few additional variables for the management Laszlo Böszörmenyi Compilers Run-time - 19
20 Mark and Sweep - Example Laszlo Böszörmenyi Compilers Run-time - 20
21 Reference counting Each memory block has a reference counter If a new reference to the block is set: increment If a reference is deleted: decrement If reference counter == 0, the block is garbage Assignments must be tracked p:= q p prev.refc--; q.refc++ Makes code slow With data flow analysis Counter ops can be reduced Complex task in compiler Cycles remain undetected p q 2 3 ref. counter p q 1 4 Laszlo Böszörmenyi Compilers Run-time - 21
22 Copying collectors Memory is partitioned into 2 semispaces A and B Memory is allocated in A If end reached Used blocks are copied into B A is now fully free Role of A and B swaps after each run Disadvantage Half of the memory remains unused Addresses must be changed at run-time Especially bad, if memory address is used as a hash value (e.g. in legacy C code) Laszlo Böszörmenyi Compilers Run-time - 22
23 Short-Pause Garbage Collection Simple gc stops the world Especially bad for real-time applications E.g. during watching a movie Partial collection We collect only a little bit Generational garbage collection Many generations of memory areas Only the oldest generation is collected Very efficient, if not too much cross-generation references exist Incremental collection The reachability analysis is broken into small pieces The collector may oversee garbage But must never collect non-garbage! Typically runs in an own thread in the background Laszlo Böszörmenyi Compilers Run-time - 23
Run-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 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 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 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 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 informationCS 345. Garbage Collection. Vitaly Shmatikov. slide 1
CS 345 Garbage Collection Vitaly Shmatikov slide 1 Major Areas of Memory Static area Fixed size, fixed content, allocated at compile time Run-time stack Variable size, variable content (activation records)
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 informationRun-Time Environments/Garbage Collection
Run-Time Environments/Garbage Collection Department of Computer Science, Faculty of ICT January 5, 2014 Introduction Compilers need to be aware of the run-time environment in which their compiled programs
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 informationIntermediate Representations & Symbol Tables
Intermediate Representations & Symbol Tables Copyright 2014, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission
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 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 informationManual Allocation. CS 1622: Garbage Collection. Example 1. Memory Leaks. Example 3. Example 2 11/26/2012. Jonathan Misurda
Manual llocation Dynamic memory allocation is an obvious necessity in a programming environment. S 1622: Garbage ollection Many programming languages expose some functions or keywords to manage runtime
More information! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?
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
More informationRuntime. The optimized program is ready to run What sorts of facilities are available at runtime
Runtime The optimized program is ready to run What sorts of facilities are available at runtime Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis token stream Syntactic
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 informationCompiler Construction
Compiler Construction Lecture 18: Code Generation V (Implementation of Dynamic Data Structures) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/
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 informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:
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 informationLecture 13: Garbage Collection
Lecture 13: Garbage Collection COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer/Mikkel Kringelbach 1 Garbage Collection Every modern programming language allows programmers
More informationWeeks 6&7: Procedures and Parameter Passing
CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45
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 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 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 informationAutomatic Memory Management
Automatic Memory Management Why Automatic Memory Management? Storage management is still a hard problem in modern programming Why Automatic Memory Management? Storage management is still a hard problem
More informationAcknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides
Garbage Collection Last time Compiling Object-Oriented Languages Today Motivation behind garbage collection Garbage collection basics Garbage collection performance Specific example of using GC in C++
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 information6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare.
6.172 Performance Engineering of Software Systems Spring 2009 Lecture 9 MIT OpenCourseWare Dynamic Storage Allocation Stack allocation: LIFO (last-in-first-out) Array and pointer A used unused P before
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 informationNOTE: Answer ANY FOUR of the following 6 sections:
A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)
More informationMotivation for Dynamic Memory. Dynamic Memory Allocation. Stack Organization. Stack Discussion. Questions answered in this lecture:
CS 537 Introduction to Operating Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is
More informationRun-time Environments -Part 3
Run-time Environments -Part 3 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Outline of the Lecture Part 3 What is run-time support?
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 - Spring 2013 1 Memory Attributes! Memory to store data in programming languages has the following lifecycle
More informationProgramming Language Implementation
A Practical Introduction to Programming Language Implementation 2014: Week 10 Garbage Collection College of Information Science and Engineering Ritsumeikan University 1 review of last week s topics dynamic
More informationHeap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008.
Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008. Outline. Dynamic Allocation. Variables and Constants. Aliases and Problems. Garbage. Introduction. On Wednesday, we were talking
More informationRun Time Environment
CS 403 Compiler Construction Lecture 12 Run Time Environment and Management [Based on Chapter 7 of Aho2] 1 Run Time Environment From Lecture 1 to 11, we have seen many jobs that are done by a compiler.
More informationDesign Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8
Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns
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 informationCS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers
CS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers Heap allocation is a necessity for modern programming tasks, and so is automatic reclamation of heapallocated memory. However,
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 informationGarbage Collection Algorithms. Ganesh Bikshandi
Garbage Collection Algorithms Ganesh Bikshandi Announcement MP4 posted Term paper posted Introduction Garbage : discarded or useless material Collection : the act or process of collecting Garbage collection
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 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 informationSustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)
COMP 412 FALL 2017 Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) Copyright 2017, Keith D. Cooper & Zoran Budimlić, all rights reserved. Students enrolled in Comp 412 at Rice
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 Spring 2017 1 Memory Attributes Memory to store data in programming languages has the following lifecycle
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 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 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 informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4303 April 9, 2010 14.00-15.30 This exam (6 pages) consists of 52 True/False
More informationCMSC 330: Organization of Programming Languages. Memory Management and Garbage Collection
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC330 Fall 2018 1 Memory Attributes Memory to store data in programming languages has the following lifecycle
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 informationImplementation Garbage Collection
CITS 3242 Programming Paradigms Part IV: Advanced Topics Topic 19: Implementation Garbage Collection Most languages in the functional, logic, and object-oriented paradigms include some form of automatic
More informationManaged runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley
Managed runtimes & garbage collection CSE 6341 Some slides by Kathryn McKinley 1 Managed runtimes Advantages? Disadvantages? 2 Managed runtimes Advantages? Reliability Security Portability Performance?
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 informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #6: Memory Management CS 61C L06 Memory Management (1) 2006-07-05 Andy Carle Memory Management (1/2) Variable declaration allocates
More informationMemory Management. Memory Management... Memory Management... Interface to Dynamic allocation
CSc 453 Compilers and Systems Software 24 : Garbage Collection Introduction Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2009 Christian Collberg Dynamic Memory Management
More informationHeap Management. Heap Allocation
Heap Management Heap Allocation A very flexible storage allocation mechanism is heap allocation. Any number of data objects can be allocated and freed in a memory pool, called a heap. Heap allocation is
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 informationOlder geometric based addressing is called CHS for cylinder-head-sector. This triple value uniquely identifies every sector.
Review: On Disk Structures At the most basic level, a HDD is a collection of individually addressable sectors or blocks that are physically distributed across the surface of the platters. Older geometric
More informationManaged runtimes & garbage collection
Managed runtimes Advantages? Managed runtimes & garbage collection CSE 631 Some slides by Kathryn McKinley Disadvantages? 1 2 Managed runtimes Portability (& performance) Advantages? Reliability Security
More informationCPSC 213. Introduction to Computer Systems. Winter Session 2017, Term 2. Unit 1c Jan 24, 26, 29, 31, and Feb 2
CPSC 213 Introduction to Computer Systems Winter Session 2017, Term 2 Unit 1c Jan 24, 26, 29, 31, and Feb 2 Instance Variables and Dynamic Allocation Overview Reading Companion: Reference 2.4.4-5 Textbook:
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 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 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 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 informationQualifying Exam in Programming Languages and Compilers
Qualifying Exam in Programming Languages and Compilers University of Wisconsin Fall 1991 Instructions This exam contains nine questions, divided into two parts. All students taking the exam should answer
More informationNames, Scopes, and Bindings. CSE 307 Principles of Programming Languages Stony Brook University
Names, Scopes, and Bindings CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Names, Scopes, and Bindings Names are identifiers (mnemonic character
More informationMemory Management. Didactic Module 14 Programming Languages - EEL670 1
Memory Management Didactic Module 14 Programming Languages - EEL670 1 Dynamic Memory Allocation Lots of things need memory at runtime: Activation records Objects Explicit allocations: new, malloc, etc.
More informationMemory Management. Chapter Fourteen Modern Programming Languages, 2nd ed. 1
Memory Management Chapter Fourteen Modern Programming Languages, 2nd ed. 1 Dynamic Memory Allocation Lots of things need memory at runtime: Activation records Objects Explicit allocations: new, malloc,
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 informationGarbage Collection. Lecture Compilers SS Dr.-Ing. Ina Schaefer. Software Technology Group TU Kaiserslautern. Ina Schaefer Garbage Collection 1
Garbage Collection Lecture Compilers SS 2009 Dr.-Ing. Ina Schaefer Software Technology Group TU Kaiserslautern Ina Schaefer Garbage Collection 1 Content of Lecture 1. Introduction: Overview and Motivation
More informationGarbage Collection. Akim D le, Etienne Renault, Roland Levillain. May 15, CCMP2 Garbage Collection May 15, / 35
Garbage Collection Akim Demaille, Etienne Renault, Roland Levillain May 15, 2017 CCMP2 Garbage Collection May 15, 2017 1 / 35 Table of contents 1 Motivations and Definitions 2 Reference Counting Garbage
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 informationLecture Notes on Advanced Garbage Collection
Lecture Notes on Advanced Garbage Collection 15-411: Compiler Design André Platzer Lecture 21 November 4, 2010 1 Introduction More information on garbage collection can be found in [App98, Ch 13.5-13.7]
More informationDeallocation Mechanisms. User-controlled Deallocation. Automatic Garbage Collection
Deallocation Mechanisms User-controlled Deallocation Allocating heap space is fairly easy. But how do we deallocate heap memory no longer in use? Sometimes we may never need to deallocate! If heaps objects
More informationNames, Scopes, and Bindings. CSE 307 Principles of Programming Languages Stony Brook University
Names, Scopes, and Bindings CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Names, Scopes, and Bindings Names are identifiers (mnemonic character
More informationReference Counting. Reference counting: a way to know whether a record has other users
Garbage Collection Today: various garbage collection strategies; basic ideas: Allocate until we run out of space; then try to free stuff Invariant: only the PL implementation (runtime system) knows about
More informationProject. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace
Project there are a couple of 3 person teams regroup or see me or forever hold your peace a new drop with new type checking is coming using it is optional 1 Compiler Architecture source code Now we jump
More informationReference Counting. Reference counting: a way to know whether a record has other users
Garbage Collection Today: various garbage collection strategies; basic ideas: Allocate until we run out of space; then try to free stuff Invariant: only the PL implementation (runtime system) knows about
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 informationCPSC 213. Introduction to Computer Systems. Instance Variables and Dynamic Allocation. Unit 1c
CPSC 213 Introduction to Computer Systems Unit 1c Instance Variables and Dynamic Allocation 1 Reading For Next 3 Lectures Companion 2.4.4-2.4.5 Textbook Structures, Dynamic Memory Allocation, Understanding
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 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 informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from
More informationLecture Notes on Garbage Collection
Lecture Notes on Garbage Collection 15-411: Compiler Design Frank Pfenning Lecture 21 November 4, 2014 These brief notes only contain a short overview, a few pointers to the literature with detailed descriptions,
More informationRun-Time Environments
1 Run-Time Environment Chapter 7 COP5621 Compiler Contruction Copyright Robert van Engelen, Florida State Univerity, 2005 Procedure Activation and Lifetime A procedure i activated when called The lifetime
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 informationCSE 504: Compilers. Expressions. R. Sekar
CSE 504: Compilers Expressions R. Sekar Expression evaluation 1 / 83 Order of evaluation For the abstract syntax tree + + 5 + + x 3 2 4 the equivalent expression is (x + 3) + (2 + 4) + 5 Expression evaluation
More informationOne-Slide Summary. Lecture Outine. Automatic Memory Management #1. Why Automatic Memory Management? Garbage Collection.
Automatic Memory Management #1 One-Slide Summary An automatic memory management system deallocates objects when they are no longer used and reclaims their storage space. We must be conservative and only
More informationHigh-Level Language VMs
High-Level Language VMs Outline Motivation What is the need for HLL VMs? How are these different from System or Process VMs? Approach to HLL VMs Evolutionary history Pascal P-code Object oriented HLL VMs
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 informationUNIT-V. Symbol Table & Run-Time Environments Symbol Table
1 P a g e UNIT-V Symbol Table & Run-Time Environments Symbol Table Symbol table is a data structure used by compiler to keep track of semantics of variable. i.e. symbol table stores the information about
More informationCS 241 Honors Memory
CS 241 Honors Memory Ben Kurtovic Atul Sandur Bhuvan Venkatesh Brian Zhou Kevin Hong University of Illinois Urbana Champaign February 20, 2018 CS 241 Course Staff (UIUC) Memory February 20, 2018 1 / 35
More informationGarbage Collection. Hwansoo Han
Garbage Collection Hwansoo Han Heap Memory Garbage collection Automatically reclaim the space that the running program can never access again Performed by the runtime system Two parts of a garbage collector
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 3a Andrew Tolmach Portland State University 1994-2017 Binding, Scope, Storage Part of being a high-level language is letting the programmer name things: variables
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 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 informationLecture Notes on Garbage Collection
Lecture Notes on Garbage Collection 15-411: Compiler Design André Platzer Lecture 20 1 Introduction In the previous lectures we have considered a programming language C0 with pointers and memory and array
More information