Abstract
Existing machines for lazy evaluation use a flat representation of environments, storing the terms associated with free variables in an array. Combined with a heap, this structure supports the shared intermediate results required by lazy evaluation. We propose and describe an alternative approach that uses a shared environment to minimize the overhead of delayed computations. We show how a shared environment can act as both an environment and a mechanism for sharing results. To formalize this approach, we introduce a calculus that makes the shared environment explicit, as well as a machine to implement the calculus, the Cactus Environment Machine. A simple compiler implements the machine and is used to run experiments for assessing performance. The results show reasonable performance and suggest that incorporating this approach into real-world compilers could yield performance benefits in some scenarios.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
In some implementations, these are lambda-lifted to be formal parameters, but the principle is the same.
- 2.
- 3.
Curien calls it a “lazy” evaluator, and there is some ambiguity with the term lazy, but we use the term only to mean call-by-need. We also remove the condition checking that \(i < m\) because we are only concerned with evaluation of closed terms.
References
Appel, A.W.: Compiling with Continuations. Cambridge University Press, Cambridge (1992)
Appel, A.W., Jim, T.: Optimizing closure environment representations. Technical report (1988)
Appel, A.W., MacQueen, D.B.: Standard ML of New Jersey. In: Maluszyński, J., Wirsing, M. (eds.) PLILP 1991. LNCS, vol. 528, pp. 1–13. Springer, Heidelberg (1991). https://doi.org/10.1007/3-540-54444-5_83
Ariola, Z.M., Maraist, J., Odersky, M., Felleisen, M., Wadler, P.: A call-by-need lambda calculus. In: Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 233–246 (1995)
Barendregt, H.P.: The Lambda Calculus. North-Holland Amsterdam, Amsterdam (1984)
Biernacka, M., Danvy, O.: A concrete framework for environment machines. ACM Trans. Comput. Log. 9(1), 6 (2007)
Boquist, U., Johnsson, T.: The GRIN project: a highly optimising back end for lazy functional languages. In: Kluge, W. (ed.) IFL 1996. LNCS, vol. 1268, pp. 58–84. Springer, Heidelberg (1997). https://doi.org/10.1007/3-540-63237-9_19
Curien, P.L.: An abstract framework for environment machines. Theor. Comput. Sci. 82(2), 389–402 (1991)
Danvy, O., Millikin, K., Munk, J., Zerny, I.: On inter-deriving small-step and big-step semantics: a case study for storeless call-by-need evaluation. Theor. Comput. Sci. 435, 21–42 (2012)
Danvy, O., Zerny, I.: A synthetic operational account of call-by-need evaluation. In: Proceedings of the 15th Symposium on Principles and Practice of Declarative Programming, pp. 97–108 (2013)
Diehl, S., Hartel, P., Sestoft, P.: Abstract machines for programming language implementation. Futur. Gener. Comput. Syst. 16(7), 739–751 (2000)
Dijkstra, A., Fokker, J., Swierstra, S.D.: The architecture of the Utrecht Haskell compiler. In: Proceedings of the 2nd ACM SIGPLAN Symposium on Haskell, pp. 93–104 (2009)
Fairbairn, J., Wray, S.: TIM: a simple, lazy abstract machine to execute supercombinators. In: Functional Programming Languages and Computer Architecture, pp. 34–45 (1987)
Friedman, D., Ghuloum, A., Siek, J., Winebarger, O.: Improving the lazy Krivine machine. High.-Order Symb. Comput. 20, 271–293 (2007)
Hauck, E., Dent, B.A.: Burroughs’ B6500/B7500 stack mechanism. In: Proceedings of the 30 April–2 May 1968, Spring Joint Computer Conference, pp. 245–251 (1968)
Ichbiah, J.: Rationale for the Design of the ADA Programming Language. Cambridge University Press, Cambridge (1991)
Ingerman, P.Z.: A way of compiling procedure statements with some comments on procedure declarations. Commun. ACM 4(1), 55–58 (1961)
Johnsson, T.: Efficient compilation of lazy evaluation. In: Proceedings of the 1984 SIGPLAN Symposium on Compiler Construction, pp. 58–69 (1984)
Krivine, J.: A call-by-name lambda-calculus machine. High.-Order Symb. Comput. 20(3), 199–207 (2007)
Landin, P.J.: The mechanical evaluation of expressions. Comput. J. 6(4), 308–320 (1964)
Leroy, X.: The ZINC experiment: an economical implementation of the ML language. Technical report 117, INRIA (1990)
Marlow, S., Jones, S.P.: Making a fast curry: push/enter vs. eval/apply for higher-order languages. J. Funct. Program. 16(4–5), 415–449 (2006)
Mycroft, A.: Abstract interpretation and optimising transformations for applicative programs. Ph.D. thesis (1982)
Peyton Jones, S.L.: Implementing lazy functional languages on stock hardware: the spineless tagless G-machine. J. Funct. Program. 2(2), 127–202 (1992)
Peyton Jones, S.L., Lester, D.R.: Implementing Functional Languages. Prentice-Hall, Inc., Upper Saddle River (1992)
Rozas, G.J.: Taming the Y operator. In: ACM SIGPLAN Lisp Pointers, vol. 1, pp. 226–234 (1992)
Sabry, A., Lumsdaine, A., Garcia, R.: Lazy evaluation and delimited control. Log. Methods Comput. Sci. 6, 153–164 (2010)
Sestoft, P.: Deriving a lazy abstract machine. J. Funct. Program. 7(3), 231–264 (1997)
Shao, Z., Appel, A.W.: Space-efficient closure representations. In: Proceedings of the 1994 ACM Conference on Lisp and Functional Programming (1994)
Stenstrom, P.: VLSI support for a cactus stack oriented memory organization. In: Proceedings of the Twenty-First Annual Hawaii International Conference on System Sciences, Volume I. Architecture Track, vol. 1, pp. 211–220 (1988)
Terei, D.A., Chakravarty, M.M.: An LLVM backend for GHC. In: Proceedings of the Third ACM Haskell Symposium on Haskell, Haskell 2010, pp. 109–120 (2010)
Wadler, P., Hughes, R.J.M.: Projections for strictness analysis. In: Functional Programming Languages and Computer Architecture, pp. 385–407 (1987)
Acknowledgments
This material is based upon work supported by the National Science Foundation under grant CCF-1422840, NSF (1518878,1444871), DARPA (FA8750-15-C-0118), AFRL (FA8750-15-2-0075), the Sandia National Laboratories Academic Alliance, and the Santa Fe Institute. Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-AC04-94AL85000.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Stelle, G., Stefanovic, D., Olivier, S.L., Forrest, S. (2019). Cactus Environment Machine. In: Van Horn, D., Hughes, J. (eds) Trends in Functional Programming. TFP 2016. Lecture Notes in Computer Science(), vol 10447. Springer, Cham. https://doi.org/10.1007/978-3-030-14805-8_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-14805-8_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-14804-1
Online ISBN: 978-3-030-14805-8
eBook Packages: Computer ScienceComputer Science (R0)