Automatic Memory Management Without Run-time Overhead Brian Brooks.

Slides:



Advertisements
Similar presentations
The Interface Definition Language for Fail-Safe C Kohei Suenaga, Yutaka Oiwa, Eijiro Sumii, Akinori Yonezawa University of Tokyko.
Advertisements

Lecture 10: Heap Management CS 540 GMU Spring 2009.
Implementation and Evaluation of a Safe Runtime in Cyclone Matthew Fluet Cornell University Daniel Wang Princeton University.
SAFECode Memory Safety Without Runtime Checks or Garbage Collection By Dinakar Dhurjati Joint work with Sumant Kowshik, Vikram Adve and Chris Lattner University.
Informática II Prof. Dr. Gustavo Patiño MJ
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Typed Memory Management in a Calculus of Capabilities David Walker (with Karl Crary and Greg Morrisett)
Laboratory for Computer Science Massachusetts Institute of Technology Ownership Types for Safe Region-Based Memory Management in Real-Time Java Chandrasekhar.
Run-Time Storage Organization
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
Compile-Time Deallocation of Individual Objects Sigmund Cherem and Radu Rugina International Symposium on Memory Management June, 2006.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Advanced Type Systems for Low-Level Languages Greg Morrisett Cornell University.
1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
CS3012: Formal Languages and Compilers The Runtime Environment After the analysis phases are complete, the compiler must generate executable code. The.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
CSE 332: C++ memory management idioms C++ Memory Management Idioms Idioms are reusable design techniques in a language –We’ll look at 4 important ones.
Storage Bindings Allocation is the process by which the memory cell or collection of memory cells is assigned to a variable. These cells are taken from.
Experience with Safe Memory Management in Cyclone Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard Dan Grossman.
Basic Semantics Associating meaning with language entities.
C++ Memory Overview 4 major memory segments Key differences from Java
Pointers in C++. 7a-2 Pointers "pointer" is a basic type like int or double value of a pointer variable contains the location, or address in memory, of.
Speculative Region-based Memory Management for Big Data Systems Khanh Nguyen, Lu Fang, Harry Xu, Brian Demsky Donald Bren School of Information and Computer.
Implementation and Evaluation of a Safe Runtime in Cyclone Matthew Fluet Cornell University Greg Morrisett Harvard University Daniel Wang Princeton University.
COMP3190: Principle of Programming Languages
Combining Garbage Collection and Safe Manual Memory Management Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard,
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
Pointers in C Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens Memory and Addresses Memory is just a sequence of byte-sized.
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Runtime Organization (Chapter 6) 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture.
CSE 332: Memory management with C++ classes Memory Management with Classes Review: for non-static built-in (native) types –default constructor and destructor.
1 Lecture07: Memory Model 5/2/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
RUNTIME ENVIRONMENT AND VARIABLE BINDINGS How to manage local variables.
Announcements There is a Quiz today. There were problems with grading assignment 2, but they should be worked out today The web page for correcting the.
Memory Management What if pgm mem > main mem ?. Memory Management What if pgm mem > main mem ? Overlays – program controlled.
Chapter 5 Names, Bindings, Type Checking CSCE 343.
Dynamic Allocation in C
Data Types In Text: Chapter 6.
Run-Time Environments Chapter 7
Free Transactions with Rio Vista
Memory Management with Classes
CS 326 Programming Languages, Concepts and Implementation
Overview 4 major memory segments Key differences from Java stack
Module 9: Memory and Resource Management
12 C Data Structures.
Storage Management.
Memory and Addresses Memory is just a sequence of byte-sized storage devices. The bytes are assigned numeric addresses, starting with zero, just like the.
Chapter 10: Pointers Starting Out with C++ Early Objects Ninth Edition
Dynamically Allocated Memory
Storage.
Overview 4 major memory segments Key differences from Java stack
Matthew Fluet Cornell University
Matthew Fluet Cornell University
Free Transactions with Rio Vista
Linear Regions Are All You Need
Review & Lab assignments
Dynamic Allocation in C
Matthew Fluet Cornell University Greg Morrisett Harvard University
UNIT V Run Time Environments.
Programming Languages
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
Dynamic Memory.
Implementation and Evaluation of a Safe Runtime in Cyclone
COP 3330 Object-oriented Programming in C++
Implementation and Evaluation of a Safe Runtime in Cyclone
Run-time environments
Gradual Memory Management
Presentation transcript:

Automatic Memory Management Without Run-time Overhead Brian Brooks

What's the point? I love my stop-the-world GC... ● The whole point of automatic memory management is that an object lives as long as it needs to, preferably no longer.

What's the point? I love my stop-the-world GC... ● The whole point of automatic memory management is that an object lives as long as it needs to, preferably no longer. ● When can we free an object?

What's the point? I love my stop-the-world GC... ● The whole point of automatic memory management is that an object lives as long as it needs to, preferably no longer. ● When can we free an object? – When we can guarantee it wont be used again.

We will look at... ● Linear type systems ● Region Based Memory Management ● Capability Calculus

History of linearity ● Linear logic (Girard) – Propositions must be used exactly once – No duplication or discarding ● Linear types (Wadler) – No duplication: only one pointer to a value – No discarding: use once, then deallocate

A Linear Type System

Are Linear Types Practical? ● Key point: values may only be used once. So deallocation is safe. ● Not really expressive. ● Could include non-linear types. Must GC.

Regions ● All values are stored in regions. ● Heap contains stack of regions. ● LIFO ordering of region lifetimes.

Regions ● All values are stored in regions. ● Heap contains stack of regions. ● LIFO ordering of region lifetimes. ● 2 annotations: “Evaluate e1 to some value and store it in region p” “Allocate a new region and bind it to p, evaluate e2, deallocate region.”

● Must ensure that: Region Safety

● Must ensure that: ● Need to track region accesses while type checking!! Region Safety

● Must ensure that: ● Need to track region accesses while type checking!! ● Annotate function type with an effect – Effect: set of regions the function may access Region Safety

● Must ensure that: ● Need to track region accesses while type checking!! ● Annotate function type with an effect – Effect: set of regions the function may access Region Safety

Regions: What else? ● Region inference – Translation from source to target annotated lang – Eliminate the need for most annotations ● Region polymorphism – Functions can be “parameterized” over regions. – Ex: Can pass a region to a function to store it's return value in.

Capabilities ● Key idea: values are still stored in regions, but region allocation / deallocation is explicit. ● Capabilities are similar to effects: – “Under … assumptions, it is legal to execute d, provided the capability C is held. – Capabilities indicate the set of regions that are valid to access (haven't been free'd).

Capabilities ● If we allocate a new region p, we update C to include p ● If we deallocate a region p, p must be in C, we then update C to remove p. ● If we try to read some value – The value v : T at p must be in the typing ctxt – AND, C must contain p.

Conclusion ● Linear types aren't very expressive. – No aliasing – Values may be used once ● Region Based Memory Management – Safe, simple discipline of automatic memory management. ● Capability Calculus – More expressive: explicit region lifetimes.

Questions?

References ● Linear types can change the world! Philip Wadler ● Region-Based Memory Management. Tofte & Talpin ● Typed Memory Management. David Walker ● Effect Types and Region-based Memory Management. Ch in AdvTAPL, Pierce.