A New Solution to the Hidden Copy Problem

We consider the well-known problem of avoiding unnecessary costly copying that arises in languages with copy/value semantics and large aggregate structures such as arrays, sets, or files. The origins of many recent studies focusing on avoiding copies of flat arrays in functional languages may be traced back to SETL copy optimization [Schwartz 75]. The problem is hard, and progress is slow, but a successful solution is crucial to achieving a pointer-free style of programming envisioned by [Hoare 75]. We give a new solution to copy optimization that uses dynamic reference counts and lazy copying to implement updates efficiently in an imperative language with arbitrarily nested finite sets and maps (which can easily model arrays, records and other aggregate datatypes). Big step operational semantics and abstract interpretations are used to prove the soundness of the analysis and the correctness of the transformation. An efficient algorithm to implement the analysis is presented. The approach is supported by realistic empirical evidence. Our solution anticipates the introduction of arbitrarily nested polymorphic sets and maps into JAVA. It may also provide a new efficient strategy for implementing object cloning in Java and object assigment in C++. We illustrate how our methods might improve the recent approach of [Wand and Clinger 98] to avoid copies of flat arrays in a language of first-order recursion equations.

[1]  Flemming Nielson,et al.  Semantics with applications - a formal introduction , 1992, Wiley professional computing.

[2]  Reinhard Wilhelm,et al.  Solving shape-analysis problems in languages with destructive updating , 1998, TOPL.

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

[4]  Jacob T. Schwartz Automatic Data Structure Choice in a Language of Very High Level , 1975, POPL.

[5]  Zhe Yang,et al.  High level reading and data structure compilation , 1997, POPL '97.

[6]  Thomas I. M. Ho Review of On programming: an interim report on the SETL project, intallment II: the SETL language and examples of its use by J. T. Schwartz. New York University, 1973. , 1974, SIGP.

[7]  Jacob T. Schwartz,et al.  Optimization of Very High Level Languages - I. Value Transmission and Its Corollaries , 1975, Comput. Lang..

[8]  Edmond Schonberg,et al.  Programming with Sets: An Introduction to SETL , 1986 .

[9]  David A. Schmidt Data flow analysis is model checking of abstract interpretations , 1998, POPL '98.

[10]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[11]  Robert Paige,et al.  Program derivation with verified transformations — a case study , 1995 .

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

[13]  M. Wegman,et al.  Global value numbers and redundant computations , 1988, POPL '88.

[14]  Jozef Gruska Foundations of Computing , 1997 .

[15]  A. Deutsch,et al.  A storeless model of aliasing and its abstractions using finite representations of right-regular equivalence relations , 1992, Proceedings of the 1992 International Conference on Computer Languages.

[16]  Robert Paige,et al.  Viewing A Program Transformation System At Work , 1994, PLILP.

[17]  Edith Schonberg,et al.  Programming with Sets , 1986, Texts and Monographs in Computer Science.

[18]  S. Purushothaman Iyer,et al.  A Uniform Treatment of Order of Evalaution and Aggregate Update , 1993, Theor. Comput. Sci..

[19]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[20]  Robert E. Tarjan,et al.  A Unified Approach to Path Problems , 1981, JACM.

[21]  K. R. Simmonds A prize in use , 1985 .

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

[23]  John Cocke,et al.  Programming languages and their compilers , 1969 .

[24]  C. Hoare,et al.  Data reliability , 1975, Reliable Software.

[25]  G. Winskel The formal semantics of programming languages , 1993 .

[26]  John E. Hopcroft,et al.  An n log n algorithm for minimizing states in a finite automaton , 1971 .

[27]  Jacob T. Schwartz,et al.  On programming : an interim report on the SETL Project , 1973 .

[28]  Robert Paige,et al.  Towards increased productivity of algorithm implementation , 1993, SIGSOFT '93.

[29]  Mitchell Wand,et al.  Set constraints for destructive array update optimization , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).