skip to main content
10.1145/2661103.2661106acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Optimizing closures in O(0) time

Published:09 September 2012Publication History

ABSTRACT

The flat-closure model for the representation of first-class procedures is simple, safe-for-space, and efficient, allowing the values or locations of free variables to be accessed with a single memory indirect. It is a straightforward model for programmers to understand, allowing programmers to predict the worst-case behavior of their programs. This paper presents a set of optimizations that improve upon the flat-closure model along with an algorithm that implements them, and it shows that the optimizations together eliminate over 50% of run-time closure-creation and free-variable access overhead in practice, with insignificant compile-time overhead. The optimizations never add overhead and remain safe-for-space, thus preserving the benefits of the flat-closure model.

References

  1. A. Appel. Private communication. 1994.Google ScholarGoogle Scholar
  2. A. W. Appel. Compiling with Continuations. Cambridge University Press, 40 West 20th Street, New York, NY 10011-4211, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. W. Appel. Closure conversion, chapter 10, pages 103--124. Cambridge University Press, 40 West 20th Street, New York, NY 10011-4211, 1992.Google ScholarGoogle Scholar
  4. L. Cardelli. The functional abstract machine. Technical report, Bell Laboratories, 1983.Google ScholarGoogle Scholar
  5. W. D. Clinger. Description of benchmarks, 2008. URL http://www.larcenists.org/benchmarksAboutR6.html. Accessed Oct 20, 2011.Google ScholarGoogle Scholar
  6. I. Dragoş. Optimizing Higher-Order Functions in Scala. In Third International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, 2008.Google ScholarGoogle Scholar
  7. R. K. Dybvig. Three Implementation Models for Scheme. PhD thesis, University of North Carolina, Chapel Hill, Apr. 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. P. Fradet and D. Le Métayer. Compilation of functional languages by program transformation. ACM Trans. Program. Lang. Syst., 13:21--51, January 1991. ISSN 0164-0925.. URL http://doi.acm.org/10.1145/114005.102805. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Ghuloum and R. K. Dybvig. Fixing letrec (reloaded). In Proceedings of the 2009 Workshop on Scheme and Functional Programming, pages 57--65, 2009.Google ScholarGoogle Scholar
  10. J. Guy L. Steele. Rabbit: A compiler for scheme. Technical report, Massachusetts Institute of Technology, Cambridge, MA, USA, 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In Proceedings 1985 Conference on Functional Programming Languages and Compiler Architecture, pages 190--203. Springer-Verlag, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. A. Kranz. ORBIT: An Optimizing Compiler for Scheme. PhD thesis, Yale University, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. M. Serrano. Control flow analysis: A functional languages compilation paradigm. In Proceedings of the 1995 ACM symposium on Applied computing, pages 118--122. ACM, 1995.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Z. Shao and A. W. Appel. Efficient and safe-for-space closure conversion. ACM TOPLAS, 22:129--161, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. O. Shivers. Control flow analysis in Scheme. In Proceedings of the ACM SIGPLAN 1988 conference on Programming Language design and Implementation, pages 164--174. ACM, 1988.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Sperber, R. K. Dybvig, M. Flatt, A. Van Straaten, R. Findler, and J. Matthews. Revised6 report on the algorithmic language scheme. Journal of Functional Programming, 19(Supplement S1):1--301, 2009.. URL http://dx.doi.org/10.1017/S0956796809990074. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. P. A. Steckler and M. Wand. Lightweight closure conversion. ACM Trans. Program. Lang. Syst., 19:48--86, January 1997. ISSN 0164-0925.. URL http://doi.acm.org/10.1145/239912.239915. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. E. Tarjan. Depth-first search and linear graph algorithms. SIAM J. Comput., 1(2):146--160, 1972.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. O. Waddell, D. Sarkar, and R. K. Dybvig. Fixing letrec: A faithful yet efficient implementation of Scheme's recursive binding construct. Higher-order and and symbolic computation, 18(3/4):299--326, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library

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
  • Published in

    cover image ACM Conferences
    Scheme '12: Proceedings of the 2012 Annual Workshop on Scheme and Functional Programming
    September 2012
    99 pages
    ISBN:9781450318952
    DOI:10.1145/2661103

    Copyright © 2012 ACM

    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    • Published: 9 September 2012

    Permissions

    Request permissions about this article.

    Request Permissions

    Check for updates

    Qualifiers

    • research-article

    Acceptance Rates

    Scheme '12 Paper Acceptance Rate4of4submissions,100%Overall Acceptance Rate4of4submissions,100%

    Upcoming Conference

    ICFP '24

PDF Format

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader