Combining Garbage Collection and Safe Manual Memory Management Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard,

Slides:



Advertisements
Similar presentations
Garbage Collection in the Next C++ Standard Hans-J. Boehm, Mike Spertus, Symantec.
Advertisements

Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
Reconsidering Custom Memory Allocation Emery D. Berger Benjamin G. Zorn Kathryn S. McKinley November 2002 Proceedings of the Conference on Object-Oriented.
Garbage Collection What is garbage and how can we deal with it?
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Implementation and Evaluation of a Safe Runtime in Cyclone Matthew Fluet Cornell University Daniel Wang Princeton University.
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
A Type Theory for Memory Allocation and Data Layout Leaf Petersen, Robert Harper, Karl Crary and Frank Pfenning Carnegie Mellon.
SAFECode Memory Safety Without Runtime Checks or Garbage Collection By Dinakar Dhurjati Joint work with Sumant Kowshik, Vikram Adve and Chris Lattner University.
ISMM Analyzing Memory Resource Bounds for Low-Level Programs Wei-Ngan Chin 1 Huu Hai Nguyen 1 Corneliu Popeea 1 Shengchao Qin 2 1 National Univ.
Checking and Inferring Local Non-Aliasing Alex AikenJeffrey S. Foster UC BerkeleyUMD College Park John KodumalTachio Terauchi UC Berkeley.
Typed Assembly Languages COS 441, Fall 2004 Frances Spalding Based on slides from Dave Walker and Greg Morrisett.
Summer School on Language-Based Techniques for Integrating with the External World Types for Safe C-Level Programming Part 3: Basic Cyclone-Style Region-
CSE 2501 Review Declaring a variable allocates space for the type of datum it is to store int x; // allocates space for an int int *px; // allocates space.
Type-Safe Programming in C George Necula EECS Department University of California, Berkeley.
Survey of Typed Assembly Language (TAL) Introduction and Motivation –Conventional untyped compiler < Typed intermediate languages –Typed intermediate language.
Typed Memory Management in a Calculus of Capabilities David Walker (with Karl Crary and Greg Morrisett)
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Laboratory for Computer Science Massachusetts Institute of Technology Ownership Types for Safe Region-Based Memory Management in Real-Time Java Chandrasekhar.
Fine-Grained Mobility in the Emerald System Eric Jul, Henry Levy, Norman Hutchinson, Andrew Black SOSP, 1987 & TOCS, 1988.
Compile-Time Deallocation of Individual Objects Sigmund Cherem and Radu Rugina International Symposium on Memory Management June, 2006.
Existential Types for Imperative Languages Dan Grossman Cornell University Eleventh European Symposium on Programming April 2002.
A Type System for Expressive Security Policies David Walker Cornell University.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Garbage Collection Without Paging Matthew Hertz, Yi Feng, Emery Berger University.
Region-Based Memory Management in Cyclone Dan Grossman Cornell University June 2002 Joint work with: Greg Morrisett, Trevor Jim (AT&T), Michael Hicks,
1 Janos Patrick Tullmann Flux Research Group University of Utah.
Advanced Type Systems for Low-Level Languages Greg Morrisett Cornell University.
Cyclone: Safe Programming at the C Level of Abstraction Dan Grossman Cornell University May 2002 Joint work with: Trevor Jim (AT&T), Greg Morrisett, Michael.
Programming Languages: Design, Specification, and Implementation G Rob Strom October 19, 2006.
Cormac Flanagan UC Santa Cruz Velodrome: A Sound and Complete Dynamic Atomicity Checker for Multithreaded Programs Jaeheon Yi UC Santa Cruz Stephen Freund.
Taming the Wildcards: Combining Definition- and Use-Site Variance – Altidor John Altidor Taming the Wildcards: Combining Definition- and Use-Site Variance.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Flexible Reference-Counting-Based Hardware Acceleration for Garbage Collection José A. Joao * Onur Mutlu ‡ Yale N. Patt * * HPS Research Group University.
Secure Virtual Architecture John Criswell, Arushi Aggarwal, Andrew Lenharth, Dinakar Dhurjati, and Vikram Adve University of Illinois at Urbana-Champaign.
Implications of Inheritance COMP204, Bernhard Pfahringer.
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.
Experience with Safe Memory Management in Cyclone Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard Dan Grossman.
A Principled Approach to Nondeferred Reference-Counting Garbage Collection † Pramod G. Joisha HP Labs, Palo Alto † This work was done when the author was.
C++ Memory Overview 4 major memory segments Key differences from Java
Cyclone Memory Management Greg Morrisett Cornell University & Microsoft Research.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Implementation and Evaluation of a Safe Runtime in Cyclone Matthew Fluet Cornell University Greg Morrisett Harvard University Daniel Wang Princeton University.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
11th Nov 2004PLDI Region Inference for an Object-Oriented Language Wei Ngan Chin 1,2 Joint work with Florin Craciun 1, Shengchao Qin 1,2, Martin.
A Type System for Borrowing Permissions Karl Naden, Rob Bocchino Jonathan Aldrich, Kevin Bierhoff POPL – January 27, 2012 School of Computer Science.
PONY Sylvan Clebsch, Sebastian Blessing, Sophia Drossopoulou, Andrew Mc Neil Causality Ltd and Imperial College London.
Object Oriented Software Development 4. C# data types, objects and references.
CSE 332: Memory management with C++ classes Memory Management with Classes Review: for non-static built-in (native) types –default constructor and destructor.
By: Rob von Behren, Jeremy Condit and Eric Brewer 2003 Presenter: Farnoosh MoshirFatemi Jan
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Alias Types David Walker Cornell University What do you want to type check today?
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
Records type city is record -- Ada Name: String (1..10); Country : String (1..20); Population: integer; Capital : Boolean; end record; struct city { --
Automatic Memory Management Without Run-time Overhead Brian Brooks.
C11, Implications of Inheritance
Garbage Collection What is garbage and how can we deal with it?
Unit-2 Objects and Classes
Cyclone A Very Short Introduction Dan Grossman
Programming with Regions
Type Systems for Region-based Memory Management
Dan Grossman University of Washington 26 July 2007
Linear Regions Are All You Need
José A. Joao* Onur Mutlu‡ Yale N. Patt*
Cyclone: A safe dialect of C
Implementation and Evaluation of a Safe Runtime in Cyclone
Implementation and Evaluation of a Safe Runtime in Cyclone
Run-time environments
Garbage Collection What is garbage and how can we deal with it?
Gradual Memory Management
Presentation transcript:

Combining Garbage Collection and Safe Manual Memory Management Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard, Dan Grossman - Uwash, and Trevor Jim - AT&T

Cyclone Derived from C, having similar goals –Exposes low-level data representations, provides fine-grained operations But memory safe –Restrictions to C (e.g., (int *)1 not allowed) –Additions and types to regain flexibility

Goal: Programmer Control Many reasonable MM choices –Garbage collection –Stack allocation – malloc/free –Reference counting Linux, COM –Arenas (individual allocation, bulk free) Apache, LCC Depends on the application

Unifying Theme: Region types Conceptually divide memory into regions –Different kinds of regions (e.g., not just bulk-free) Associate every pointer with a region Prevent dereferencing pointers into dead regions int *`r x; // x points into region `r *x = 3; // deref allowed if `r is live (inference often obviates annotations `r)

Regions Summary (PLDI 02) Region Variety Allocation (objects) Deallocation (what) (when) Aliasing (objects) Stackstaticwhole region exit of scope free Lexicaldynamic Heapsingle objects GC

Regions Summary (now) Region Variety Allocation (objects) Deallocation (what) (when) Aliasing (objects) Stackstaticwhole region exit of scope free Lexicaldynamic Dynamicmanual Heapsingle objects GC Uniquemanual restricted Refcounted

Enabled by Linearity (Affinity) Pointers whose state is carefully tracked To simplify programming: –Polymorphism –Temporary aliasing –Atomic swap (e.g., destructive reads) Main ideas close to Walker & Watkins Key contribution: extension and integration into realistic low-level language

Programming Experience Optimize for memory use –Important for embedded systems, OSs Optimize for speed –Servers, OSs, etc. Applications –Event-based webserver (only unique pointers) –MediaNet: Streaming data overlay network All six region varieties; packet data is unique or reference-counted

Memory Usage: webserver

MediaNet: gc (4 KB packets)

MediaNet: gc+free (4 KB packets)

MediaNet: throughput

Future Work Further generalization –Type-safe Reaps (Berger et al.) More programming experience Better inference (e.g. for alias) Formal model …

Conclusions High degree of control, safely: Sound mechanisms for programmer- controlled memory management –Region-based vs. object-based deallocation –Manual vs. automatic reclamation Region-annotated pointers within a simple framework –Lexical regions as unifying theme (alias,open) –Region polymorphism, for code reuse

More Information Cyclone homepage – Has papers and free distribution –Read about it, write some code!

Related Work (incomplete) Regions –ML-Kit (foundation for Cyclone’s type system) –RC –Reaps –Walker/Watkins Uniqueness –Wadler, Walker/Watkins, Clean –Alias types, Calculus of Capabilities, Vault –Destructive reads (e.g., Boyland)