Compile-Time Deallocation of Individual Objects Sigmund Cherem and Radu Rugina International Symposium on Memory Management June, 2006.

Slides:



Advertisements
Similar presentations
Shape Analysis by Graph Decomposition R. Manevich M. Sagiv Tel Aviv University G. Ramalingam MSR India J. Berdine B. Cook MSR Cambridge.
Advertisements

Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Pointer Analysis – Part I Mayur Naik Intel Research, Berkeley CS294 Lecture March 17, 2009.
3-Valued Logic Analyzer (TVP) Tal Lev-Ami and Mooly Sagiv.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
Resurrector: A Tunable Object Lifetime Profiling Technique Guoqing Xu University of California, Irvine OOPSLA’13 Conference Talk 1.
Relational Inductive Shape Analysis Bor-Yuh Evan Chang University of California, Berkeley Xavier Rival INRIA POPL 2008.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
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.
Free-Me: A Static Analysis for Individual Object Reclamation Samuel Z. Guyer Tufts University Kathryn S. McKinley University of Texas at Austin Daniel.
Pointer and Shape Analysis Seminar Context-sensitive points-to analysis: is it worth it? Article by Ondřej Lhoták & Laurie Hendren from McGill University.
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Purity Analysis : Abstract Interpretation Formulation Ravichandhran Madhavan, G. Ramalingam, Kapil Vaswani Microsoft Research, India.
Control Flow Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
1 Control Flow Analysis Mooly Sagiv Tel Aviv University Textbook Chapter 3
Previous finals up on the web page use them as practice problems look at them early.
Chapter 10 Storage Management Implementation details beyond programmer’s control Storage/CPU time trade-off Binding times to storage.
Compositional Pointer and Escape Analysis for Java Programs Martin Rinard Laboratory for Computer Science MIT John Whaley IBM Tokyo Research Laboratory.
Run-Time Storage Organization
An Adaptive, Region-based Allocator for Java Feng Qian & Laurie Hendren 2002.
Catriel Beeri Pls/Winter 2004/5 environment 68  Some details of implementation As part of / extension of type-checking: Each declaration d(x) associated.
Detecting Memory Errors using Compile Time Techniques Nurit Dor Mooly Sagiv Tel-Aviv University.
Reps Horwitz and Sagiv 95 (RHS) Another approach to context-sensitive interprocedural analysis Express the problem as a graph reachability query Works.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
A Semantics for Procedure Local Heaps and its Abstractions Noam Rinetzky Tel Aviv University Jörg Bauer Universität des Saarlandes Thomas Reps University.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Impact Analysis of Database Schema Changes Andy Maule, Wolfgang Emmerich and David S. Rosenblum London Software Systems Dept. of Computer Science, University.
COP4020 Programming Languages
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University STATIC ANALYSES FOR JAVA IN THE PRESENCE OF DISTRIBUTED COMPONENTS AND.
An Adaptive, Region-based Allocator for Java Feng Qian, Laurie Hendren {fqian, Sable Research Group School of Computer Science McGill.
Adaptive Optimization with On-Stack Replacement Stephen J. Fink IBM T.J. Watson Research Center Feng Qian (presenter) Sable Research Group, McGill University.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Dimitris Prountzos.
Finding Your Cronies: Static Analysis for Dynamic Object Colocation Samuel Z. Guyer Kathryn S. McKinley T H E U N I V E R S I T Y O F T E X A S A T A U.
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 9.
Incrementalized Pointer and Escape Analysis Frédéric Vivien ICPS/LSIIT Université Louis Pasteur Strasbourg, France Martin Rinard Laboratory for Computer.
Combining Garbage Collection and Safe Manual Memory Management Michael Hicks University of Maryland, College Park Joint work with Greg Morrisett - Harvard,
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University Merging Equivalent Contexts for Scalable Heap-cloning-based Points-to.
Pointer Analysis Survey. Rupesh Nasre. Aug 24, 2007.
Incrementalized Pointer and Escape Analysis Martin Rinard MIT LCS.
Pointer Analysis for Multithreaded Programs Radu Rugina and Martin Rinard M I T Laboratory for Computer Science.
Data Flow Analysis for Software Prefetching Linked Data Structures in Java Brendon Cahoon Dept. of Computer Science University of Massachusetts Amherst,
Heap liveness and its usage in automatic memory management Ran Shaham Elliot Kolodner Mooly Sagiv ISMM’02 Unpublished TVLA.
Runtime Organization (Chapter 6) 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture.
CS 343 presentation Concrete Type Inference Department of Computer Science Stanford University.
Pointer and Escape Analysis for Multithreaded Programs Alexandru Salcianu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Pointer Analysis – Part I CS Pointer Analysis Answers which pointers can point to which memory locations at run-time Central to many program optimization.
LECTURE 13 Names, Scopes, and Bindings: Memory Management Schemes.
Recursion Unrolling for Divide and Conquer Programs Radu Rugina and Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Interprocedural shape analysis for cutpoint-free programs Noam Rinetzky Tel Aviv University Joint work with Mooly Sagiv Tel Aviv University Eran Yahav.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Memory Management in Java Mr. Gerb Computer Science 4.
Automatic Memory Management Without Run-time Overhead Brian Brooks.
C11, Implications of Inheritance
Object Lifetime and Pointers
Compositional Pointer and Escape Analysis for Java programs
Compositional Pointer and Escape Analysis for Java Programs
Design-Driven Compilation
Incrementalized Pointer and Escape Analysis
자바 언어를 위한 정적 분석 (Static Analyses for Java) ‘99 한국정보과학회 가을학술발표회 튜토리얼
A Semantics for Procedure Local Heaps and its Abstractions
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Compile-Time Deallocation of Individual Objects Sigmund Cherem and Radu Rugina International Symposium on Memory Management June, 2006

Motivation Memory management challenges Effective reclamation of memory (precision) Transparent to users and applications Eliminate memory errors (safety) Minimize run-time overhead (efficiency) Support real-time systems (predictability) Automatic memory management Eliminate user ’ s responsibilities on MM

SafetyPrecision Overhead

SafetyPrecision Overhead No MM

SafetyPrecision Overhead Manual MM

SafetyPrecision Overhead Dynamic MM

SafetyPrecision Overhead Dynamic MM Compile-Time MM

SafetyPrecision Overhead Hybrid MM Dynamic MM Compile-Time MM

General Idea Estimate object lifetimes Reachability: objects reachable from stack variables Ref-counts: objects with some references into them Liveness: objects being used Transform programs to deallocate objects Regions: deallocate entire group of heap objects Stack allocation: place objects on stack frames Free statements: deallocate individual objects Our Approach Reference count based reachability Reclaim individual objects using “ free ” statements Flexibility, simplicity and efficiency

Running Example class L { D d; L n; } class D { int val; } L removeVal (L x, int v) { … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; } … return x; }

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; }

Running Example pc nnn ddd …… … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; }

Running Example pc n n n ddd …… … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; }

Running Example pc n n ddd …… … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; }

… L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; } Running Example pc n n ddd ……

… L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; } Running Example p n n ddd …… c

… L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; } Running Example pc n n ddd ……

p n n ddd …… c … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … free(c); ? c = p.n; }

Running Example p n n ddd …… c p,c nnn ddd …… … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … free(c); ? c = p.n; }

Running Example p n n ddd …… c p,c nnn ddd …… … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) free(c); c = p.n; }

Running Example p n n ddd …… c … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) free(c); c = p.n; }

Running Example p n n ddd …… c … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) { free(c.d); free(c); } c = p.n; }

Jfree Compiler Reference Count Analysis Insert Free Statements Java Bytecode Java Bytecode + Free

Reference Count Analysis Insert Free Statements Java Bytecode Java Bytecode + Free

Reference Count Analysis Determines when objects become unreachable Compute ref-counts for each object at each program point Track each object to determine its reference counts: Tracked Object Analysis Precision: able to distinguish between object instances Scalability at the inter-procedural level: large reuse of information on method summaries Extends shape analysis with local reasoning [HR POPL ’ 05] Taking advantage of type safety in Java Modeling Java programming practices or idioms

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n x y

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n x y y, n 1

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n xn1n1 y y, n 1

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n xn1n1 y y, n 1

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n xn1n1 d1d1 y y, n 1

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n xn1n1 d1d1 y y, n 1

Example concrete memory Abstract representation Use one unit (configuration) to represent individual objects Use heap reference counts, hit expressions, and more information about the object Each unit tracked independently Reference Count Analysis x nn dddd n xn1n1 d1d1 y y, n 1 (x.n)

Running Example pc …… … while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; c, n 1 (p.n)

Running Example … while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; pc …… c c, n 1 (p.n)

Running Example … while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; pc …… c c c, n 1 (p.n)

… while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; Running Example pc …… c c c c, n 1 (p.n)

… while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; Running Example p c …… c c c c, n 1 (p.n)

… while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … /* free(c); */ c = p.n; Running Example c p c …… c c c, n 1 (p.n)

Other Analysis Details (I) Abstraction Elements More than reference counts and hit expressions Miss expressions: expressions that don ’ t reference the object Expression equivalences: alias information about neighbors of tracked object Intra-procedural Analysis Dataflow analysis that starts at allocation sites Updates configurations on assignments Merges some configurations at merge points

Other Analysis Details (II) Inter-procedural Analysis Split configuration in halves Filter non-accessed information No need to analyze a portion not used by the callee Skip call if accessed portion is empty Add extended parameters Helps preserving precise information about equivalences Analyze callee Record and use method summaries Summaries are independent of caller information Combine Recover and merge non-accessed information

Reference Count Analysis Insert Free Statements Java Bytecode Java Bytecode + Free

Transformation Goal: automatically insert free statements to reclaim dead objects Technique At points where tracked object becomes unreachable Extract expression from responsible statement e = g;  free(e); Determine conditions for deallocation (discriminants) Look for hit expressions in other configurations Find a set of expressions that distinguishes them

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … c = p.n; } c, n 1 (p.n) cc, p, n 1

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if ( ??? ) { free(c); } c = p.n; } c, n 1 (p.n) cc, p, n 1

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) { free(c); } c = p.n; } c, n 1 (p.n) cc, p, n 1

Reference Count Analysis Insert Free Statements Java Bytecode Java Bytecode + Free

Reiteration Model a cascade effect of deallocations Deallocate multiple level structures Model the semantics of deallocation statements Temporarily add nullifications into code free(x)  x.f = null; No need to reanalyze whole program Cleanup and recompute affected part Limited to finite number of iterations Can ’ t deallocate recursive structures

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) { c.d = null; free(c); } c = p.n; }

Running Example … L p = x, c = p.n; while (c != null) { if (c.d.val == v) { p.n = c.n; c.n = null; } else p = c; … if (p != c) { free(c.d); free(c); } c = p.n; }

Analysis Enhancements Variable Equality Analysis Infer additional equivalences that exist prior to analysis starting point Variable Liveness Analysis Increases precision by reducing object lifetimes Allows to deallocate objects earlier Variable Uniqueness Analysis No need for conditional deallocation: decide deallocation in isolation Escape/effect analysis Accelerate inter-procedural analysis by improving filtering of information and skipping of calls

Experimental Evaluation

Settings and Analysis Times Jfree Compiler System Soot infrastructure SPECjvm98 Benchmarks Parameters for tuning speed and precision E.g. time cut-off to limit analysis time Compile-time statistics Average application size: 547 methods Average analysis time:1 ’ 37 ’’ (default parameters) Libraries code is analyzed, but not transformed JfreeVM Runtime System JikesRVM 2.3.5, MMTk

Memory Freed % of total allocated memory Default parameters

Memory Freed % of total allocated memory Best parameters

Integration with GC Normalized Memory Size Normalized Application Time MS Free + MS

Related Work Stack Allocation Blanchet OOPLSA ’ 99, Choi et al. OOPSLA ’ 99, Whaley and Rinard OOPSLA ’ 99, Bogda and Hoelzle OOPSLA ’ 99, Gay/Steensgard CC ’ 00 Regions Tofte and Talpin POPL ’ 94, AFL PLDI ’ 95, Cherem and Rugina ISMM ’ 04, Chin et al. PLDI ’ 04 Individual Object Deallocation Three-valued logic: Shaham et al. SAS ’ 03 Pointer analysis: Guyer et al. PLDI ’ 06 Shape Analysis Sagiv et al. POPL ’ 99, Hackett and Rugina POPL ’ 05

Conclusions Reference Count Analysis in Java Extensions to Shape Analysis w/Local Reasoning Inserting free statements Conditional deallocation Reclaiming structures Compiler results 50% of memory can be reclaimed statically Integration with GC 31% faster for small heaps