Advertisement

Higher order escape analysis: Optimizing stack allocation in functional program implementations

  • Benjamin Goldberg
  • Young Gil Park
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 432)

Abstract

In this paper, we present a method for optimizing the allocation of closures in memory. This method is based on escape analysis, an application of abstraction interpretation to higher order functional languages. Escape analysis determines, at compile time, if any arguments to a function have a greater lifetime than the function call itself. Such arguments, especially if they are closures, must be allocated in the heap rather than in the stack. In most implementations, however, stack allocation of closures is preferable due to the lower cost of allocation and reclamation. Therefore, we use escape analysis to determine when arguments can be stack allocated safely.

In the past, first order escape analysis has been used in optimizing LISP compilers, and has been described in various data-flow analysis frameworks for a language with complex types. The analysis described here, being higher order, provides more accurate escape information, although for a very simple higher order functional language.

References

  1. [AM87]
    A. Appel and D.B. MacQueen. A standard ML compiler. In Proceedings of the 1987 Conference on Functional Programming and Computer Architecture. September, 1987.Google Scholar
  2. [Barth77]
    J.M. Barth. Shifting garbage collection overhead to compile time. Communications of the ACM, 20(7), July 1977.Google Scholar
  3. [BHA85]
    G.L. Burn, C.L. Hankin, and S. Abramsky. The theory of strictness analysis for higher order functions. In Programs as Data Objects, LNCS 217. Springer-Verlag. 1985Google Scholar
  4. [CC77]
    P. Cousot and R. Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th Annual ACM Symposium on Principles of Programming Languages. January 1977.Google Scholar
  5. [Chase87]
    D.R. Chase. Garbage Collection and Other Optimizations. Ph.D. Thesis, Rice University. 1987Google Scholar
  6. [Chase88]
    D.R. Chase. Safety considerations for storage allocation optimizations. In Proceedings of the 1987 Conference on Functional Programming and Computer Architecture. September, 1987.Google Scholar
  7. [Goldberg87]
    B. Goldberg. Detecting sharing of partial applications in functional programs. In Proceedings of the 1987 Conference on Functional Programming and Computer Architecture. September, 1987.Google Scholar
  8. [HY86]
    P. Hudak and J. Young. Higher-order strictness analysis for the untyped lambda calculus. In Proceedings of the 13th Annual ACM Symposium on Principles of Programming Languages. January, 1986.Google Scholar
  9. [JM76]
    N. Jones and S. Muchnick. Binding time optimization in programming languages: An approach to the design of an ideal language. In Proceedings of the 3rd Annual ACM Symposium on Principles of Programming Languages. January 1976.Google Scholar
  10. [Kranz88]
    D. Kranz. ORBIT: An Optimizing Compiler for Scheme. Ph.D. Thesis, Yale University, Department of Computer Science. May 1988.Google Scholar
  11. [MJ81]
    S. Muchnick and N. Jones, editors. Flow Analysis and Optimization of LISP-like Structures. Prentice-Hall, 1981.Google Scholar
  12. [Mycroft81]
    A. Mycroft. Abstract Interpretation and Optimizing Transformations for Applicative Programs. Ph.D. Thesis, University of Edinburgh. 1981.Google Scholar
  13. [RM88]
    C. Ruggieri and T.P. Murtagh. Lifetime analysis of dynamically allocated objects. Proceedings of the 15th Annual ACM Symposium on Principles of Programming Languages. January, 1988.Google Scholar
  14. [Schwartz75]
    J.T. Schwartz. Optimization of very high level languages — I. Value transmission and its corollaries. Journal of Computer Languages, 1:161–194, 1975.CrossRefGoogle Scholar
  15. [Wadler87]
    P. Wadler, Strictness analysis on non-flat domains. In Abstract Interpretation of Declarative Languages. C. L. Hankin and S. Abramsky, editors. Ellis Horwood, 1987.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1990

Authors and Affiliations

  • Benjamin Goldberg
    • 1
    • 2
  • Young Gil Park
    • 1
    • 2
  1. 1.Department of Computer Science Courant Institute of Mathematical SciencesNew York UniversityUSA
  2. 2.New York

Personalised recommendations