article

Solving shape-analysis problems in languages with destructive updating

Abstract

This article concerns the static analysis of programs that perform destructive updating on heap-allocated storage. We give an algorithm that uses finite shape graphs to approximate conservatively the possible “shapes” that heap-allocated structures in a program can take on. For certain programs, our technique is able to determine such properties as (1) when the input to the program is a list, the output is also a list and (2) when the input to the program is a tree, the output is also a tree. For example, the method can determine that “listness” is preserved by (1) a program that performs list reversal via destructive updating of the input list and (2) a program that searches a list and splices a new element into the list. None of the previously known methods that use graphs to model the program's store are capable of determining that “listness” is preserved on these examples (or examples of similar complexity). In contrast with most previous work, our shape analysis algorithm is even accurate for certain programs that update cyclic data structures; that is, it is sometimes able to show that when the input to the program is a circular list, the output is also a circular list. For example, the shape-analysis algorithm can determine that an insertion into a circular list preserves “circular listness.”

References

  1. ASSMANN, W. AND WEINHARDT, M. 1993. Interprocedural heap analysis for parallelizing imperative programs. In Programming Models For Massively Parallel Computers, W. K. Giloi, S. JS~hnichen, and B. D. Shriver, Eds. IEEE Computer Society, Washington, D.C., 74-82.Google ScholarGoogle Scholar
  2. CHASE, D., WEGMAN, M., AND ZADECK, F. 1990. Analysis of pointers and structures. In SIGPLAN Conference on Programming Languages Design and Implementation. ACM Press, New York, 296-310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. CHOI, J.-D., BURKE, M., AND CARINI, P. 1993. Efficient flow-sensitive interprocedural computation of pointer-induced aliases and side-effects. In Proceedings of the A CM Symposium on Principles of Programming Languages. ACM Press, New York, 232-245. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. COUSOT, P. AND COUSOT, R. 1977. Abstract interpretation: A unified lattice model for static analysis of programs by construction of approximation of fixed points. In Proceedings of the A CM Symposium on Principles of Programming Languages. ACM Press, New York, 238-252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. DEUTSCH, t. 1992. A storeless model for aliasing and its abstractions using finite representations of right-regular equivalence relations. In Proceedings of the IEEE International Conference on Computer Languages. IEEE Computer Society, Washington, D.C., 2-13.Google ScholarGoogle ScholarCross RefCross Ref
  6. DEUTSCH, t. 1994. Interprocedural may-alias analysis for pointers: Beyond k-limiting. In SIC- PLAN Conference on Programming Languages Design and Implementation. ACM Press, New York, 230-241. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. GHIYA, R. AND HENDREN, L. 1996. Is it a tree, a dag, or a cyclic graph? In Proceedings of the A CM Symposium on Principles of Programming Languages. ACM Press, New York. Available via ftp://ftp-acaps.cs.mcgill.ca/pub/doc/papers/POPL96.ps.gz. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. HEINTZE, N. 1992. Set-based program analysis. Ph.D. thesis, School of Computer Science, Carnegie Mellon Univ., Pittsburgh, Pa. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. HENDREN, L. 1990. Parallelizing programs with recursive data structures. Ph.D. thesis, Cornell Univ., Ithaca, N.Y. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. HENDREN, L. AND GAO, G. 1992. Designing programming languages for analyzability: A fresh look at pointer data structures. In Proceedings of the International Conference on Computer Languages. IEEE Computer Society, Washington, D.C., 242-251.Google ScholarGoogle ScholarCross RefCross Ref
  11. HENDREN, L., HUMMEL, J., AND NICOLAU, t. 1992. Abstractions for recursive pointer data structures: Improving the analysis and the transformation of imperative programs. In SIGPLAN Conference on Programming Languages Design and Implementation. ACM Press, New York, 249-260. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. HENDREN, L. AND NICOLAU, A. 1990. Parallelizing programs with recursive data structures. IEEE Trans. Parallel Distrib. Syst. 1, 1 (Jan.), 35-47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. HORWITZ, S., PFEIFFER, P., AND REPS, T. 1989. Dependence analysis for pointer variables. In SIGPLAN Conference on Programming Languages Design and Implementation. ACM Press, New York, 28-40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. JONES, N. AND MUCHNICK, S. 1981. Flow analysis and optimization of Lisp-like structures. In Program Flow Analysis: Theory and Applications, S. Muchnick and N. Jones, Eds. Prentice- Hall, Englewood Cliffs, N.J., Chapter 4, 102-131.Google ScholarGoogle Scholar
  15. JONES, N. AND MUCHNICK, S. 1982. A flexible approach to interprocedural data flow analysis and programs with recursive data structures. In Proceedings of the A CM Symposium on Principles of Programming Languages. ACM Press, New York, 66-74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. KNUTH, D. E. 1973. The Art of Computer Programming. Vol. 1, Fundamental Algorithms. 2nd. ed. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. LANDI, W. 1992. Undecidability of static analysis. ACM Lett. Program. Lang. Syst. 1, 4, 323-337. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. LANDI, W. AND RYDER, B. 1991. Pointer induced aliasing: A problem classification. In Proceedings of the A CM Symposium on Principles of Programming Languages. ACM Press, New York, 93- 103. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. LARUS, J. 1989. Restructuring symbolic programs for concurrent execution on multiprocessors. Ph.D. thesis, Univ. of California, Berkeley, Calif. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. LARUS, J. AND HILFINGER, P. 1988. Detecting conflicts between structure accesses. In SIGPLAN Conference on Programming Languages Design and Implementation. ACM Press, New York, 21-34. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. LINDSTROM, G. 1973. Scanning list structures without stacks or tag bits. Inf. Process. Lett. 2, 2 (June), 47-51.Google ScholarGoogle ScholarCross RefCross Ref
  22. MOGENSEN, T. 1988. Partially static structures in a self-applicable partial evaluator. In Partial Evaluation and Mixed Computation: Proceedings of the IFIP TC2 Workshop on Partial Evaluation and Mixed Computation (Gammel Avernaes, Denmark, Oct 18-24, 1987). North-Holland, Amsterdam, 325-347.Google ScholarGoogle Scholar
  23. MOGENSEN, T. 1989. Separating binding times in language specifications. In Proceedings of the gth International Conference on Functional Programming and Computer Architecture. ACM Press, New York, 12-25. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. MYERS, E. 1981. A precise inter-procedural data flow algorithm. In Proceedings of the ACM Symposium on Principles of Programming Languages. ACM Press, New York, 219-230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. PLEVYAK, J., CHIEN, A., AND KARAMCHETI, V. 1993. Analysis of dynamic structures for efficient parallel execution. In Languages and Compilers for Parallel Computing, U. Banerjee, D. Gelernter, A. Nicolau, and D. Padua, Eds. Lecture Notes in Computer Science, vol. 768. Springer-Verlag, Berlin, 37-57. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. RAMAKRISHNAN, R., SESHADRI, P., SRIVASTAVA, D., AND SUDARSHAN, S. 1993. Implementation of the CORAL deductive database system. In Proceedings of the A CM SIGMOD 93 Conference. ACM Press, New York, 167-176. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. RAMALINGAM, G. 1994. The undecidability of aliasing. ACM Trans. Program. Lang. Syst. 16, 5, 1467-1471. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. REPS, T. 1995. Shape analysis as a generalized path problem. In Proceedings of the ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation, PEPM'95. ACM Press, New York, 1-11. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. REYNOLDS, J. 1968. Automatic computation of data set definitions. In Information Processing 68: Proceedings of the IFIP Congress. North-Holland, Amsterdam, 456-461.Google ScholarGoogle Scholar
  30. SAGIV, ~/{., REP$, T., AND WILHELM, R. 1995. Solving shape-anMysis problems in languages with destructive updating. Tech. Rep. TR-1276, Computer Sciences Dept., Univ. of Wisconsin, Madison, Wisc. July. Available via http:////www.cs.wisc.edu//trs.html.Google ScholarGoogle Scholar
  31. SEDGEWICK, R. 1988. Algorithms. 2nd ed. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. SHARIR, ~/{. AND PNUELI, t. 1981. Two approaches to interprocedurM data flow analysis. In Program Flow Analysis: Theory and Applications, S. Muchnick and N. Jones, Eds. Prentice- Hall, Englewood Cliffs, N.J., 189-234.Google ScholarGoogle Scholar
  33. STRANSKY, J. 1992. A lattice for abstract interpretation of dynamic (Lisp-like) structures. Inf. Comput. 101, 1 (Nov.), 70-102. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. WARREN, D. 1992. Memoing for logic programs. Commun. ACM 35, 3 (Mar.), 93-111. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Solving shape-analysis problems in languages with destructive updating

                          Reviews

                          Max Hailperin

                          An abstract interpretation of imperative programs mutating pointer-based structures is presented. This interpretation can reach conclusions such as that inserting into a circular list yields a circular list, while inserting into an acyclic list yields an acyclic list. Each program point is assigned an abstract store resulting from three forms of abstraction: joining information from all program paths leading to the point, generalizing over program inputs, and bounding the number of objects. The last of these embodies the biggest innovation: the manner in which the unboundedly large collection of run-time objects is mapped to an analysis-time collection that is at worst exponentially large in the program size. One abstract object is used per alias configuration, that is, per possible set of aliased pointer variables, including one abstract object to represent all concrete objects that are not directly referenced by any variable. The authors also associate an is-shared bit with each abstract object. This bit shows whether sharing in the abstract store reflects sharing in the concrete store or is an artifact of abstraction. The main empirical result of the paper is that synergism between these is-shared bits and the per-alias-configuration allocation of abstract objects produces precise analysis results for a number of example programs. The authors skillfully use a running example to open up what would otherwise be a difficult paper to a potential audience of empirical investigators and practical adapters, who will find plenty of fertile ground for their work.

                          Access critical reviews of Computing literature here

                          Become a reviewer for Computing Reviews.

                          Comments

                          Login options

                          Check if you have access through your login credentials or your institution to get full access on this article.

                          Sign in

                          Full Access

                          PDF Format

                          View or Download as a PDF file.

                          PDF

                          eReader

                          View online with eReader.

                          eReader
                          About Cookies On This Site

                          We use cookies to ensure that we give you the best experience on our website.

                          Learn more

                          Got it!