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.
Preview
Unable to display preview. Download preview PDF.
References
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.
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.
A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. In Proceedings of FPCA, 1993.
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.
R. J. M. Hughes. The design and implementation of programming languages. Dr. phil. thesis, Programming Research Group, Oxford, July 1983.
S. Hughes. Compile-time garbage collection for higher-order functional languages. Journal of Logic and Computation, 2(4):483–509, 1992.
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.
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.
M. Mohnen. Efficient compile-time garbage collection for arbitrary data structures. In Proceedings of PLILP 95, LNCS, 1995. to appear.
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.
P. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 1(73):231–248, 1990.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1995 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Mohnen, M. (1995). Efficient closure utilisation by higher-order inheritance analysis. In: Mycroft, A. (eds) Static Analysis. SAS 1995. Lecture Notes in Computer Science, vol 983. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-60360-3_44
Download citation
DOI: https://doi.org/10.1007/3-540-60360-3_44
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-60360-3
Online ISBN: 978-3-540-45050-4
eBook Packages: Springer Book Archive