Stack Tracing In A Statically Typed Language
|
|
- Steven Murphy
- 5 years ago
- Views:
Transcription
1 Stack Tracing In A Statically Typed Language Amer Diwan Object Oriented Systems Laboratory Department of Computer Science University of Massachusetts October 2, Introduction Statically-typed languages such as Modula-3 [Cardelli et al., 1989] provide many opportunities for compile-time garbage collection support. Compiler generated tables can assist the collector in locating the root pointers and in updating them when objects are moved. This obviates the need for run-time tags in the stack and offers substantial performance improvements. In this paper, we explore an important issue that a stack tracing scheme for a statically typed language needs to address: derived locations. A memory slot or a register is called a derived location if its value is determined by arithmetic from the base addresses of one or more objects or from other derived locations. The objects involved in the derivation are referred to as the involved objects of the derived location. Derived locations are important for two reasons. First, the involved objects of a reachable derived location should be saved during a scavenge. Second, when an involved object is moved during a scavenge, the derived locations dependent on it should be updated as well 1. In the remainder of this paper we describe the key issues that arise when we add compiler support to assist the garbage collector in finding and updating derived locations. We also describe our solutions for Modula-3. Although our work has been done in the context of Modula-3, it is relevant to other languages and collectors as well. In Section 6 we talk about similar issues that have come up in work on a C system using an ambiguous roots collector. 2 Creation of Derived Locations In this section we identify some language features and compiler optimizations that produce derived locations and give an example derivation in each case. By convention, all arrays, unless otherwise specified, are one dimensional integer arrays with base index 0. Also, we adopt the convention of presenting all source code in Modula-3 syntax and all compiler/optimizer output in C syntax. This work is part of the author s M.S. project. 1 An object may be an involved object for any number of derived locations. 1
2 Pass by Reference: A pointer to the middle of array A is created when A[i] is passed by VAR in a procedure call 2. Note that passing a derived location by VAR to a routine creates a new derived location. Strength Reduction: The body A[i] := 13; INC (i); of an array initialization loop can be turned into *p++ = 13, with p appropriately initialized. Virtual Array Origin: If A is an array of type ARRAY [7..13] OF INTEGER, the obvious method of accessing A[i] is *(&A[0] + (i - 7) * sizeof (int)). The subtraction can be avoided by treating the array as if it were of type ARRAY [0..13] OF INTEGER. Note that in this optimization, the derived location can point outside its involved object. Common Subexpression Elimination: The code A[i,j] := 10; A[i,k] := 20; may be compiled into t = &A[i]; *(t + j * sizeof (int)) = 10; *(t + k * sizeof (int)) = 20; if the optimizer can determine that t is being computed twice and that i is not updated. Double Indexing: If A[i] := 10; B[i] := 20; is naively compiled, it may yield *(&A[0] + (i * sizeof(int))) = 10; *(&B[0] + (i * sizeof(int))) = 20; This may be optimized to t1 = &B[0] - &A[0]; t2 = &A[0] + (i * sizeof(int)); *t2 = 10; *(t2 + t1) = 20; Note that this time the derived location t1 is not even of pointer type. 3 Using the Compiler Generated Tables The base tables associate each derived location with its base pointers (see Figure 1) at a given program point 3. These tables are used by the scavenger during garbage collection to keep derived locations consistent with their base pointers. 2 This is the only way of creating a derived location from within a Modula-3 program. Unrestricted pointer arithmetic is allowed in unsafe modules, but the validity of the addresses produced by these operations is implementation dependent [Cardelli et al., 1989]. 3 As it would probably be prohibitively expensive to have this information available for each program point, we store this information for some carefully chosen points in the program. 2
3 a Base Relation Base Value b1 b2 b3 + + Figure 1: Base table for a at program point p The Relation column in the table indicates how the corresponding base pointer is related to the derived location (either added or subtracted 4 ). For instance, in Figure 1, b1 and b3 are added in the derivation of a, whereas b2 is subtracted. This is equivalent to saying that the reaching definition of a at program point p is: a := b1 - b2 + b3 + <expression that does not involve any pointers> The Base Value column is used by the collector at run time. At the beginning of a scavenge, the collector goes through the base tables of each live derived location, and fills in the current value of the base pointers in the Base Value column. At the end of a scavenge, the collector goes through these tables again, this time computing the difference between the current value of a base pointer and its saved value, and uses the difference to update the derived location. If a base is a derived location then its value needs to be updated before any locations that are derived from it. Fortunately, this ordering can be accomplished if the derived locations are updated while traversing the stack from the bottom up; if X is a derived location and its base pointer Y is also a derived location then Y must be lower in the stack than X. Note that we assume the relations are easily invertible which is true in our case since we allow only addition and subtraction. If we allow other operators we will need to augment the scheme to recalculate the entire deriving expression. 4 Some Complications The job of the compiler would be simple if it could correctly, statically, and unambiguously identify the base pointers 5 for each derived location at any given point in the program. Unfortunately, this is not the case for at least two scenarios: when multiple derivations reach a program point, and when a base pointer dies before the derived location. Following are examples of each of these scenarios. 4 Our current implementation supports derived location creation only through pointer addition and subtraction. If other operators are needed (like bit-manipulation operators), we can work them into our scheme with little effort. 5 The pointer(s) used in the derivation of a derived location. 3
4 SOURCE OPTIMIZED i := 1; WHILE (cond) IF (inv) THEN PRINT (P[i]); ELSE PRINT (Q[i]); INC (i); =) i = 1; if (inv) t = &P[0] + 1; else t = &Q[0] + 1; while (cond) PRINT (*(t + i++)); If inv is invariant, the optimizer may hoist the conditional out of the loop causing t s derivation to be ambiguous inside the loop; t is derived from either &P[0] or &Q[0]. SOURCE OPTIMIZED A: REF ARRAY [1..10] OF INTEGER; FOR i := 1 TO LAST (Aˆ) DO s := s + Aˆ[i]; =) for (i = 1; i <= 10; i++) s = s + *A++; If data flow analysis can determine that A is dead after the loop, then the compiler may generate the code on the right. In this code, A s base pointer (the original value of A) is not available to the collector inside the loop. 5 Solutions It should be clear that determining the base pointers of t in the ambiguous derivation scenario in Section 4 cannot be accomplished at compile time; some run-time overhead is unavoidable. Our solution adds one additional assignment to each path of an ambiguous derivation. The idea is to have a path variable; its value determines which of the various paths were taken, and hence which base table to use. i = 1; if (inv) f t 0 = <Expression indicating that this path was taken> t = &P[0] + 1; g else f t 0 = <Expression indicating that this path was taken> t = &Q[0] + 1; g while (cond) PRINT (*(t + i++)); 4
5 Now, rather than having a base table for t, we associate t with t 0. Based on the value of t 0, the garbage collector associates a base table with t. Note that a base table is created for each alternative derivation; the appropriate one is chosen at run time based on the value of t 0. The problem of dead base pointers is solved if we can convince the compiler that the base pointers of a derived location are live at every use of the derived location. We do this by making our compiler consider a use of a derived location as a use of each of its base pointers. This forces the compiler to retain the base pointers for the lifetime of the derived locations that are derived from them. 6 Related Work Boehm [Boehm, 1991b; Boehm, 1991a] is currently incorporating garbage collection support in a C compiler. They are using an ambiguous roots collector and therefore do not need to disambiguate derivations; since they never move objects, they do not need to update derived locations. However, they do need to ensure that any object reachable from a derived location is also reachable from a pointer to the base of the object. This problem is similar to our dead base pointer scenario described in Section 4. 7 Conclusions We have described how garbage collection schemes can benefit from the compile-time type information available for statically typed languages. We have also described problems that need to be dealt with effectively if the collector is to gain much benefit from compile-time information, along with our solutions to the problem. Our initial implementation for Modula-3 is almost complete. We expect to have some preliminary measurements (of base table sizes, etc) available soon. 8 Acknowledgments I would like to thank my advisor Eliot Moss for his guidance during this work. I also wish to thank Tony Hosking, Rick Hudson, Eliot Moss, and Darko Stefanovic for their comments on drafts of this paper. References [Boehm, 1991a] Hans-Juergen Boehm. Personal communication, July [Boehm, 1991b] Hans-Juergen Boehm. A Proposal for GC-safe C Compilation. Draft, June [Cardelli et al., 1989] Luca Cardelli, James Donahue, Lucille Glassman, Mick Jordan, Bill Kalsow, and Greg Nelson. Modula-3 report (revised). Tech. Rep. DEC SRC 52, DEC Systems Research Center/Olivetti Research Center, Palo Alto/Menlo Park, CA, Nov
The Modula-3 FOR loop
The Modula-3 FOR loop Roland Illig roland.illig@gmx.de September 25, 2005 Modula-3 is a simple and safe programming language. The Modula-3 FOR statement is defined such that using it with very large or
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 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 informationA Language-Independent Garbage Collector Toolkit
University of Massachusetts Amherst ScholarWorks@UMass Amherst Computer Science Department Faculty Publication Series Computer Science 1991 A Language-Independent Garbage Collector Toolkit Richard L. Hudson
More informationSupercomputing in Plain English Part IV: Henry Neeman, Director
Supercomputing in Plain English Part IV: Henry Neeman, Director OU Supercomputing Center for Education & Research University of Oklahoma Wednesday September 19 2007 Outline! Dependency Analysis! What is
More informationMachine-Independent Optimizations
Chapter 9 Machine-Independent Optimizations High-level language constructs can introduce substantial run-time overhead if we naively translate each construct independently into machine code. This chapter
More informationTowards Compile-Time Optimisations for Persistence
Towards Compile-Time Optimisations for Persistence Antony L. Hosking hosking@cs.umass.edu J. Eliot B. Moss moss@cs.umass.edu Department of Computer and Information Science University of Massachusetts Amherst,
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 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 informationCode Shape II Expressions & Assignment
Code Shape II Expressions & Assignment Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make
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 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 informationAt this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows:
Pointers and Arrays Part II We will continue with our discussion on the relationship between pointers and arrays, and in particular, discuss how arrays with dynamical length can be created at run-time
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 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 information(just another operator) Ambiguous scalars or aggregates go into memory
Handling Assignment (just another operator) lhs rhs Strategy Evaluate rhs to a value (an rvalue) Evaluate lhs to a location (an lvalue) > lvalue is a register move rhs > lvalue is an address store rhs
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 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 information16.10 Exercises. 372 Chapter 16 Code Improvement. be translated as
372 Chapter 16 Code Improvement 16.10 Exercises 16.1 In Section 16.2 we suggested replacing the instruction r1 := r2 / 2 with the instruction r1 := r2 >> 1, and noted that the replacement may not be correct
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 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 informationOptimizing Closures in O(0) time
Optimizing Closures in O(0 time Andrew W. Keep Cisco Systems, Inc. Indiana Univeristy akeep@cisco.com Alex Hearn Indiana University adhearn@cs.indiana.edu R. Kent Dybvig Cisco Systems, Inc. Indiana University
More informationI J C S I E International Science Press
Vol. 5, No. 2, December 2014, pp. 53-56 I J C S I E International Science Press Tolerating Memory Leaks at Runtime JITENDER SINGH YADAV, MOHIT YADAV, KIRTI AZAD AND JANPREET SINGH JOLLY CSE B-tech 4th
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 informationExpressing Object Residency Optimizations Using Pointer Type Annotations
Expressing Object Residency Optimizations Using Pointer Type Annotations J. Eliot B. Moss and Antony L. Hosking Object Systems Laboratory, Department of Computer Science University of Massachusetts; Amherst,
More informationAdvances in Programming Languages: Regions
Advances in Programming Languages: Regions Allan Clark and Stephen Gilmore The University of Edinburgh February 22, 2007 Introduction The design decision that memory will be managed on a per-language basis
More informationType Checking and Type Equality
Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.
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 informationAn Exceptional Programming Language
An Exceptional Programming Language John Aycock Department of Computer Science University of Calgary 2500 University Drive N.W. Calgary, Alberta, Canada T2N 1N4 Phone: +1 403 210 9409, Fax: +1 403 284
More informationMemory Allocation III
Memory Allocation III CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Homework 5 Due Wed
More informationHardware-Supported Pointer Detection for common Garbage Collections
2013 First International Symposium on Computing and Networking Hardware-Supported Pointer Detection for common Garbage Collections Kei IDEUE, Yuki SATOMI, Tomoaki TSUMURA and Hiroshi MATSUO Nagoya Institute
More informationCE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings
CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings 19/10/2017 CE221 Part 2 1 Variables and References 1 In Java a variable of primitive type is associated with a memory location
More informationCompiler Construction 2010/2011 Loop Optimizations
Compiler Construction 2010/2011 Loop Optimizations Peter Thiemann January 25, 2011 Outline 1 Loop Optimizations 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6
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 informationStructure of Programming Languages Lecture 10
Structure of Programming Languages Lecture 10 CS 6636 4536 Spring 2017 CS 6636 4536 Lecture 10: Classes... 1/23 Spring 2017 1 / 23 Outline 1 1. Types Type Coercion and Conversion Type Classes, Generics,
More informationCompiler Construction 2016/2017 Loop Optimizations
Compiler Construction 2016/2017 Loop Optimizations Peter Thiemann January 16, 2017 Outline 1 Loops 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6 Loop Unrolling
More informationCompiler Support for Garbage Collection in a Statically Typed Language*
Compiler Support for Garbage Collection in a Statically Typed Language* Amer Diwan Eliot Moss Richard Hudson ~ Object Systems Laboratory Department of Computer Science University of Massachusetts Amherst,
More informationFinding References in Java Stacks
SML document #SML-97-0405 Presented at the OOPSLA 97 Workshop on Garbage Collection and Memory Management, October 5, 1997, Atlanta, GA. Finding References in Java Stacks Ole Agesen, David Detlefs Sun
More informationC: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21
Department of Computer Science College of Engineering Boise State University September 11, 2017 1/21 Pointers A pointer is a variable that stores the address of another variable. Pointers are similar to
More informationDynamic Memory Allocation II October 22, 2008
15-213 Dynamic Memory Allocation II October 22, 2008 Topics Explicit doubly-linked free lists Segregated free lists Garbage collection Review of pointers Memory-related perils and pitfalls class18.ppt
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 informationCS153: Compilers Lecture 15: Local Optimization
CS153: Compilers Lecture 15: Local Optimization Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 4 out Due Thursday Oct 25 (2 days) Project 5 out Due Tuesday Nov 13 (21 days)
More informationCode optimization. Have we achieved optimal code? Impossible to answer! We make improvements to the code. Aim: faster code and/or less space
Code optimization Have we achieved optimal code? Impossible to answer! We make improvements to the code Aim: faster code and/or less space Types of optimization machine-independent In source code or internal
More informationWhat have we learned about when we learned about function parameters? 1-1
What have we learned about when we learned about function parameters? 1-1 What have we learned about when we learned about function parameters? Call-by-Value also known as scalars (eg. int, double, char,
More informationOlder-First Garbage Collection in Practice: Evaluation in a Java Virtual Machine
Older-First Garbage Collection in Practice: Evaluation in a Java Virtual Machine Darko Stefanovic (Univ. of New Mexico) Matthew Hertz (Univ. of Massachusetts) Stephen M. Blackburn (Australian National
More informationMemory Allocation III
Memory Allocation III CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun
More informationEstimating the Impact of Heap Liveness Information on Space Consumption in Java
Estimating the Impact of Heap Liveness Information on Space Consumption in Java by R. Shaham, E. Kolodner and M. Sagiv first presented at ISSM'02 presentation: Adrian Moos Contents what is this about?
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.
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 informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
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 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 informationCS61, Fall 2012 Section 2 Notes
CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors
More informationDynamic Memory Allocation
Dynamic Memory Allocation CS61, Lecture 11 Prof. Stephen Chong October 6, 2011 Announcements 1/2 Reminder: No section on Monday Monday sections have been rescheduled See website for details Please attend
More informationLecture Notes on Loop Optimizations
Lecture Notes on Loop Optimizations 15-411: Compiler Design Frank Pfenning Lecture 17 October 22, 2013 1 Introduction Optimizing loops is particularly important in compilation, since loops (and in particular
More informationOn the Type Accuracy of Garbage Collection
On the Type Accuracy of Garbage Collection Martin Hirzel University of Colorado Boulder, CO 80309 hirzel@cs.colorado.edu Amer Diwan University of Colorado Boulder, CO 80309 diwan@cs.colorado.edu ABSTRACT
More informationOn the Usefulness of Liveness for Garbage Collection and Leak Detection
182 Martin Hirzel, Amer Diwan, and Antony Hosking On the Usefulness of Liveness for Garbage Collection and Leak Detection Martin Hirzel 1, Amer Diwan 1, and Antony Hosking 2 1 University of Colorado Boulder,
More informationSimple Garbage Collection and Fast Allocation Andrew W. Appel
Simple Garbage Collection and Fast Allocation Andrew W. Appel Presented by Karthik Iyer Background Motivation Appel s Technique Terminology Fast Allocation Arranging Generations Invariant GC Working Heuristic
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 informationFreeing memory is a pain. Need to decide on a protocol (who frees what?) Pollutes interfaces Errors hard to track down
Freeing memory is a pain Need to decide on a protocol (who frees what?) Pollutes interfaces Errors hard to track down 1 Freeing memory is a pain Need to decide on a protocol (who frees what?) Pollutes
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
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 informationCS 2461: Computer Architecture 1
Next.. : Computer Architecture 1 Performance Optimization CODE OPTIMIZATION Code optimization for performance A quick look at some techniques that can improve the performance of your code Rewrite code
More informationGoal of lecture. Object-oriented Programming. Context of discussion. Message of lecture
Goal of lecture Object-oriented Programming Understand inadequacies of class languages like Ur- Java Extend Ur-Java so it becomes an object-oriented language Implementation in SaM heap allocation of objects
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 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 informationPrinciples of Compiler Design
Principles of Compiler Design Intermediate Representation Compiler Lexical Analysis Syntax Analysis Semantic Analysis Source Program Token stream Abstract Syntax tree Unambiguous Program representation
More informationStatic Single Assignment Form in the COINS Compiler Infrastructure
Static Single Assignment Form in the COINS Compiler Infrastructure Masataka Sassa (Tokyo Institute of Technology) Background Static single assignment (SSA) form facilitates compiler optimizations. Compiler
More informationCIS 341 Midterm March 2, 2017 SOLUTIONS
CIS 341 Midterm March 2, 2017 SOLUTIONS 1 1. True or False (14 points) Mark each statement as either true or false. a. T F The typical compiler consists of several phases, including: lexing, parsing, transformation
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 informationCompiler Design. Code Shaping. Hwansoo Han
Compiler Design Code Shaping Hwansoo Han Code Shape Definition All those nebulous properties of the code that impact performance & code quality Includes code, approach for different constructs, cost, storage
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 informationOn the Usefulness of Liveness for Garbage Collection and Leak Detection
On the Usefulness of Liveness for Garbage Collection and Leak Detection Martin Hirzel 1,AmerDiwan 1, and Antony Hosking 2 1 University of Colorado Boulder, CO 80309 {hirzel, diwan}@cs.colorado.edu 2 Purdue
More informationGenerating Code for Assignment Statements back to work. Comp 412 COMP 412 FALL Chapters 4, 6 & 7 in EaC2e. source code. IR IR target.
COMP 412 FALL 2017 Generating Code for Assignment Statements back to work Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights
More informationPerformance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs
Performance of Non-Moving Garbage Collectors Hans-J. Boehm HP Labs Why Use (Tracing) Garbage Collection to Reclaim Program Memory? Increasingly common Java, C#, Scheme, Python, ML,... gcc, w3m, emacs,
More informationHOT-Compilation: Garbage Collection
HOT-Compilation: Garbage Collection TA: Akiva Leffert aleffert@andrew.cmu.edu Out: Saturday, December 9th In: Tuesday, December 9th (Before midnight) Introduction It s time to take a step back and congratulate
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 informationLecture Conservative Garbage Collection. 3.2 Precise Garbage Collectors. 3.3 Other Garbage Collection Techniques
CMPSCI 691ST Systems Fall 2011 Lecture 3 Lecturer: Emery Berger Scribe: Nicolas Scarrci 3.1 Conservative Garbage Collection The Boehm collector is the first example of conservative garbage collection.
More informationFreeing memory is a pain. Need to decide on a protocol (who frees what?) Pollutes interfaces Errors hard to track down
Freeing memory is a pain Need to decide on a protocol (who frees what?) Pollutes interfaces Errors hard to track down 1 Freeing memory is a pain Need to decide on a protocol (who frees what?) Pollutes
More informationCompiler Optimization
Compiler Optimization The compiler translates programs written in a high-level language to assembly language code Assembly language code is translated to object code by an assembler Object code modules
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 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 informationQuestion 13 1: (Solution, p 4) Describe the inputs and outputs of a (1-way) demultiplexer, and how they relate.
Questions 1 Question 13 1: (Solution, p ) Describe the inputs and outputs of a (1-way) demultiplexer, and how they relate. Question 13 : (Solution, p ) In implementing HYMN s control unit, the fetch cycle
More informationOptimization Prof. James L. Frankel Harvard University
Optimization Prof. James L. Frankel Harvard University Version of 4:24 PM 1-May-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reasons to Optimize Reduce execution time Reduce memory
More informationSpace Efficient Conservative Garbage Collection
RETROSPECTIVE: Space Efficient Conservative Garbage Collection Hans-J. Boehm HP Laboratories 1501 Page Mill Rd. MS 1138 Palo Alto, CA, 94304, USA Hans.Boehm@hp.com ABSTRACT Both type-accurate and conservative
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 informationGarbage Collection. CS 351: Systems Programming Michael Saelee
Garbage Collection CS 351: Systems Programming Michael Saelee = automatic deallocation i.e., malloc, but no free! system must track status of allocated blocks free (and potentially reuse)
More informationPrecise Garbage Collection for C. Jon Rafkind * Adam Wick + John Regehr * Matthew Flatt *
Slide No. 1 Precise Garbage Collection for C Jon Rafkind * Adam Wick + John Regehr * Matthew Flatt * * University of Utah + Galois, Inc. Slide No. 2 Motivation C Used to implement important programs Web
More informationCompiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler
Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis Synthesis of output program (back-end) Intermediate Code Generation Optimization Before and after generating machine
More informationCompiler Optimization Techniques
Compiler Optimization Techniques Department of Computer Science, Faculty of ICT February 5, 2014 Introduction Code optimisations usually involve the replacement (transformation) of code from one sequence
More informationAlgorithms for Dynamic Memory Management (236780) Lecture 4. Lecturer: Erez Petrank
Algorithms for Dynamic Memory Management (236780) Lecture 4 Lecturer: Erez Petrank!1 March 24, 2014 Topics last week The Copying Garbage Collector algorithm: Basics Cheney s collector Additional issues:
More informationComp 204: Computer Systems and Their Implementation. Lecture 22: Code Generation and Optimisation
Comp 204: Computer Systems and Their Implementation Lecture 22: Code Generation and Optimisation 1 Today Code generation Three address code Code optimisation Techniques Classification of optimisations
More informationThe Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.
The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. Operating System Services User Operating System Interface
More informationCompiler Design. Fall Control-Flow Analysis. Prof. Pedro C. Diniz
Compiler Design Fall 2015 Control-Flow Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292
More informationCSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall
CSE443 Compilers Dr. Carl Alphonce alphonce@buffalo.edu 343 Davis Hall http://www.cse.buffalo.edu/faculty/alphonce/sp17/cse443/index.php https://piazza.com/class/iybn4ndqa1s3ei Announcements Grading survey
More informationWhy Global Dataflow Analysis?
Why Global Dataflow Analysis? Answer key questions at compile-time about the flow of values and other program properties over control-flow paths Compiler fundamentals What defs. of x reach a given use
More informationC: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36
Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar
More informationSimone Campanoni Loop transformations
Simone Campanoni simonec@eecs.northwestern.edu Loop transformations Outline Simple loop transformations Loop invariants Induction variables Complex loop transformations Simple loop transformations Simple
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 informationCS 137 Part 5. Pointers, Arrays, Malloc, Variable Sized Arrays, Vectors. October 25th, 2017
CS 137 Part 5 Pointers, Arrays, Malloc, Variable Sized Arrays, Vectors October 25th, 2017 Exam Wrapper Silently answer the following questions on paper (for yourself) Do you think that the problems on
More information