Cactus Environment Machine

Shared Environment Call-by-Need

  • Conference paper
  • First Online:
Trends in Functional Programming (TFP 2016)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10447))

Included in the following conference series:

  • 297 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
EUR 29.95
Price includes VAT (France)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
EUR 42.79
Price includes VAT (France)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
EUR 52.74
Price includes VAT (France)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free ship** worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    In some implementations, these are lambda-lifted to be formal parameters, but the principle is the same.

  2. 2.

    Some work refers to this space as closure representation rather than environment representation [2, 29]. Because the term part of the closure is simply a code pointer and the interesting design choices are in the environment, we refer to the topic as environment representation.

  3. 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

  1. Appel, A.W.: Compiling with Continuations. Cambridge University Press, Cambridge (1992)

    Google Scholar 

  2. Appel, A.W., Jim, T.: Optimizing closure environment representations. Technical report (1988)

    Google Scholar 

  3. 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

    Chapter  Google Scholar 

  4. 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)

    Google Scholar 

  5. Barendregt, H.P.: The Lambda Calculus. North-Holland Amsterdam, Amsterdam (1984)

    MATH  Google Scholar 

  6. Biernacka, M., Danvy, O.: A concrete framework for environment machines. ACM Trans. Comput. Log. 9(1), 6 (2007)

    Article  MathSciNet  Google Scholar 

  7. 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

    Chapter  Google Scholar 

  8. Curien, P.L.: An abstract framework for environment machines. Theor. Comput. Sci. 82(2), 389–402 (1991)

    Article  MathSciNet  Google Scholar 

  9. 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)

    Article  MathSciNet  Google Scholar 

  10. 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)

    Google Scholar 

  11. Diehl, S., Hartel, P., Sestoft, P.: Abstract machines for programming language implementation. Futur. Gener. Comput. Syst. 16(7), 739–751 (2000)

    Article  Google Scholar 

  12. 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)

    Google Scholar 

  13. Fairbairn, J., Wray, S.: TIM: a simple, lazy abstract machine to execute supercombinators. In: Functional Programming Languages and Computer Architecture, pp. 34–45 (1987)

    Chapter  Google Scholar 

  14. Friedman, D., Ghuloum, A., Siek, J., Winebarger, O.: Improving the lazy Krivine machine. High.-Order Symb. Comput. 20, 271–293 (2007)

    Article  Google Scholar 

  15. 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)

    Google Scholar 

  16. Ichbiah, J.: Rationale for the Design of the ADA Programming Language. Cambridge University Press, Cambridge (1991)

    Google Scholar 

  17. Ingerman, P.Z.: A way of compiling procedure statements with some comments on procedure declarations. Commun. ACM 4(1), 55–58 (1961)

    Article  Google Scholar 

  18. Johnsson, T.: Efficient compilation of lazy evaluation. In: Proceedings of the 1984 SIGPLAN Symposium on Compiler Construction, pp. 58–69 (1984)

    Google Scholar 

  19. Krivine, J.: A call-by-name lambda-calculus machine. High.-Order Symb. Comput. 20(3), 199–207 (2007)

    Article  MathSciNet  Google Scholar 

  20. Landin, P.J.: The mechanical evaluation of expressions. Comput. J. 6(4), 308–320 (1964)

    Article  Google Scholar 

  21. Leroy, X.: The ZINC experiment: an economical implementation of the ML language. Technical report 117, INRIA (1990)

    Google Scholar 

  22. 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)

    Article  MathSciNet  Google Scholar 

  23. Mycroft, A.: Abstract interpretation and optimising transformations for applicative programs. Ph.D. thesis (1982)

    Google Scholar 

  24. Peyton Jones, S.L.: Implementing lazy functional languages on stock hardware: the spineless tagless G-machine. J. Funct. Program. 2(2), 127–202 (1992)

    Article  Google Scholar 

  25. Peyton Jones, S.L., Lester, D.R.: Implementing Functional Languages. Prentice-Hall, Inc., Upper Saddle River (1992)

    Google Scholar 

  26. Rozas, G.J.: Taming the Y operator. In: ACM SIGPLAN Lisp Pointers, vol. 1, pp. 226–234 (1992)

    Article  Google Scholar 

  27. Sabry, A., Lumsdaine, A., Garcia, R.: Lazy evaluation and delimited control. Log. Methods Comput. Sci. 6, 153–164 (2010)

    MathSciNet  MATH  Google Scholar 

  28. Sestoft, P.: Deriving a lazy abstract machine. J. Funct. Program. 7(3), 231–264 (1997)

    Article  MathSciNet  Google Scholar 

  29. Shao, Z., Appel, A.W.: Space-efficient closure representations. In: Proceedings of the 1994 ACM Conference on Lisp and Functional Programming (1994)

    Google Scholar 

  30. 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)

    Google Scholar 

  31. 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)

    Google Scholar 

  32. Wadler, P., Hughes, R.J.M.: Projections for strictness analysis. In: Functional Programming Languages and Computer Architecture, pp. 385–407 (1987)

    Chapter  Google Scholar 

Download references

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

Authors

Corresponding author

Correspondence to George Stelle .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics

Navigation