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.
This research was partially supported by Office of Naval Research Grant No. N00014-93-1-0924, and National Science Foundation grant CCR-9616993.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
ADA UK News, Vol. 6, No. 1, pp. 14–15, Jan 1985.
A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools. Addison Wesley, 1988.
J. Cai and R. Paige. Towards increased productivity of algorithm implementation. In Proc. ACM SIGSOFT, pages 71–78, Dec. 1993.
J. Cocke and J. Schwartz. Programming Languages and Their Compilers. Lecture Notes. Courant Institute, New York University, New York, 1969.
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.
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.
M. Draghicescu and S. Purushotham. A uniform treatment of order of evaluation and aggregate update. Theoretical Computer Science, 118:231–262, 1993.
C. A. R. Hoare. Data reliability. In Proc. of the Intl. Conf. on Reliable Software, pages 528–533, 1975.
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.
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.
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.
G. Kahn. Natural semantics. In Proc. STACS’87. Springer-Verlag, 1987. Lecture Notes in Computer Science, Vol. 247.
J. B. Kam and J. D. Ullman. Monotone data flow analysis frameworks. Acta Informatica, 7:305–317, 1977.
J. Keller and R. Paige. Program derivation with verified transformations-a case study. CPAM, 48(9–10), 1995.
G. A. Kildall. A unified approach to global program optimization. In ACM Symp. on Principles of Prog. Lang., pages 194–206, 1973.
H. R. Nielson and F. Nielson. Semantics with Applications, A formal introduction. Wiley, 1992.
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).
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.
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.
M. Sagiv, T. Reps, and R. Wilhelm. Solving shape analysis problems in languages with destructive updating. ACM TOPLAS, 20(1):1–50, January 1998.
D. A. Schmidt. Data flow analysis is model checking of abstract interpretations. In 25th ACM SIGPLAN-SIGACT Symp. on Principles of Prog. Lang., 1998.
J. Schwartz. On Programming: An Interim Report on the SETL Project, Installments I and II. New York University, New York, 1974.
J. Schwartz. Automatic data structure choice in a language of very high level. CACM, 18(12):722–728, Dec. 1975.
J. Schwartz. Optimization of very high level languages, parts I, II. J. of Computer Languages, 1(2–3):161–218, 1975.
J. Schwartz, R. Dewar, E. Dubinsky, and E. Schonberg. Programming with Sets: An Introduction to SETL. Springer-Verlag, New York, 1986.
M. Sharir. A few cautionary notes on the convergence of iterative data-flow analysis algorithms. Setl Newsletter 208, New York University, April 1978.
K. Snyder. The SETL2 programming language. Technical Report 490, Courant Insititute, New York University, 1990.
R. E. Tarjan. A unified approach to path problems. JACM, 28(3):577–593, July 1981.
M. Wand and W. D. Clinger. Set constraints for destructive array update optimization. In Proc. IEEE Conf. on Computer Languages. IEEE, May 1998.
G. Winskell. The Formal Semantics of Programming Languages. Foundations of Computing. MIT Press, 1994.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Goyal, D., Paige, R. (1998). A New Solution to the Hidden Copy Problem. In: Levi, G. (eds) Static Analysis. SAS 1998. Lecture Notes in Computer Science, vol 1503. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-49727-7_20
Download citation
DOI: https://doi.org/10.1007/3-540-49727-7_20
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-65014-0
Online ISBN: 978-3-540-49727-1
eBook Packages: Springer Book Archive