skip to main content
10.1145/507635.507639acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Contification using dominators

Published:01 October 2001Publication History

ABSTRACT

Contification is a compiler optimization that turns a function that always returns to the same place into a continuation. Compilers for functional languages use contification to expose the control-flow information that is required by many optimizations, including traditional loop optimizations. This paper gives a formal presentation of contification in MLton, a whole-program optimizing Standard ML compiler. We present two existing algorithms for contification in our framework, as well as a new algorithm based on the dominator tree of a program's call graph. We prove that the dominator algorithm is optimal. We present benchmark results on realistic SML programs demonstrating that contification has minimal overhead on compile time and significantly improves run time.

References

  1. A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles. techniques, and Tricks. Addison Wesley. 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. W. Appel. Loop headers in A-calculus or CPS. Lisp and Symbolic Computation, 7:337 313, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. W. Appel. SSA is functional progranhlniiiig. ACM SI'CPLAN Notices. 33(4):17 20, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. W. Appel and T. Jim. Shrinking lambda expressions in linear time. Journal of Functional Programming, 7(5):515- 540. 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. H. Cejtin, S. Jagannathan, and S. T. Weeks, Flow-directed closure conversion for typed languages. In European Symposium on Programming. pages 56-71, Mar. 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. P. Cousot and R. Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Symposium on Principles of Programming Languages, pages 238-252, 1977.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. Transactions on Programming Languages and Systems, 13(4):451-490, October 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 0. Danvy and U. P. Schultz, Lambda-dropping: Transforming recursive equations into programs with block structure. Theoretical Computer Science, 248(1-2):243-287. 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. M. Elsman. Static interpretation of modules. In International Conference on Functional Proqramming. pages 208 -219, Sept. 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Conference on Programming Language Design and Implementation, pages 237247. June 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. R. Harper and J. C. Mitchell. On the type structure of Standard NIL. Transactions on Programming Languages and Systems, 15(2):211 -252, April 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. N. D. Jones. Flow analysis of lambda expressions. In International Colloquium on Automata, Languages and Programming, volume 115, pages 114 128. Springer-Verlag. 1981.]] Google ScholarGoogle Scholar
  14. R. A. Kelsey. A correspondence between continuation passing style arid static single assignment form, In Workshop on Intermediate Representations, pages 13-22. Jan. 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. A. Kelsey and P. Hudak. Realistic compilation by program transformation'. In Symposium on Principles of Programming Languages. pages 281 -292. 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. D. Kranz, R. A. Kelsey, J. Rees, P. Hudak, J. Philbin, and N. Adams. ORBIT: An optimizing compiler for Scheme. In Symposium on Compiler Construction, pages 219 233. June 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. T. Lengauer and R. E. Tarjan. A fast algorithm, for finding domnimnators in a flowgrapli. Transactions on Programming Languages and Systems, l(I):121 141, 1979.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. MLton. a whole program optimizing compiler for Standard ML. http://www.sourcelight.com/MLton/.]]Google ScholarGoogle Scholar
  19. S. S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmnann Publishers, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J. E. Piazza. System for conversion of loop functions in continuation-passing style. ITS Patent 5881291, May, 1999.]]Google ScholarGoogle Scholar
  21. J. Reppy. Local CPS conversion in a direct-style compiler. In Workshop on Continuations, pages 1-5, Jan. 2001.]]Google ScholarGoogle Scholar
  22. D. Tarditi, J. G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A typedirected optimizing compiler for NIL. In Conference on Programming Language Design and Implementation. pages 181 192, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. M. Tofte, L. Birkedal, M. Elsman, N. Hallenberg, T. H. Olesen, and P. S. Bertelsen. Programming with regions in the NIL Kit (for version 3). Technical Report 98/25. University of Copenhagen. 1998.]]Google ScholarGoogle Scholar
  24. A. P. Tolmach and D. Oliva, From ML to Ada: Strongly-typed language interoperahility via source translation. Journal of Functional Programming, 8(4):367 -412. 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. K. Yi and S. Ryu A most-effective estimation of uncaught exceptions in, Standard Nil programs. Theoretical Computer Science, 237(1), 2000.]]Google ScholarGoogle Scholar

Index Terms

  1. Contification using dominators

        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
          ICFP '01: Proceedings of the sixth ACM SIGPLAN international conference on Functional programming
          October 2001
          277 pages
          ISBN:1581134150
          DOI:10.1145/507635
          • cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 36, Issue 10
            October 2001
            276 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/507669
            Issue’s Table of Contents

          Copyright © 2001 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: 1 October 2001

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • Article

          Acceptance Rates

          ICFP '01 Paper Acceptance Rate23of66submissions,35%Overall Acceptance Rate333of1,064submissions,31%

          Upcoming Conference

          ICFP '24

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader