Escape analysis for Java

This paper presents a simple and efficient data flow algorithm for escape analysis of objects in Java programs to determine (i) if an object can be allocated on the stack; (ii) if an object is accessed only by a single thread during its lifetime, so that synchronization operations on that object can be removed. We introduce a new program abstraction for escape analysis, the connection graph, that is used to establish reachability relationships between objects and object references. We show that the connection graph can be summarized for each method such that the same summary information may be used effectively in different calling contexts. We present an interprocedural algorithm that uses the above property to efficiently compute the connection graph and identify the non-escaping objects for methods and threads. The experimental results, from a prototype implementation of our framework in the IBM High Performance Compiler for Java, are very promising. The percentage of objects that may be allocated on the stack exceeds 70% of all dynamically created objects in three out of the ten benchmarks (with a median of 19%), 11% to 92% of all lock operations are eliminated in those ten programs (with a median of 51%), and the overall execution time reduction ranges from 2% to 23% (with a median of 7%) on a 333 MHz PowerPC workstation with 128 MB memory.

[1]  James C. Corbett,et al.  Constructing compact models of concurrent Java programs , 1998, ISSTA '98.

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

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

[4]  Urs Hölzle,et al.  Removing unnecessary synchronization in Java , 1999, OOPSLA '99.

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

[6]  Wilson C. Hsieh,et al.  The Need for Predictable Garbage Collection , 1999 .

[7]  Jong-Deok Choi,et al.  Flow-Insensitive Interprocedural Alias Analysis in the Presence of Pointers , 1994, LCPC.

[8]  Jong-Deok Choi,et al.  Efficient and precise modeling of exceptions for the analysis of Java programs , 1999, ACM SIGSOFT Softw. Eng. Notes.

[9]  Emin Gün Sirer,et al.  Static Analyses for Eliminating Unnecessary Synchronization from Java Programs , 1999, SAS.

[10]  Zhiyuan Li,et al.  On Reducing Data Synchronization in Multiprocessed Loops , 1987, IEEE Transactions on Computers.

[11]  Jong-Deok Choi,et al.  Interprocedural pointer alias analysis , 1999, TOPL.

[12]  Julian Dolby Automatic inline allocation of objects , 1997, PLDI '97.

[13]  Jong-Deok Choi,et al.  Efficient and precise modeling of exceptions for the analysis of Java programs , 1999, PASTE '99.

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

[15]  Martin C. Rinard,et al.  Compositional pointer and escape analysis for Java programs , 1999, OOPSLA '99.

[16]  Martin C. Rinard,et al.  Synchronization transformations for parallel computing , 1999, POPL '97.

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

[18]  David A. Padua,et al.  Compiler Algorithms for Synchronization , 1987, IEEE Transactions on Computers.

[19]  Mauricio J. Serrano,et al.  Thin locks: featherweight synchronization for Java , 1998, PLDI '98.

[20]  Bruno Blanchet,et al.  Escape analysis for object-oriented languages: application to Java , 1999, OOPSLA '99.

[21]  Bjarne Steensgaard Stack Allocating Objects in Java , 1998 .

[22]  Laurie J. Hendren,et al.  Putting pointer analysis to work , 1998, POPL '98.

[23]  Gary A. Kildall,et al.  A unified approach to global program optimization , 1973, POPL.

[24]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

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