Nothing Special   »   [go: up one dir, main page]

skip to main content
article
Free access

CONS should not CONS its arguments, part II: Cheney on the M.T.A.

Published: 01 September 1995 Publication History

Abstract

Previous Schemes for implementing full tail-recursion when compiling into C have required some form of "trampoline" to pop the stack. We propose solving the tail-recursion problem in the same manner as Standard ML of New Jersey, by allocating all frames in the (garbage-collected) heap. The Scheme program is translated into continuation-passing style, so the target C functions never return. The C stack pointer then becomes the allocation pointer for a Cheney-style copying garbage collection scheme. Our Scheme can use C function calls, C arguments, C variable-arity functions, and separate compilation without requiring complex block-compilation of entire programs. Our C version of the "Boyer" benchmark is available at ftp://ftp.netcom.com/pub/hb/hbaker/cboyer13.c.

References

[1]
Appel, A.W. "Garbage collection can be faster than stack allocation". Info. Proc. Letts. 25, 4 (1987), 275-279.
[2]
Appel, A.W. "Simple Generational Garbage Collection and Fast Allocation". SW Prac. & Exper. 19, 2 (1989), 171+.
[3]
Appel, A.W. "A Runtime System". Lisp & Symbolic Comput. 3, 4 (Nov. 1990), 343-380.
[4]
Appel, A.W., and MacQueen, D.B. "Standard ML of New Jersey". In Wirsing, M., ed. Third Int'l Symp on Progr Lang Implementation and Logic Progr., Springer, August 1991.
[5]
Baker, H.G. "List Processing in Real Time on a Serial Computer". CACM 21, 4 (April 1978), 280-294.
[6]
Baker, H.G. "CONS Should Not CONS Its Arguments, or, a Lazy alloc is a Smart alloc". Sigplan Not. 27, 3 (Mar. 1992), 24-34.
[7]
Bartlett, J. "Scheme¿C: A portable Scheme-to-C compiler". Tech. Rept., DEC West. Res. Lab., 1989.
[8]
Berry, D.M. "Block Structure: Retention vs. Deletion". Proc. 3rd Sigact Symp. Th. of Comp. Shaker Hgts., 1971.
[9]
Cheney, C.J. "A nonrecursive list compacting algorithm". CACM 13, 11 (Nov. 1970), 677-678.
[10]
Clinger, W., Hartheimer, A., and Ost, E. "Implementation strategies for continuations". Proc. LFP, 1988, 124-131.
[11]
Danvy, O. "Memory Allocation and Higher-Order Functions". Proc. Sigplan '87 Symp. on Interp & Interp. Techs., ACM Sigplan Not. 22, 7 (July 1987), 241-252.
[12]
Fairbairn, J., and Wray, S.C. "TIM: a simple abstract machine to execute supercombinators". Proc. 1987 FPCA.
[13]
Fischer, M.J. "Lambda Calculus Schemata". ACM Conf. Proving Asserts. re Progs., Sigplan Not. 7, 1 (Jan. 1972).
[14]
Friedman, D.P., and Wise, D.S. "CONS Should Not Evaluate Its Arguments". In Michaelson, S., and Milner, R., eds. Automata, Languages and Programming, Edinburgh U. Press, 1976, 257-284.
[15]
Hanson, C. "Efficient stack allocation for tail-recursive languages". Proc. LFP, June 1990.
[16]
IEEE. IEEE Standard for the Scheme Programming Language. IEEE-1178-1990, IEEE, NY, Dec. 1990.
[17]
Peyton Jones, S.L. The Implementation of Functional Programming Languages. Prentice-Hall, New York, 1987.
[18]
Stallman, R.M. "Phantom Stacks: If you look too hard, they aren't there". AI Memo 556, MIT AI Lab., July 1980.
[19]
Stallman, R.M. Using and Porting GNU CC. Free Software Foundation, Inc. February, 1990.
[20]
Steiner, J., and Hawkes, B. "The M.T.A." On the album The Kingston Trio At Large, released June 8, 1959, reached number 15 on June 15, 1959. Copyright Atlantic Music 1956-57.
[21]
Tarditi, D., & Lee, P. "No assembly required: Compiling standard ML to C". ACM LOPLAS 1, 2 (1992), 161-177.

Cited By

View all
  • (2019)Evaluating Portable Mechanisms for Legitimate Execution Stack Access with a Scheme Interpreter in an Extended SC LanguageJournal of Information Processing10.2197/ipsjjip.27.17727(177-189)Online publication date: 2019
  • (2018)Putting in all the stops: execution control for JavaScriptACM SIGPLAN Notices10.1145/3296979.319237053:4(30-45)Online publication date: 11-Jun-2018
  • (2018)Garnishing parsec with parsleyProceedings of the 9th ACM SIGPLAN International Symposium on Scala10.1145/3241653.3241656(24-34)Online publication date: 17-Sep-2018
  • Show More Cited By

Index Terms

  1. CONS should not CONS its arguments, part II: Cheney on the M.T.A.

      Recommendations

      Comments

      Please enable JavaScript to view thecomments powered by Disqus.

      Information & Contributors

      Information

      Published In

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 01 September 1995
      Published in SIGPLAN Volume 30, Issue 9

      Check for updates

      Qualifiers

      • Article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)303
      • Downloads (Last 6 weeks)47
      Reflects downloads up to 30 Sep 2024

      Other Metrics

      Citations

      Cited By

      View all
      • (2019)Evaluating Portable Mechanisms for Legitimate Execution Stack Access with a Scheme Interpreter in an Extended SC LanguageJournal of Information Processing10.2197/ipsjjip.27.17727(177-189)Online publication date: 2019
      • (2018)Putting in all the stops: execution control for JavaScriptACM SIGPLAN Notices10.1145/3296979.319237053:4(30-45)Online publication date: 11-Jun-2018
      • (2018)Garnishing parsec with parsleyProceedings of the 9th ACM SIGPLAN International Symposium on Scala10.1145/3241653.3241656(24-34)Online publication date: 17-Sep-2018
      • (2018)Putting in all the stops: execution control for JavaScriptProceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3192366.3192370(30-45)Online publication date: 11-Jun-2018
      • (2016)Design and Implementation of Probabilistic Programming Language AnglicanProceedings of the 28th Symposium on the Implementation and Application of Functional Programming Languages10.1145/3064899.3064910(1-12)Online publication date: 31-Aug-2016
      • (2015)Compiling for multi-language task migrationACM SIGPLAN Notices10.1145/2936313.281671351:2(63-77)Online publication date: 21-Oct-2015
      • (2015)Compiling for multi-language task migrationProceedings of the 11th Symposium on Dynamic Languages10.1145/2816707.2816713(63-77)Online publication date: 21-Oct-2015
      • (2015)Memory-Efficient Tail Calls in the JVM with Imperative Functional ObjectsProgramming Languages and Systems10.1007/978-3-319-26529-2_2(11-28)Online publication date: 9-Dec-2015
      • (2012)Efficient compilation of tail calls and continuations to JavaScriptProceedings of the 2012 Annual Workshop on Scheme and Functional Programming10.1145/2661103.2661108(47-57)Online publication date: 9-Sep-2012
      • (2012)AvalancheProceedings of the 1st ACM SIGPLAN workshop on Functional high-performance computing10.1145/2364474.2364479(15-26)Online publication date: 15-Sep-2012
      • Show More Cited By

      View Options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Get Access

      Login options

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media