CS421 COMPILERS AND INTERPRETERS. the point it was passed (line 11). explicit vs implicit memory de-allocation? (malloc-free vs. garbage collection)
|
|
- Rodger Williams
- 5 years ago
- Views:
Transcription
1 rocedre arameters (in ascal) rocedre parameters permit procedres to be invoked ot-of-scope ; 1 program main(inpt, otpt); 2 3 procedre b(fnction h(n : integer): integer); 4 var m : integer; 5 begin m := 6; writeln(h(2)) ; 6 7 procedre c; 8 var m : integer; 9 fnction f(n: integer): integer; 10 begin f := m + n ; 11 begin m := 0; b(f) ; 12 begin c. Qestion: how to get the correct environment when calling h inside b? Soltion: mst pass static link along with f as if it had been called at the point it was passed (line 11). Traditional Stack Scheme parameters and retrned vales STACK (activation records) program conter links and saved stats code temporaries and local data Activation Record HEA (dynamic data) garbage collector STATIC (code and globals) REGISTERS Memory Layot More on Rntime Environments How to efficiently implement procedre call and retrn in the presence of higher-order fnctions? what are higher-order fnctions? how to ext frames to spport higher-order fnctions? efficiency isses (exection time, space sage)? How to efficiently spport memory allocation and de-allocation? what are the data representations? what are the memory layot? explicit vs implicit memory de-allocation? (malloc-free vs. garbage collection) Restrictions in C & ascal C does not allow nested procedres --- names in C are either local to some procedre or are global and visible in all procedres. rocedres in C can be passed as argments or retrned as reslts. ascal (or Modla-2, Modla-3, Algol ) allows procedre declarations to be nested, bt procedre parameters are of restricted se, and procedres cannot be retrned as reslt. Fnctional langages (e.g. ML, Haskell, Scheme, Lisp) spport higherorder fnctions --- spporting both nested procedres and procedres passed as parameters or retrned as reslts. spporting it is a big challenge to the compiler writers!
2 rocedre Activations (cont d) ested Fnctions in ML val BIG = big() v=big w=x=y=0 access links Q, fn (v,w,x,y) = val = hd(v) R control links... (v,,,y)... v=v,w= x=,y=y Q, in... Q()... val reslt = (BIG,0,0,0) $ Higher-Order Fnctions (cont d) Q lost track of its environment fn (v,w,x,y) = val = hd(v)... (,w+x+y+3)... Q val S = (BIG,0,0,0) & access links # % rocedre Activations ested Fnctions in ML val BIG = big() v=big w=x=y=0 fn (v,w,x,y) = val = hd(v) Q, control links R... (v,,,y)... in... Q()... val reslt = (BIG,0,0,0) Higher-Order Fnctions How to create a closre for Q? v=big w=x=y=0 fn (v,w,x,y) = val = hd(v)... (,w+x+y+3)... Q val S = (BIG,0,0,0)
3 Higher-Order Fnctions (cont d) Q s environment is in the! fn (v,w,x,y) = val = hd(v) val S = (BIG,0,0,0) ested Higher-Order Fnctions fn (v,w,x,y) = val = hd(v) Qor S R val S = (BIG,0,0,0) val reslt = T() Higher-Order Fnctions (cont d) Q mst copy the frame! v=big w=x=y=0 fn (v,w,x,y) = val = hd(v)... (,w+x+y+3)... val S = (BIG,0,0,0) Applying Higher-Order Fnctions Accessing the Closre Q! Qor S fn (v,w,x,y) = val = hd(v) R val S = (BIG,0,0,0)
4 R or T R w x y copying!!! Linked Closres : O( 2 ) R -1 Flat Closres : O() R w x y $ Flat Closres fn (v,w,x,y) = val = hd(v) val S = (BIG,0,0,0) val reslt = T() Slow creation, Fast access! Space Usage Space Leaks for Linked Closres fn (v,w,x,y) = val = hd(v) (,w+x+y+3) fn loop (n,res) = if n<1 then res else ( val S = (big(),0,0,0) in loop(n-1,t::res) ) val reslt = loop(,[]) Linked Closres fn (v,w,x,y) = val = hd(v) R or T R val S = (BIG,0,0,0) val reslt = T() Fast creation, Slow access! Better Representations? Closres cannot point to frame (different life time, so yo mst copy.) Linked closres --- fast creation, slow access Flat closres --- slow creation, fast access Stack frames with access links are similar to linked closres (accessing non-local variables is slow.) GOAL : We need good closre representations that have both fast access and fast creation! #
5 Better Space Usage? The safe for space complexity rle : Local variable mst be assmed dead after its last se within its scope! Stacks and linked closres are OT safe for space Flat closres are safe for space SML/J : nsafe version = (2 to 80) x safe version & Efficient Heap-based Compilation An efficient -based scheme has the following advantages: very good space sage (safe for space complexity!) very fast closre creation and closre access closres can be shared with activation records fast call/cc and fast generational GC simple implementation % Space Usage (cont d) -1 Q,v,w n= Space Leaks for Stack Allocations Q,v,w n=-1 fn (x) = Q,v,w n=-2 Use O( 2 ) Space! fn Q(n) = val = big(n) val v = () val w = hd() in if n > 0 then Q(n-1)+v(w) else... val reslt = Q() is dead after this call! Drawbacks of Stack Allocation inefficient space sage slow access to non-local variables expensive copying between and (activation records cannot be shared by closres) scanning roots is expensive in generational GC very slow first-class continations (call/cc) correct implementation is complicated and messy
6 Safely Linked Closres THE TRICK: Safe for Space : se O() space Variables w,x,y have same life time! R fn (v,w,x,y) = val = hd(v) (,w+x+y+3) w x y Q v fn loop (n,res) = if n<1 then res else ( val S = (big(),0,0,0) in loop(n-1,t::res) ) -1 val reslt = loop(,[]) Good Use of Registers To avoid memory traffic, modern compilers often pass argments, retrn reslts, and allocate local variables in machine registers. Typical parameter-passing convention on modern machines: the first k argments ( k = 4 or 6) of a fnction are passed in registers R p,..., R p+k-1, the rest are passed on the. roblem : extra memory traffic cased by passing args. in registers fnction g(x : int, y : int, z :int) : int = x*y*z fnction f(x : int, y : int, z : int) = val a := g(z+3, y+3, x+4) in a*x+y+z Sppose fnction f and g pass their argments 1, R 2, R 3 ; then f mst save R 1, R 2, and R 3 to the memory before calling g, re Heap-based Scheme Ideas: no rntime! program conter safely linked closres good se of registers code HEA (dynamic data) (activation records) garbage collector STATIC (code and globals) REGISTERS Memory Layot Safely Linked Closres (cont d) THE TRICK: Shorter Access ath! Variables w,x,y have same life time! S R w x y fn (v,w,x,y) = val = hd(v) fn S() = w+x+y+3 in (S,) Q v val T = (big(),0,0,0) -1 The nmber of links traversed is at most 1.
7 Closres egisters? o! pred is an escaping fnction! Modle FOO: (in file foo.sml ) Its closre mst be bilt on the! fn pred(x) =...v(w,x)... val reslt = BAR.filter(pred,...) Modle BAR : (in file bar.sml ) Escaping fnctions: fnctions whose call sites are not all known at compile time! fn filter(p,l) = fn h(s,z) = if (s=[]) then rev z else ( val a = car s val r = cdr s in if p a then h(r,a::z) else h(r,z) ) in h(l,[]) $ Lambda Lifting fn filter(p,l) = r 0 r 1 r 2 r 3 s z rev p h s=[] fn h(s,z,rev,p) = if (s=[]) then rev z else ( val a = car s val r = cdr s in if p a then h(r,a::z,rev,p) else h(r,z,rev,p) ) p a in h(l,[],rev,p) rev z known fnctions can be rewritten into fnctions that are flly closed! (i.e. with no free variables!) & Good Use of Registers (cont d) how to avoid extra memory traffic? Leaf procedres (or fnctions) are procedres that do not call other procedres; e.g, the fnction exchange. The parameters of leaf procedres can be allocated in registers withot casing any extra memory traffic. Use global register allocation, different fnctions se different set of registers to pass their argments. Use register windows (as on SARC) --- each fnction invocation can allocate a fresh set of registers. Allocate closres in registers or se callee-save registers When all fails --- save to the frame or to the. # Closres egisters? es! Known fnctions: fn filter(p,l) = fnctions whose call sites are all known at compile time! h fn h(s,z) = if (s=[]) then rev z else ( val a = car s val r = cdr s in if p a then h(r,a::z) else h(r,z) ) s=[] in h(l,[]) p a h is a known fnction! Its closre can be pt in registers! (e.g., {rev,p}) rev z %
8 Callee-save Registers callee-save registers general registers Convention : r 4 r 5 r 6 r 0 r 1 r 2 r 3 Reserve k special registers! A B C g v w f A B C Every fnction promises to always preservethese registers! w g g v g Example : k=3 (r 4,r 5,r 6 ) x w x g x w g y A B C f retrn fn f(g,,v,w) = val x =g(,v) val y = g(x,w) in x+y+w Smmary : A Uniform Soltion Take advantage of variable life time and compiime control flow information! Spilled activation records are also thoght as closres! no rntime everything is sharable all se safely-linked closres to maximize sharing pass argments and retrn reslts in registers allocating most closres in registers good se of callee-save registers Spilled Activation Records We do not know how p treats the registers! r 0 r 1 r 2 r 3 r 4 r 5 s z rev p h s=[] r 0 r 1 r 2 r 3 r 4 r 5 a::z r z rev p a p a r 0 r 1 r 2 r 3 r 4 r 5 r rev p a r 0 r 1 r 2 r 3 r 4 r 5 r z rev p a Mst save and load everything here! rev z Callee-save Registers (cont d) A B C D E F r 0 r 1 r 2 r 3 s z rev p 6 callee-save registers : r 4,r 5,r 6,r 7,r 8,r 9 A B C D E F h s z rev p recover everything! s=[] a::z r z rev p a p a r rev p a r z rev p a no need to save and load anymore! rev z
More on Runtime Environments. Procedure Parameters (in Pascal) Traditional Stack Scheme. Restrictions in C & Pascal. code.
More on Rntime Environments How to efficiently implement procedre call and retrn in the presence of higher-order fnctions? 1. what are higher-order fnctions? 2. how to ext frames to spport higher-order
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 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 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 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 informationThe Volcano Optimizer Generator: Extensibility and Efficient Search
The Volcano Optimizer Generator: Extensibility and Efficient Search - Prithvi Lakshminarayanan - 301313262 Athors Goetz Graefe, Portland State University Won the Most Inflential Paper award in 1993 Worked
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 26: Dynamic Memory (2) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 25: Dynamic Memory (1) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals
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 informationContents. 8-1 Copyright (c) N. Afshartous
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10 Introduction to Object-Oriented
More informationControl in Sequential Languages
CS 242 2012 Control in Sequential Languages Reading: Chapter 8, Sections 8.1 8.3 (only) Section 7.3 of The Haskell 98 Report, Exception Handling in the I/O Monad, http://www.haskell.org/onlinelibrary/io-13.html
More informationEXAMINATIONS 2010 END OF YEAR NWEN 242 COMPUTER ORGANIZATION
EXAINATIONS 2010 END OF YEAR COPUTER ORGANIZATION Time Allowed: 3 Hors (180 mintes) Instrctions: Answer all qestions. ake sre yor answers are clear and to the point. Calclators and paper foreign langage
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 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 informationMore eamples with half half(0) handle Zero => 1000; > val it = 1000 : int half(1) handle Zero => 1000; > ncaght eception Odd half(0) handle Zero => 10
Lectre 4 0 More eamples with half half(0) handle Zero => 1000; > val it = 1000 : int half(1) handle Zero => 1000; > ncaght eception Odd half(0) handle Zero => 1000 Odd => 1001; > val it = 1000 : int half(3)
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
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 informationHardware Design Tips. Outline
Hardware Design Tips EE 36 University of Hawaii EE 36 Fall 23 University of Hawaii Otline Verilog: some sbleties Simlators Test Benching Implementing the IPS Actally a simplified 6 bit version EE 36 Fall
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 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline
CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can
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 informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 8: Threads Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Processes P1 P2 Recall that Bt OS A process
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 9: Synchronization (1) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Cooperation between Threads
More informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 23: File Systems (2) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time Abstractions for the
More informationCAPL Scripting Quickstart
CAPL Scripting Qickstart CAPL (Commnication Access Programming Langage) For CANalyzer and CANoe V1.01 2015-12-03 Agenda Important information before getting started 3 Visal Seqencer (GUI based programming
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 informationCS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University
CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 2: Historical Perspective Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time What is an OS?
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 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 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 informationMinimum Spanning Trees Outline: MST
Minimm Spanning Trees Otline: MST Minimm Spanning Tree Generic MST Algorithm Krskal s Algorithm (Edge Based) Prim s Algorithm (Vertex Based) Spanning Tree A spanning tree of G is a sbgraph which is tree
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 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 informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationLECTURE 16. Functional Programming
LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative
More informationC Puzzles The course that gives CMU its Zip! Integer Arithmetic Operations Jan. 25, Unsigned Addition. Visualizing Integer Addition
1513 The corse that gies CMU its Zip! Integer Arithmetic Operations Jan. 5, 1 Topics Basic operations Addition, negation, mltiplication Programming Implications Conseqences of oerflow Using shifts to perform
More informationProgramming Languages
Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes
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 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 informationStorage. Outline. Variables and Updating. Composite Variables. Storables Lifetime : Programming Languages. Course slides - Storage
Storage 1 Variables and Updating Outline Composite Variables Total and selective updating Array variables Storables Lifetime Local and global variables Heap variables Persistent variables Garbage collection
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 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 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 informationCS 153 Design of Operating Systems
CS 153 Design of Operating Systems Spring 18 Lectre 3: OS model and Architectral Spport Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time/today
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 informationCS 415 Midterm Exam Spring 2002
CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming
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 informationLecture 13: Complex Types and Garbage Collection
Lecture 13: Complex Types and Garbage Collection COMP 524 Programming Language Concepts Stephen Olivier March 17, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts
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 informationCSC 533: Organization of Programming Languages. Spring 2005
CSC 533: Organization of Programming Languages Spring 2005 Language features and issues variables & bindings data types primitive complex/structured expressions & assignments control structures subprograms
More informationCOP4020 Programming Languages. Functional Programming Prof. Robert van Engelen
COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts
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 informationCS 153 Design of Operating Systems Spring 18
CS 153 Design of Operating Systems Spring 18 Lectre 11: Semaphores Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time Worked throgh software implementation
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 informationPage # CISC360. Integers Sep 11, Encoding Integers Unsigned. Encoding Example (Cont.) Topics. Twoʼs Complement. Sign Bit
Topics CISC3 Integers Sep 11, 28 Nmeric Encodings Unsigned & Twoʼs complement Programming Implications C promotion rles Basic operations Addition, negation, mltiplication Programming Implications Conseqences
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 informationLecture 15 Garbage Collection
Lecture 15 Garbage Collection I. Introduction to GC -- Reference Counting -- Basic Trace-Based GC II. Copying Collectors III. Break Up GC in Time (Incremental) IV. Break Up GC in Space (Partial) Readings:
More informationPutting the dynamic into software security testing
Ptting the dynamic into software secrity testing Detecting and Addressing Cybersecrity Isses V1.1 2018-03-05 Code ahead! 2 Atomated vlnerability detection and triage + = 3 How did we get here? Vector was
More informationInformal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility
Informal Semantics of Data semantic specification names (identifiers) attributes binding declarations scope rules visibility 1 Ways to Specify Semantics Standards Documents (Language Definition) Language
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 informationAnnouncements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model.
CS 242 2007 Scope, Function Calls and Storage Management John Mitchell Announcements Homework Returned in class Wed; afterwards in 4 th Floor Gates Cabinet SCPD students: attach routing slip, will be returned
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 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 informationScope. Chapter Ten Modern Programming Languages 1
Scope Chapter Ten Modern Programming Languages 1 Reusing Names Scope is trivial if you have a unique name for everything: fun square a = a * a; fun double b = b + b; But in modern languages, we often use
More informationDr Paolo Guagliardo. Fall 2018
The NULL vale Dr Paolo Gagliardo dbs-lectrer@ed.ac.k Fall 2018 NULL: all-prpose marker to represent incomplete information Main sorce of problems and inconsistencies... this topic cannot be described in
More informationAn Introduction to GPU Computing. Aaron Coutino MFCF
An Introdction to GPU Compting Aaron Cotino acotino@waterloo.ca MFCF What is a GPU? A GPU (Graphical Processing Unit) is a special type of processor that was designed to render and maniplate textres. They
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 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 informationChapter 6: Pipelining
CSE 322 COPUTER ARCHITECTURE II Chapter 6: Pipelining Chapter 6: Pipelining Febrary 10, 2000 1 Clothes Washing CSE 322 COPUTER ARCHITECTURE II The Assembly Line Accmlate dirty clothes in hamper Place in
More informationAdministration CS 412/413. Advanced Language Support. First-class vs. Second-class. First-class functions. Function Types
Administration CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Lecture 33: First-class functions 21 April 00 Programming Assignment 6 handed out today register allocation
More informationNames, Scopes, and Bindings II. Hwansoo Han
Names, Scopes, and Bindings II Hwansoo Han Scope Rules A scope is textual region where bindings are active A program section of maximal size Bindings become active at the entry No bindings change in the
More informationQ1: /8 Q2: /30 Q3: /30 Q4: /32. Total: /100
ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam Three November 20 th 2013 Name: Q1: /8 Q2: /30 Q3: /30 Q4: /32 Total: /100 1/10 For functional call related questions, let s assume
More informationThe single-cycle design from last time
lticycle path Last time we saw a single-cycle path and control nit for or simple IPS-based instrction set. A mlticycle processor fies some shortcomings in the single-cycle CPU. Faster instrctions are not
More informationBits, Bytes, and Integers. Bits, Bytes, and Integers. The Decimal System and Bases. Everything is bits. Converting from Decimal to Binary
with contribtions from Dr. Bin Ren, College of William & Mary Addition, negation, mltiplication, shifting 1 Everything is bits The Decimal System and Bases Each bit is or 1 By encoding/interpreting sets
More informationRequirements Engineering. Objectives. System requirements. Types of requirements. FAQS about requirements. Requirements problems
Reqirements Engineering Objectives An introdction to reqirements Gerald Kotonya and Ian Sommerville To introdce the notion of system reqirements and the reqirements process. To explain how reqirements
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 informationC Puzzles! Taken from old exams. Integers Sep 3, Encoding Integers Unsigned. Encoding Example (Cont.) The course that gives CMU its Zip!
15-13 The corse that gies CMU its Zip! Topics class3.ppt Integers Sep 3,! Nmeric Encodings " Unsigned & Two s complement! Programming Implications " C promotion rles! Basic operations " Addition, negation,
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 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 informationAnswer: Early binding generally leads to greater efficiency (compilation approach) Late binding general leads to greater flexibility
Quiz Review Q1. What is the advantage of binding things as early as possible? Is there any advantage to delaying binding? Answer: Early binding generally leads to greater efficiency (compilation approach)
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 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 informationStatic Program Analysis Part 9 pointer analysis. Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University
Static Program Analysis Part 9 pointer analysis Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Agenda Introduction to points-to analysis Andersen s analysis Steensgaards s
More informationPART I: Adding Instructions to the Datapath. (2 nd Edition):
EE57 Instrctor: G. Pvvada ===================================================================== Homework #5b De: check on the blackboard =====================================================================
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 informationTDT4255 Friday the 21st of October. Real world examples of pipelining? How does pipelining influence instruction
Review Friday the 2st of October Real world eamples of pipelining? How does pipelining pp inflence instrction latency? How does pipelining inflence instrction throghpt? What are the three types of hazard
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 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 informationAn Introduction to Scheme
An Introduction to Scheme Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Stéphane Ducasse 1 Scheme Minimal Statically scoped Functional Imperative Stack manipulation Specification
More informationThe role of semantic analysis in a compiler
Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
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 09: Data Abstraction ++ Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree.
Lecture 09: Data Abstraction ++ Parsing Parsing is the process of translating a sequence of characters (a string) into an abstract syntax tree. program text Parser AST Processor Compilers (and some interpreters)
More informationEEC 483 Computer Organization. Branch (Control) Hazards
EEC 483 Compter Organization Section 4.8 Branch Hazards Section 4.9 Exceptions Chans Y Branch (Control) Hazards While execting a previos branch, next instrction address might not yet be known. s n i o
More informationCSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8
Question 1. (12 points) For each of the following, what value is printed? (Assume that each group of statements is executed independently in a newly reset Scheme environment.) (a) (define x 1) (define
More informationCompiler Construction Lent Term 2015 Lectures 10, 11 (of 16)
Compiler Construction Lent Term 15 Lectures 10, 11 (of 16) 1. Slang.2 (Lecture 10) 1. In lecture code walk of slang2_derive 2. Assorted topics (Lecture 11) 1. Exceptions 2. Objects 3. Stacks vs. Register
More informationProgramming Language Concepts Scoping. Janyl Jumadinova January 31, 2017
Programming Language Concepts Scoping Janyl Jumadinova January 31, 2017 Scope Rules A scope is a program section of maximal size in which no bindings change, or at least in which no re-declarations are
More informationOperating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst
Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst Department of Computer Science Why C? Low-level Direct access to memory WYSIWYG (more or less) Effectively
More informationControl in Sequential Languages
Control in Sequential Languages Structured Programming Go to considered harmful Exceptions structured jumps that may return a value dynamic scoping of exception handler Continuations Function representing
More information