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.
- A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles. techniques, and Tricks. Addison Wesley. 1986.]] Google ScholarDigital Library
- A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992.]] Google ScholarDigital Library
- A. W. Appel. Loop headers in A-calculus or CPS. Lisp and Symbolic Computation, 7:337 313, 1994.]] Google ScholarDigital Library
- A. W. Appel. SSA is functional progranhlniiiig. ACM SI'CPLAN Notices. 33(4):17 20, 1998.]] Google ScholarDigital Library
- A. W. Appel and T. Jim. Shrinking lambda expressions in linear time. Journal of Functional Programming, 7(5):515- 540. 1997.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- M. Elsman. Static interpretation of modules. In International Conference on Functional Proqramming. pages 208 -219, Sept. 1999.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- R. A. Kelsey and P. Hudak. Realistic compilation by program transformation'. In Symposium on Principles of Programming Languages. pages 281 -292. 1989.]] Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- MLton. a whole program optimizing compiler for Standard ML. http://www.sourcelight.com/MLton/.]]Google Scholar
- S. S. Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmnann Publishers, 1997.]] Google ScholarDigital Library
- J. E. Piazza. System for conversion of loop functions in continuation-passing style. ITS Patent 5881291, May, 1999.]]Google Scholar
- J. Reppy. Local CPS conversion in a direct-style compiler. In Workshop on Continuations, pages 1-5, Jan. 2001.]]Google Scholar
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- K. Yi and S. Ryu A most-effective estimation of uncaught exceptions in, Standard Nil programs. Theoretical Computer Science, 237(1), 2000.]]Google Scholar
Index Terms
- Contification using dominators
Recommendations
Contification using dominators
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, ...
Generalized dominators and post-dominators
POPL '92: Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languagesThe notion of dominators is generalized to include multiple-vertex dominators in addition to single-vertex dominators. A multiple-vertex dominator of a vertex is a group of vertices that collectively dominate the vertex. Existing algorithms compute ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...
Comments