Escape analysis: correctness proof, implementation and experimental results

We describe an escape analysis [32, 14], used to determine whether the lifetime of data exceeds its static scope.We give a new correctness proof starting directly from a semantics. Contrary to previous proofs, it takes into account all the features of functional languages, including imperative features and polymorphism. The analysis has been designed so that it can be implemented under the small complexity bound of O(n log2 n) where n is the size of the analyzed program. We have included it in the Caml Special Light compiler (an implementation of ML), and applied it to very large programs. We plan to apply these techniques to the Java programming language.Escape analysis has been applied to stack allocation. We improve the optimization technique by determining minimal lifetime for stack allocated data, and using inlining. We manage to stack allocate 25% of data in the theorem prover Coq. We analyzed the effect of this optimization, and noticed that its main effect is to improve data locality, which is important for efficiency.

[1]  Lars Birkedal,et al.  From region inference to von Neumann machines via region representation inference , 1996, POPL '96.

[2]  Alain Deutsch,et al.  Interprocedural may-alias analysis for pointers: beyond k-limiting , 1994, PLDI '94.

[3]  Mads Tofte,et al.  A theory of stack allocation in polymorphically typed languages , 1993 .

[4]  Williams Ludwell HarrisonIII The interprocedural analysis and automatic parallelization of Scheme programs , 1989 .

[5]  Thomas P. Murtagh,et al.  Lifetime analysis of dynamically allocated objects , 1988, POPL '88.

[6]  Robert E. Tarjan,et al.  Applications of Path Compression on Balanced Trees , 1979, JACM.

[7]  Alain Deutsch,et al.  On the complexity of escape analysis , 1997, POPL '97.

[8]  James Hicks,et al.  Experiences with compiler-directed storage reclamation , 1993, FPCA '93.

[9]  Olin Shivers,et al.  Control flow analysis in scheme , 1988, PLDI '88.

[10]  Alain Deutsch,et al.  On determining lifetime and aliasing of dynamically allocated data in higher-order functional specifications , 1989, POPL '90.

[11]  Marc Feeley,et al.  Storage use analysis and its applications , 1996, ICFP '96.

[12]  Samson Abramsky,et al.  Strictness analysis and polymorphic invariance , 1985, Programs as Data Objects.

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

[14]  Markus Mohnen,et al.  Efficient Closure Utilisation by Higher-Order Inheritance Analysis , 1995, SAS.

[15]  Robert E. Tarjan,et al.  Finding Dominators in Directed Graphs , 1974, SIAM J. Comput..

[16]  Lucy Hederman Compile time garbage collection using reference count analysis , 1989 .

[17]  David R. Chase,et al.  Safety consideration for storage allocation optimizations , 1988, PLDI '88.

[18]  Andrew W. Appel,et al.  Garbage Collection can be Faster than Stack Allocation , 1987, Inf. Process. Lett..

[19]  Katsuro Inoue,et al.  Analysis of functional programs to detect run-time garbage cells , 1988, TOPL.

[20]  Geoffrey L. Burn A relationship between abstract interpretation and projection analysis , 1989, POPL '90.

[21]  Michael White,et al.  Is Compile Time Garbage Collection Worth the Effort? , 1990, Functional Programming.

[22]  Paul Hudak A semantic model of reference counting and its abstraction (detailed summary) , 1986, LFP '86.

[23]  Neil D. Jones,et al.  A flexible approach to interprocedural data flow analysis and programs with recursive data structures , 1982, POPL '82.

[24]  Andrew W. Appel,et al.  Empirical and Analytic Study of Stack Versus Heap Cost for Languages with Closures , 1996, J. Funct. Program..

[25]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[26]  John Hannan A Type-based Analysis for Stack Allocation in Functional Languages , 1995, SAS.

[27]  Prakash Panangaden,et al.  Computation of aliases and support sets , 1987, POPL '87.

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

[29]  Benjamin Goldberg,et al.  Escape analysis on lists , 1992, PLDI '92.

[30]  Alexander Aiken,et al.  Better static memory management: improving region-based analysis of higher-order languages , 1995, PLDI '95.

[31]  Donald E. Knuth,et al.  A Generalization of Dijkstra's Algorithm , 1977, Inf. Process. Lett..

[32]  Simon Hughes,et al.  Compile-Time Garbage Collection for Higher-Order Functional Languages , 1992, J. Log. Comput..

[33]  Robin Milner,et al.  Definition of standard ML , 1990 .

[34]  Patrick Cousot,et al.  Systematic design of program analysis frameworks , 1979, POPL.

[35]  Chau-Wen Tseng,et al.  Compiler optimizations for improving data locality , 1994, ASPLOS VI.

[36]  Zhong Shao,et al.  An Empirical and Analytic Study of Stack vs . Heap Cost for Languages with Closures , 1993 .

[37]  C. A. R. Hoare,et al.  Some Properties of Predicate Transformers , 1978, JACM.