SAS 1998: Static Analysis pp 327-348 | Cite as

A New Solution to the Hidden Copy Problem

  • Deepak Goyal
  • Robert Paige
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1503)

Abstract

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 effciently 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.

Keywords

Copy Optimization Big Step Operational Semantics Abstract Interpretation Must Alias Analysis 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    ADA UK News, Vol. 6, No. 1, pp. 14–15, Jan 1985.Google Scholar
  2. 2.
    A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools. Addison Wesley, 1988.Google Scholar
  3. 3.
    J. Cai and R. Paige. Towards increased productivity of algorithm implementation. In Proc. ACM SIGSOFT, pages 71–78, Dec. 1993.Google Scholar
  4. 4.
    J. Cocke and J. Schwartz. Programming Languages and Their Compilers. Lecture Notes. Courant Institute, New York University, New York, 1969.Google Scholar
  5. 5.
    P. Cousot and R. Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixed points. In Proc. 4th ACM Symp. on Principles of Prog. Lang., pages 238–252, 1977.Google Scholar
  6. 6.
    A. Deutsch. A storeless model of aliasing and its abstractions using finite representations of right-regular equivalence relations. In International Conference on Computer Languages, pages 2–13. IEEE, 1992.Google Scholar
  7. 7.
    M. Draghicescu and S. Purushotham. A uniform treatment of order of evaluation and aggregate update. Theoretical Computer Science, 118:231–262, 1993.MATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    C. A. R. Hoare. Data reliability. In Proc. of the Intl. Conf. on Reliable Software, pages 528–533, 1975.Google Scholar
  9. 9.
    J. Hopcroft. An n log n algorithm for minimizing states in a finite automaton. In Z. Kohavi and A. Paz, editors, Theory of Machines and Computations, pages 189–196. Academic Press, New York, 1971. Proc. Intl. Symp. on Theory of Machines and Computation.Google Scholar
  10. 10.
    P. Hudak. A semantic model of reference counting and its abstraction. In Proc. 1986 ACM Symp. on Lisp and Func. Prog., pages 351–363. ACM, 1986.Google Scholar
  11. 11.
    P. Hudak and A. Bloss. Avoiding copying in functional and logic programming languages. In Proc. 12th Annual ACM Symp. on Principles of Prog. Lang., pages 300–314. ACM, 1985.Google Scholar
  12. 12.
    G. Kahn. Natural semantics. In Proc. STACS’87. Springer-Verlag, 1987. Lecture Notes in Computer Science, Vol. 247.Google Scholar
  13. 13.
    J. B. Kam and J. D. Ullman. Monotone data flow analysis frameworks. Acta Informatica, 7:305–317, 1977.MATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    J. Keller and R. Paige. Program derivation with verified transformations-a case study. CPAM, 48(9–10), 1995.Google Scholar
  15. 15.
    G. A. Kildall. A unified approach to global program optimization. In ACM Symp. on Principles of Prog. Lang., pages 194–206, 1973.Google Scholar
  16. 16.
    H. R. Nielson and F. Nielson. Semantics with Applications, A formal introduction. Wiley, 1992.Google Scholar
  17. 17.
    R. Paige. Viewing a program transformation system at work. In M. Hermenegildo and J. Penjam, editors, Programming Language Implementation and Logic, volume 844 of LNCS, pages 5–24. Springer-Verlag, Berlin, Sep. 1994. Proc. Joint 6th Intl. Conf. on Prog. Lang. Impl. and Logic Prog. (PLILP) and 4th Intl. Conf. on Algebraic and Logic Prog. (ALP).Google Scholar
  18. 18.
    R. Paige and Z. Yang. High level reading and data structure compilation. In Proc. 24th ACM SIGPLAN-SIGACT Symp. on Principles of Prog. Lang., pages 456–469, Paris, France, 15–17 Jan. 1997.Google Scholar
  19. 19.
    B. K. Rosen, M. Wegman, and K. Zadeck. Global value numbers and redundant computations. In ACM Symp. on Principles of Prog. Lang., pages 12–27, 1988.Google Scholar
  20. 20.
    M. Sagiv, T. Reps, and R. Wilhelm. Solving shape analysis problems in languages with destructive updating. ACM TOPLAS, 20(1):1–50, January 1998.Google Scholar
  21. 21.
    D. A. Schmidt. Data flow analysis is model checking of abstract interpretations. In 25th ACM SIGPLAN-SIGACT Symp. on Principles of Prog. Lang., 1998.Google Scholar
  22. 22.
    J. Schwartz. On Programming: An Interim Report on the SETL Project, Installments I and II. New York University, New York, 1974.Google Scholar
  23. 23.
    J. Schwartz. Automatic data structure choice in a language of very high level. CACM, 18(12):722–728, Dec. 1975.Google Scholar
  24. 24.
    J. Schwartz. Optimization of very high level languages, parts I, II. J. of Computer Languages, 1(2–3):161–218, 1975.MATHCrossRefGoogle Scholar
  25. 25.
    J. Schwartz, R. Dewar, E. Dubinsky, and E. Schonberg. Programming with Sets: An Introduction to SETL. Springer-Verlag, New York, 1986.MATHGoogle Scholar
  26. 26.
    M. Sharir. A few cautionary notes on the convergence of iterative data-flow analysis algorithms. Setl Newsletter 208, New York University, April 1978.Google Scholar
  27. 27.
    K. Snyder. The SETL2 programming language. Technical Report 490, Courant Insititute, New York University, 1990.Google Scholar
  28. 28.
    R. E. Tarjan. A unified approach to path problems. JACM, 28(3):577–593, July 1981.Google Scholar
  29. 29.
    M. Wand and W. D. Clinger. Set constraints for destructive array update optimization. In Proc. IEEE Conf. on Computer Languages. IEEE, May 1998.Google Scholar
  30. 30.
    G. Winskell. The Formal Semantics of Programming Languages. Foundations of Computing. MIT Press, 1994.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1998

Authors and Affiliations

  • Deepak Goyal
    • 1
  • Robert Paige
    • 1
  1. 1.New York UniversityNY

Personalised recommendations