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.
Article PDF
Similar content being viewed by others
References
A.W. Appel, Compiling with Continuations. Cambridge University Press, 1992.
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.
A.W. Appel, Modern Compiler Implementation in Java. Cambridge University Press, 1998.
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.
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.
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.
D.G. Bobrow and B. Wegbreit, A model and stack implementation of multiple environments. CACM 16, 10 (Oct. 1973) 591–603.
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.
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.
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.
D.R. Chase, Safety considerations for storage allocation optimizations. In Proceedings of the 1988 ACM Conference on Programming Language Design and Implementation, 1–10.
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.
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.
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.
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.
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.
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.
O. Danvy, Memory allocation and higher-order functions. In Proceedings of the SIGPLAN '87 Symposium on Interpreters and Interpretive Techniques, June 1987, 241–252.
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.
M. Feeley, Gambit-C version 3.0. An implementation of Scheme available via http:// www.iro.umontreal.ca/~gambit, 6 May 1998.
M.J. Fischer, Lambda-calculus schemata. In Journal of Lisp and Symbolic Computation 6, 3/4 (December 1993), 259–288.
R.P. Gabriel, Performance and Evaluation of Lisp Systems. The MIT Press, 1985.
A. Goldberg and D. Robson, Smalltalk-80: the Language and its Implementation. Addison-Wesley, 1983.
C. Hanson, Efficient stack allocation for tail-recursive languages. In Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, 106–118.
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.
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.
J. Holloway, G.L. Steele, G.J. Sussman and A. Bell, The SCHEME-79 chip. MIT AI Laboratory, AI Memo 559 (January 1980).
IEEE Standard 1178-1990. IEEE Standard for the Scheme Programming Language. IEEE, New York, 1991.
R. Kelsey, W. Clinger and J. Rees, Revised5 report on the algorithmic language. Higher-Order and Symbolic Computation 11, 3 (1998), 7–105.
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.
D.A. Kranz, ORBIT: An Optimizing Compiler for Scheme. PhD thesis, Yale University, May 1988.
Lightship Software. MacScheme Manual and Software. The Scientific Press, 1990.
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.
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.
E. Miranda, BrouHaHa—a portable Smalltalk interpreter. In Conference Proceedings of OOPSLA '87, SIGPLAN Notices 22, 12 (December 1987), 354–365.
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.
PowerPC 601 RISC Microprocessor User's Manual. Motorola, 1993.
J. Rees and W. Clinger, Eds., Revised3 report on the algorithmic language Scheme. In SIGPLAN Notices 21, 12 (December 1986), 37–79.
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.
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.
Semantic Microsystems. MacScheme+Toolsmith. August 1987.
Z. Shao and A.W. Appel, Space-efficient closure representations. In Proceedings of the 1994 ACM Conference on Lisp and Functional Programming, 150–161.
G.L. Steele, Jr., Macaroni is better than spaghetti. In Proceedings of the Symposium on Artificial Intelligence and Programming Languages (August 1977), 60–66.
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.
D.M. Ungar, The Design and Evaluation of a High Performance Smalltalk System. The MIT Press, 1987.
D.L. Weaver and T. Germond, The SPARC Architecture Manual, Version 9. SPARC International and PTR Prentice Hall, 1994.
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].
Author information
Authors and Affiliations
Rights and permissions
This article is published under an open access license. Please check the 'Copyright Information' section either on this page or in the PDF for details of this license and what re-use is permitted. If your intended use exceeds what is permitted by the license or if you are unable to locate the licence and re-use information, please contact the Rights and Permissions team.
About this article
Cite this article
Clinger, W.D., Hartheimer, A.H. & Ost, E.M. Implementation Strategies for First-Class Continuations. Higher-Order and Symbolic Computation 12, 7–45 (1999). https://doi.org/10.1023/A:1010016816429
Issue Date:
DOI: https://doi.org/10.1023/A:1010016816429