A principled approach to nondeferred reference-counting garbage collection

Nondeferred reference-counting (RC) garbage collection is among the oldest memory-management methods. Despite offering unique advantages, little attention has been paid on how to correctly implement it for modern programming languages. This paper revisits this collection method and describes how to implement it for a modern object-oriented language in an optimizing compiler. The main contribution is a general algorithm that realizes one form of nondeferred RC collection for an object-oriented language having features such as exceptions, interior pointers, and object pinning. The algorithm abstracts the pertinent characteristics of instructions using concepts from data-flow analysis, such as def/use information, so that instructions are handled in a uniform manner, instead of in an ad hoc or special-case way. The abstracted information is used to systematically compute what increments and decrements to do, even in the presence of subtle conditions such as exceptional control flow. These techniques enabled us to compile a large suite of programs to use nondeferred RC collection. The paper also discusses the modifications that were necessary in the compiler for supporting the inserted RC operations, and reports measurements from a reference implementation.

[1]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[2]  George E. Collins,et al.  A method for overlapping and erasure of lists , 1960, CACM.

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

[4]  Hans-J Boehm Simple Gc-safe Compilation , 1991 .

[5]  Pramod G. Joisha Overlooking roots: a framework for making nondeferred reference-counting garbage collection fast , 2007, ISMM '07.

[6]  Daniel G. Bobrow,et al.  An efficient, incremental, automatic garbage collector , 1976, CACM.

[7]  B. J. Epstein List of Tables xi , 2012 .

[8]  Benjamin Goldberg,et al.  Reference escape analysis: optimizing reference counting based on the lifetime of references , 1991, PEPM '91.

[9]  David Detlefs,et al.  Garbage collection and local variable type-precision and liveness in Java virtual machines , 1998, PLDI.

[10]  Pramod G. Joisha,et al.  Compiler optimizations for nondeferred reference: counting garbage collection , 2006, ISMM '06.

[11]  Peter Lee,et al.  TIL: a type-directed, optimizing compiler for ML , 2004, SIGP.

[12]  Jeffrey M. Barth Shifting garbage collection overhead to compile time , 1977, CACM.

[13]  H. Gelernter,et al.  A FORTRAN-compiled list-processing language , 1959, ACM '59.

[14]  Mads Torgersen,et al.  C# Programming Language , 2003 .

[15]  Rafael Dueire Lins,et al.  Garbage collection: algorithms for automatic dynamic memory management , 1996 .

[16]  Stephen J. Fink,et al.  The Jalapeño virtual machine , 2000, IBM Syst. J..

[17]  James Gosling The Java Language Specification - Second Edition , 2000 .

[18]  V. T. Rajan,et al.  A unified theory of garbage collection , 2004, OOPSLA '04.

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

[20]  Amer Diwan,et al.  Compiler support for garbage collection in a statically typed language , 1992, PLDI '92.

[21]  Guy L. Steele,et al.  Java Language Specification, Second Edition: The Java Series , 2000 .

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

[23]  James M. Stichnoth,et al.  Support for garbage collection at every instruction in a Java compiler , 1999, PLDI '99.

[24]  Amer Diwan,et al.  On the usefulness of type and liveness accuracy for garbage collection and leak detection , 2002, TOPL.

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

[26]  Don Box,et al.  Essential .NET: The Common Language Runtime , 2002 .

[27]  Frank Yellin,et al.  The Java Virtual Machine Specification , 1996 .

[28]  Andrew W. Appel,et al.  RETROSPECTIVE : Real-time Concurrent Collection on Stock Multiprocessors , 2004 .

[29]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..