Higher-Order and Symbolic Computation

, Volume 12, Issue 1, pp 7–45

Implementation Strategies for First-Class Continuations

  • William D. Clinger
  • Anne H. Hartheimer
  • Eric M. Ost
Open Access
Article

Abstract

Scheme and Smalltalk continuations may have unlimited extent. This means that a purely stack-based implementation of continuations, as suffices for most languages, is inadequate. We review several implementation strategies for continuations and compare their performance using instruction counts for the normal case and continuation-intensive synthetic benchmarks for other scenarios, including coroutines and multitasking. All of the strategies constrain a compiler in some way, resulting in indirect costs that are hard to measure directly. We use related measurements on a set of benchmarks to calculate upper bounds for these indirect costs.

continuations stacks heap allocation coroutines multitasking Scheme Smalltalk 

References

  1. 1.
    A.W. Appel, Compiling with Continuations. Cambridge University Press, 1992.Google Scholar
  2. 2.
    A.W. Appel and Z. Shao, An empirical and analytic study of stack vs. heap cost for languages with closures. Journal of Functional Programming 6,1 (1996), 47–74.Google Scholar
  3. 3.
    A.W. Appel, Modern Compiler Implementation in Java. Cambridge University Press, 1998.Google Scholar
  4. 4.
    A.W. Appel and Z. Shao, Personal communications by electronic mail in October 1996 and September 1998, and by a telephone conference on 9 September 1998.Google Scholar
  5. 5.
    D.H. Bartley and J.C. Jensen, The implementation of PC Scheme. In Proceedings of the 1986 ACM Conference on Lisp and Functional Programming (August 1986), 86–93.Google Scholar
  6. 6.
    D.M. Berry, Block structure: retention or deletion? (Extended Abstract). In Conference Record of the Third Annual ACM Symposium on Theory of Computing, May 1971, 86–100.Google Scholar
  7. 7.
    D.G. Bobrow and B. Wegbreit, A model and stack implementation of multiple environments. CACM 16, 10 (Oct. 1973) 591–603.Google Scholar
  8. 8.
    C. Bruggeman, O. Waddell and R.K. Dybvig, Representing control in the presence of one-shot continuations. In Proceedings of the 1996 ACM SIGPLAN Conference on Programming Language Design and Implementation, June 1996, SIGPLAN Notices 31, 5 (May 1996), 99–107.Google Scholar
  9. 9.
    R.G. Burger, O. Waddell and R.K. Dybvig, Register allocation using lazy saves, eager restores, and greedy shuffling. In Proceedings of the 1995 ACM SIGPLAN Conference on Programming Language Design and Implementation, June 1995, 130–138.Google Scholar
  10. 10.
    P.J. Caudill and A. Wirfs-Brock, A third generation Smalltalk-80 implementation. In Conference Proceedings of OOPSLA '86, SIGPLAN Notices 21,11 (November 1986), 119–130.Google Scholar
  11. 11.
    D.R. Chase, Safety considerations for storage allocation optimizations. In Proceedings of the 1988 ACM Conference on Programming Language Design and Implementation, 1–10.Google Scholar
  12. 12.
    P. Cheng, R. Harper and P. Lee, Generational stack collection and profile-driven pretenuring. Proceedings of the 1998 ACM SIGPLAN Conference on Programming Language Design and Implementation, June 1998, 162–173.Google Scholar
  13. 13.
    W.D. Clinger, A.H. Hartheimer and E. Ost, Implementation strategies for continuations. In Proceedings of the 1988 ACM Conference on Lisp and Functional Programming, 124–131.Google Scholar
  14. 14.
    W.D. Clinger and L.T. Hansen, Lambda, the ultimate label, or a simple optimizing compiler for Scheme. In Proc. 1994 ACM Conference on Lisp and Functional Programming, 1994, 128–139.Google Scholar
  15. 15.
    W.D. Clinger and L.T. Hansen Generational garbage collection and the radioactive decay model. Proceedings of the 1997 ACMSIGPLAN Conference on Programming Language Design and Implementation, June 1997, 97–108.Google Scholar
  16. 16.
    W.D. Clinger, Proper tail recursion and space efficiency. Proceedings of the 1998 ACMSIGPLAN Conference on Programming Language Design and Implementation, June 1998, 174–185.Google Scholar
  17. 17.
    R. Cytron, J. Ferrante, B.N. Rosen, M.N. Wegman and F.K. Zadeck, Efficiently computing static single assignment form and the control dependence graph. ACM TOPLAS 13, 4 (October 1991), 451–490.Google Scholar
  18. 18.
    O. Danvy, Memory allocation and higher-order functions. In Proceedings of the SIGPLAN '87 Symposium on Interpreters and Interpretive Techniques, June 1987, 241–252.Google Scholar
  19. 19.
    L.P. Deutsch and A.M. Schiffman, Efficient implementation of the Smalltalk-80 system. In Conference Record of the 11th Annual ACM Symposium on Principles of Programming Languages, January 1984, 297–302.Google Scholar
  20. 20.
    M. Feeley, Gambit-C version 3.0. An implementation of Scheme available via http:// www.iro.umontreal.ca/~gambit, 6 May 1998.Google Scholar
  21. 21.
    M.J. Fischer, Lambda-calculus schemata. In Journal of Lisp and Symbolic Computation 6, 3/4 (December 1993), 259–288.Google Scholar
  22. 22.
    R.P. Gabriel, Performance and Evaluation of Lisp Systems. The MIT Press, 1985.Google Scholar
  23. 23.
    A. Goldberg and D. Robson, Smalltalk-80: the Language and its Implementation. Addison-Wesley, 1983.Google Scholar
  24. 24.
    C. Hanson, Efficient stack allocation for tail-recursive languages. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, 106–118.Google Scholar
  25. 25.
    C.T. Haynes and D.P. Friedman, Engines build process abstractions. Conference Record of the 1984 ACM Symposium on Lisp and Functional Programming (August 1984), 18–24.Google Scholar
  26. 26.
    R. Hieb, R.K. Dybvig and C. Bruggeman, Representing control in the presence of first-class continuations. In Proceedings of the ACMSIGPLAN '90 Conference on Programming Language Design and Implementation, ACM SIGPLAN Notices 25, 6 (June 1990), 66-77.Google Scholar
  27. 27.
    J. Holloway, G.L. Steele, G.J. Sussman and A. Bell, The SCHEME-79 chip. MIT AI Laboratory, AI Memo 559 (January 1980).Google Scholar
  28. 28.
    IEEE Standard 1178-1990. IEEE Standard for the Scheme Programming Language. IEEE, New York, 1991.Google Scholar
  29. 29.
    R. Kelsey, W. Clinger and J. Rees, Revised5 report on the algorithmic language. Higher-Order and Symbolic Computation 11, 3 (1998), 7–105.Google Scholar
  30. 30.
    D.A. Kranz, R. Kelsey, J.A. Rees, P. Hudak, J. Philbin and N.I. Adams, Orbit: An optimizing compiler for Scheme. In Proceedings of the SIGPLAN '86 Symposium on Compiler Construction. SIGPLAN Notices 21, 7 (July 1986), 219–223.Google Scholar
  31. 31.
    D.A. Kranz, ORBIT: An Optimizing Compiler for Scheme. PhD thesis, Yale University, May 1988.Google Scholar
  32. 32.
    Lightship Software. MacScheme Manual and Software. The Scientific Press, 1990.Google Scholar
  33. 33.
    L. Mateu, An efficient implementation for coroutines. In Bekkers, Y., and Cohen, J. [editors]. Memory Management (Proceedings of the International Workshop on Memory Management IWMM 92), Springer-Verlag, 1992, 230–247.Google Scholar
  34. 34.
    D. McDermott, An efficient environment allocation scheme in an interpreter for a lexically-scoped Lisp. In Conference Record of the 1980 Lisp Conference (August 1980), 154–162.Google Scholar
  35. 35.
    E. Miranda, BrouHaHa—a portable Smalltalk interpreter. In Conference Proceedings of OOPSLA '87, SIGPLAN Notices 22, 12 (December 1987), 354–365.Google Scholar
  36. 36.
    J.E.B. Moss, Managing stack frames in Smalltalk. In Proceedings of the SIGPLAN '87 Symposium on Interpreters and Interpretive Techniques, June 1987, 229–240.Google Scholar
  37. 37.
    PowerPC 601 RISC Microprocessor User's Manual. Motorola, 1993.Google Scholar
  38. 38.
    J. Rees and W. Clinger, Eds., Revised3 report on the algorithmic language Scheme. In SIGPLAN Notices 21, 12 (December 1986), 37–79.Google Scholar
  39. 39.
    J.H. Reppy, CML: A higher-order concurrent language. In Proceedings of the 1991 ACM SIGPLAN Conference on Programming Language Design and Implementation, SIGPLAN Notices 26, 6 (1991), 294–305.Google Scholar
  40. 40.
    A.D. Samples, D. Ungar and P. Hilfinger, SOAR: Smalltalk without bytecodes In Conference Proceedings of OOPSLA '86, SIGPLAN Notices 21, 11 (November 1986), 107–118.Google Scholar
  41. 41.
    Semantic Microsystems. MacScheme+Toolsmith. August 1987.Google Scholar
  42. 42.
    Z. Shao and A.W. Appel, Space-efficient closure representations. In Proceedings of the 1994 ACM Conference on Lisp and Functional Programming, 150–161.Google Scholar
  43. 43.
    G.L. Steele, Jr., Macaroni is better than spaghetti. In Proceedings of the Symposium on Artificial Intelligence and Programming Languages (August 1977), 60–66.Google Scholar
  44. 44.
    N. Suzuki and M. Terada, Creating efficient systems for object-oriented languages. In Conference Record of the 11th Annual ACM Symposium on Principles of Programming Languages, January 1984, 290–296.Google Scholar
  45. 45.
    D.M. Ungar, The Design and Evaluation of a High Performance Smalltalk System. The MIT Press, 1987.Google Scholar
  46. 46.
    D.L. Weaver and T. Germond, The SPARC Architecture Manual, Version 9. SPARC International and PTR Prentice Hall, 1994.Google Scholar
  47. 47.
    A. Wirfs-Brock, Personal communication, April 1988. Tektronix Smalltalk was described by Caudill and Wirfs-brock, but not in enough detail for us to realize that Tektronix Smalltalk uses the stack/heap strategy rather than the stack strategy [10].Google Scholar

Copyright information

© Kluwer Academic Publishers 1999

Authors and Affiliations

  • William D. Clinger
    • 1
  • Anne H. Hartheimer
  • Eric M. Ost
  1. 1.College of Computer ScienceNortheastern UniversityBoston

Personalised recommendations