Inserting Safe Memory Re-use Commands into ML-like Programs

We present a static analysis that estimates reusable memory cells and a source-level transformation that adds explicit memory-reuse commands into the program text. For benchmark ML programs, our analysis and transformation achieves the memory reuse ratio from 5.2% to 91.3%. The small-ratio cases are for programs that have too prevalent sharings among memory cells. For other cases, our experimental results are encouraging in terms of accuracy and cost. Major features of our analysis are: (1) poly-variant analysis of functions by parameterization for the argument heap cells; (2) use of multiset formulas in expressing the sharings and partitionings of heap cells; (3) deallocations conditioned by dynamic flags that are passed as extra arguments to functions; (4) individual heap cell as the granularity of explicit memory-free. Our analysis and transformation is fully automatic.

[1]  Martin Hofmann,et al.  Another Type System for In-Place Update , 2002, ESOP.

[2]  James Cheney,et al.  Region-based memory management in cyclone , 2002, PLDI '02.

[3]  David Walker,et al.  Alias Types , 2000, ESOP.

[4]  Peter W. O'Hearn,et al.  Local Reasoning about Programs that Alter Data Structures , 2001, CSL.

[5]  Lars Birkedal,et al.  A region inference algorithm , 1998, TOPL.

[6]  G. Morrisett,et al.  Alias Types for Re ursive Data Stru tures ? , 2000 .

[7]  David Walker,et al.  Typed memory management in a calculus of capabilities , 1999, POPL '99.

[8]  Damien Doligez,et al.  The Objective Caml system release 2.04 , 2002 .

[9]  David Gay,et al.  Language support for regions , 2001, PLDI '01.

[10]  Xavier Leroy The objective caml system release 3 , 2001 .

[11]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[12]  Hongseok Yang,et al.  Correctness proof on an algorithm to insert safe memory reuse commands , 2003 .

[13]  Naoki Kobayashi Quasi-linear types , 1999, POPL '99.

[14]  Mads Tofte,et al.  Region-based Memory Management , 1997, Inf. Comput..

[15]  Bruno Blanchet,et al.  Escape analysis: correctness proof, implementation and experimental results , 1998, POPL '98.

[16]  Martin Elsman,et al.  Programming with regions in the ml kit (for version 4) , 1998 .

[17]  Robert Harper,et al.  Typed closure conversion , 1996, POPL '96.

[18]  Pierre Falzon,et al.  Institut national de recherche en informatique et en automatique , 1992 .

[19]  Philip Wadler,et al.  Once upon a type , 1995, FPCA '95.

[20]  Markus Mohnen Efficient Compile-Time Garbage Collection for Arbitrary Data Structures , 1995, PLILP.

[21]  Mads Tofte,et al.  Implementation of the typed call-by-value λ-calculus using a stack of regions , 1994, POPL '94.

[22]  David Walker,et al.  Alias Types for Recursive Data Structures , 2000, Types in Compilation.

[23]  Martin C. Rinard,et al.  Interprocedural compatibility analysis for static object preallocation , 2003, POPL.

[24]  Williams Ludwell Harrison,et al.  The interprocedural analysis and automatic parallelization of Scheme programs , 1990, LISP Symb. Comput..

[25]  John C. Reynolds,et al.  Separation logic: a logic for shared mutable data structures , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[26]  Erik Barendsen,et al.  Uniqueness Typing for Functional Languages with Graph Rewriting Semantics , 1996, Math. Struct. Comput. Sci..

[27]  Martin Rinard,et al.  Interprocedural compatibility analysis for static object preallocation , 2003, POPL '03.