article
Free Access

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

Published:01 September 1995Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Appel, A.W. "Simple Generational Garbage Collection and Fast Allocation". SW Prac. & Exper. 19, 2 (1989), 171+. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Appel, A.W. "A Runtime System". Lisp & Symbolic Comput. 3, 4 (Nov. 1990), 343-380. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  5. Baker, H.G. "List Processing in Real Time on a Serial Computer". CACM 21, 4 (April 1978), 280-294. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Bartlett, J. "Scheme¿C: A portable Scheme-to-C compiler". Tech. Rept., DEC West. Res. Lab., 1989.Google ScholarGoogle Scholar
  8. Berry, D.M. "Block Structure: Retention vs. Deletion". Proc. 3rd Sigact Symp. Th. of Comp. Shaker Hgts., 1971. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Cheney, C.J. "A nonrecursive list compacting algorithm". CACM 13, 11 (Nov. 1970), 677-678. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Clinger, W., Hartheimer, A., and Ost, E. "Implementation strategies for continuations". Proc. LFP, 1988, 124-131. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Fairbairn, J., and Wray, S.C. "TIM: a simple abstract machine to execute supercombinators". Proc. 1987 FPCA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Fischer, M.J. "Lambda Calculus Schemata". ACM Conf. Proving Asserts. re Progs., Sigplan Not. 7, 1 (Jan. 1972). Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  15. Hanson, C. "Efficient stack allocation for tail-recursive languages". Proc. LFP, June 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. IEEE. IEEE Standard for the Scheme Programming Language. IEEE-1178-1990, IEEE, NY, Dec. 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Peyton Jones, S.L. The Implementation of Functional Programming Languages. Prentice-Hall, New York, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Stallman, R.M. "Phantom Stacks: If you look too hard, they aren't there". AI Memo 556, MIT AI Lab., July 1980.Google ScholarGoogle Scholar
  19. Stallman, R.M. Using and Porting GNU CC. Free Software Foundation, Inc. February, 1990.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  21. Tarditi, D., & Lee, P. "No assembly required: Compiling standard ML to C". ACM LOPLAS 1, 2 (1992), 161-177. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

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

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 30, Issue 9
        Sept. 1995
        48 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/214448
        Issue’s Table of Contents

        Copyright © 1995 Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 September 1995

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!