Abstract
In order to capture first-class continuations, most stack-based implementations copy contents of the stack to the heap. While various implementation strategies for copying have been proposed, many implementations employ the stack strategy. With this strategy, the entire stack contents is copied to the heap whenever a continuation is captured. This simple strategy is easy to implement and can be used for implementations with foreign language interface. However, this strategy requires a lot of time and memory for creation and invocation of continuations. We propose a lazy stack copying technique. The contents of the stack to copy are preserved on the stack until the function returns that has captured the continuation. So we delay stack copying for the continuation until the function returns. We can avoid stack copying if it is detected that the continuation has become garbage before the function returns. In addition, we propose stack copy sharing, which is realized by using lazy stack copying. We present three models for stack copy sharing. We applied these techniques to Scheme systems and found that the proposed techniques improve runtime and memory efficiency of programs that use first-class continuations.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
IEEE-1178-1990: IEEE Standard for the Scheme Programming Language. IEEE (1991)
Revised5 Report on the Algorithmic Language Scheme. In: Kelsey, R., Clinger, W., Rees, J. (eds.) Higher-Order and Symbolic Computation, vol. 11, Kluwer Academic Publishers, Dordrecht (1998)
Clinger, W.D., Hartheimer, A.H., Ost, E.M.: Implementation strategies for firstclass continuations. In: Higher-Order and Symbolic Computation, vol. 12, pp. 7–45. Kluwer Academic Publishers, Dordrecht (1999)
Jones, R., Lins, R.: Garbage Collection. John Wiley & Sons, Chichester (1996)
Yuasa, T., Nakagawa, Y., Komiya, T., Yasugi, M.: Return barrier. In: Proceedings International Lisp Conference, San Francisco (2002) (to appear)
Ugawa, T., Komiya, T., Yasugi, M., Yuasa, T.: Lazy stack copying for efficient implementation of continuations. In: Nineteenth Conference Proceedings Japan Society for Software Science and Technology, Japan Society for Software Science and Technology (2002) (in Japanese)
Jaffer, A.: SCM Manual (2003)
Appel, A.W., MacQueen, D.B.: Standard ML of New Jersey. In: Wirsing, M. (ed.) Third Int’l Symp. on Prog. Lang. Implementation and Logic Programming, pp. 1–13. Springer, New York (1991)
Appel, A.W.: Compiling with Continuations. Cambridge University Press, Cambridge (1992)
Flatt, M.: PLT MzScheme: Langurage manual (2000)
Gabriel, R.: Performance and Evaluation of Lisp Systems. MIT Press, Cambridge (1985)
Baker, H.G.: CONS should not CONS its arguments, or, a lazy alloc is a smart alloc. ACM SIGPLAN Notices 27, 24–34 (1992)
Kelsey, R.A., Rees, J.A.: A tractable Scheme implementation. Lisp and Symbolic Computation 7, 315–335 (1994)
Clinger, W.D., Hansen, L.T.: Lambda, the ultimate label or a simple optimizing compiler for scheme. In: Proceedings 1994 ACM Conference on Lisp and Functional Programming, pp. 128–139. ACM Press, New York (1994)
Samples, A.D., Ungar, D., Hilfinger, P.: SOAR: Smalltalk without bytecodes. In: Proceedings OOPSLA 1986. ACM SIGPLAN Notices, vol. 21, pp. 107–118 (1986)
Goldberg, A., Robson, D.: Smalltalk-80: The Language and Its Implementation. Addison-Wesley, Reading (1983)
Friedman, D.P., Wise, D.S.: The one-bit reference count. BIT 17, 351–359 (1977)
Mohr, E., Kranz, D.A., Halstead, J. R.H.: Lazy task creation: a technique for increasing the granularity of parallel programs. In: Proceedings of the 1990 ACM conference on LISP and functional programming, pp. 185–197. ACM Press, New York (1990)
Goldstein, S.C., Schauser, K.E., Culler, D.E.: Enabling Primitives for Compiling Parallel Languages. In: Third Workshop on Languages, Compilers, and Run-Time Systems for Scalable Computers (1995)
Taura, K., Yonezawa, A.: Fine-grain multithreading with minimal compiler support - a cost effective approach to implementing efficient multithreading languages. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 320–333 (1997)
Chakravarty, M.M.T.: Lazy thread and task creation in parallel graph reduction. In: Clack, C., Hammond, K., Davie, T. (eds.) IFL 1997. LNCS, vol. 1467, p. 231. Springer, Heidelberg (1998)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Ugawa, T., Minagawa, N., Komiya, T., Yasugi, M., Yuasa, T. (2003). Lazy Stack Copying and Stack Copy Sharing for the Efficient Implementation of Continuations. In: Ohori, A. (eds) Programming Languages and Systems. APLAS 2003. Lecture Notes in Computer Science, vol 2895. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-40018-9_27
Download citation
DOI: https://doi.org/10.1007/978-3-540-40018-9_27
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-20536-4
Online ISBN: 978-3-540-40018-9
eBook Packages: Springer Book Archive