SAS 1995: Static Analysis pp 261-278 | Cite as

Efficient closure utilisation by higher-order inheritance analysis

  • Markus Mohnen
Contributed Papers
Part of the Lecture Notes in Computer Science book series (LNCS, volume 983)

Abstract

Higher-order functions and the ability to create new functions at runtime, either by partial application or λ-abstraction of existing functions, are important features of functional languages. Since these runtime-created functions may outlive their creating functions, it is necessary to represent all functional parameters by closures in a memory area which is not affected by the termination of function calls, i.e. in a heap component. Such a closure contains the original function, which may be a closure again, and the bindings of the parameters used (by the partial application). It many cases, however, it is possible to avoid this expensive heap allocation and use the run-time stack or even statically allocated closures. Often a closure created for a partial application is used only locally and will never be part of the result of the creating function. In these cases, the closure may be allocated on the stack. This approach is feasible in eager and lazy languages. If we can additionally ensure that there will never be more than one incarnation of a partial application, a closure can be allocated statically. In order to use this optimisation in lazy languages, we have to perform a strictness analysis first. We develop an abstract interpretation for the detection of inheritance information which allows us to decide whether the heap cells of an argument may be propagated to the result of a function call (i.e. are part of the result). Furthermore we give a criterion for checking whether there will be always only one incarnation of a certain partial application during runtime. In order to increase efficiency, we show how the number of recomputations can be decreased by using only parts of the abstract domains. The worst case time complexity is essentially quadratic in the size of the program. We illustrate the method developed in this paper with several examples. Correctness of the analysis is considered, using a modified denotational semantics as reference point. The main goal of our work is to keep both the run-time and the compile-time overhead as small as possible.

Keywords

Functional Type Abstract Interpretation Functional Program Abstract Domain Denotational Semantic 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [Abr86]
    S. Abramsky. Strictness analysis and polymorphic invariance. In G. Goos and J. Hartmanis, editors, Workshop on Programs as Data Objects, number 217 in LNCS, pages 1–24, 1986.Google Scholar
  2. [BH89]
    G. Baraki and J. Hughes. Abstract interpretation of polymorphic functions. In K. Davis and J. Hughes, editors, Functional Programming, Glasgow 1989, Workshops in Computing, 1989.Google Scholar
  3. [GLP93]
    A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. In Proceedings of FPCA, 1993.Google Scholar
  4. [GP90]
    B. Goldberg and Y.G. Park. Higher Order Escape Analysis: Optimizing Stack Allocation in Functional Program Implementations. In N. Jones, editor, ESOP 90, volume 432 of Lecture Notes in Computer Science. Springer-Verlag, 1990.Google Scholar
  5. [Hug83]
    R. J. M. Hughes. The design and implementation of programming languages. Dr. phil. thesis, Programming Research Group, Oxford, July 1983.Google Scholar
  6. [Hug92]
    S. Hughes. Compile-time garbage collection for higher-order functional languages. Journal of Logic and Computation, 2(4):483–509, 1992.Google Scholar
  7. [JM89]
    Simon B. Jones and Daniel Le Métayer. Compile-time garbage collection by sharing analysis. In Proceedings of The Fourth International Conference on Functional Programming Languages and Computer Architecture, 1989.Google Scholar
  8. [Jon85]
    T. Jonsson. Lambda lifting: transforming programs to recursive equations. In Jouannaud, editor, Proceedings of FPCA, number 201 in LNCS, pages 190–205. Springer Verlag, 1985.Google Scholar
  9. [Moh95]
    M. Mohnen. Efficient compile-time garbage collection for arbitrary data structures. In Proceedings of PLILP 95, LNCS, 1995. to appear.Google Scholar
  10. [Myc80]
    Alan Mycroft. The theory and practice of transforming call-by-need into call-by-value. In Proceedings of the International Symposium on Programming, number 83 in LNCS, pages 269–281, 1980.Google Scholar
  11. [Wad90]
    P. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 1(73):231–248, 1990.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1995

Authors and Affiliations

  • Markus Mohnen
    • 1
  1. 1.Lehrstuhl für Informatik IIAachen University of TechnologyAachenGermany

Personalised recommendations