ABSTRACT
Pushdown models are better than control-flow graphs for higher-order flow analysis. They faithfully model the call/return structure of a program, which results in fewer spurious flows and increased precision. However, pushdown models require that calls and returns in the analyzed program nest properly. As a result, they cannot be used to analyze language constructs that break call/return nesting such as generators, coroutines, call/cc, etc.
In this paper, we extend the CFA2 flow analysis to create the first pushdown flow analysis for languages with first-class control. We modify the abstract semantics of CFA2 to allow continuations to escape to, and be restored from, the heap. We then present a summarization algorithm that handles escaping continuations via a new kind of summary edge. We prove that the algorithm is sound with respect to the abstract semantics.
Supplemental Material
- A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992. 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 Proceedings of the Fourth Annual ACM Symposium on Principles of Programming Languages, pages 238--252, Jan. 1977. Google ScholarDigital Library
- O.-J. Dahl and K. Nygaard. SIMULA - an ALGOL-based simulation language. Communications of the ACM, 9 (9): 671--678, 1966. Google ScholarDigital Library
- O. Danvy and A. Filinski. A functional abstraction of typed contexts. Technical Report 89/12, University of Copenhagen, 1989.Google Scholar
- Doctor JS: A set of static-analysis tools for JavaScript. https://github.com/mozilla/doctorjs.Google Scholar
- C. Earl, M. Might, and D. Van Horn. Pushdown control-flow analysis of higher-order programs. In Proceedings of the 2010 Workshop on Scheme and Functional Programming, 2010.Google Scholar
- M. Felleisen. The theory and practice of first-class prompts. In Proceedings of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, pages 180--190, 1988. Google ScholarDigital Library
- JavaScript generators. https://developer.mozilla.org/en/JavaScript/New_in_JavaScript/1.7.Google Scholar
- D. Kranz. ORBIT: An Optimizing Compiler for Scheme. PhD thesis, Yale University, 1988. Google ScholarDigital Library
- D. Kranz, R. Kelsey, J. Rees, P. Hudak, J. Philbin, and N. Adams. Orbit: an optimizing compiler for Scheme. In Proceedings of the 1986 SIGPLAN Symposium on Compiler Construction, pages 219--233, 1986. Google ScholarDigital Library
- The Lua programming language. http://www.lua.org.Google Scholar
- M. Might. Environment Analysis of Higher-Order Languages. PhD thesis, Georgia Institute of Technology, 2007. Google ScholarDigital Library
- M. Might and O. Shivers. Analyzing the environment structure of higher-order languages using frame strings. Theoretical Computer Science, 375 (1-3): 137--168, May 2007. Google ScholarDigital Library
- Python generators. http://www.python.org/dev/peps/pep-0255.Google Scholar
- T. W. Reps, S. Horwitz, and S. Sagiv. Precise interprocedural dataflow analysis via graph reachability. In Proceedings of the Twenty-Second Annual ACM Symposium on Principles of Programming Languages, pages 49--61, 1995. Google ScholarDigital Library
- T. Rompf, I. Maier, and M. Odersky. Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform. In Proceeding of the 14th ACM SIGPLAN International Conference on Functional Programming, pages 317--328, 2009. Google ScholarDigital Library
- M. Sharir and A. Pnueli. Two approaches to interprocedural data-flow analysis. In S. Muchnick and N. Jones, editors, Program Flow Analysis: Theory and Applications. Prentice Hall, 1981.Google Scholar
- O. Shivers. Continuations and threads: Expressing machine concurrency directly in advanced languages. In O. Danvy, editor, Proceedings of the Second ACM SIGPLAN Workshop on Continuations (CW 1997), Technical report BRICS-NS-96-13, University of Århus, pages 2:1--15, Paris, France, Jan. 1997.Google Scholar
- O. Shivers and M. Might. Continuations and transducer composition. In Proceedings of the 2006 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2006), pages 295--307, Ottawa, Canada, June 2006. Google ScholarDigital Library
- M. Sperber, R. K. Dybvig, M. Flatt, A. van Straaten, R. Findler, and J. Matthews, editors. Revised6 Report on the Algorithmic Language Scheme. Cambridge University Press, 2010. Google ScholarDigital Library
- G. L. Steele. Rabbit: A Compiler for Scheme. Master's thesis, MIT, 1978.Google Scholar
- D. Vardoulakis and O. Shivers. CFA2: A context-free approach to control-flow analysis. In Proceedings of the 19th European Symposium on Programming (ESOP 2010), volume 6012 of Lecture Notes in Computer Science, pages 570--589, Paphos, Cyprus, Mar. 2010. Springer. Google ScholarDigital Library
- D. Vardoulakis and O. Shivers. Ordering multiple continuations on the stack. In Proceedings of the 2011 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2011), pages 13--22, Austin, Texas, Jan. 2011. Google ScholarDigital Library
- D. Vardoulakis and O. Shivers. CFA2: A context-free approach to control-flow analysis. Logical Methods in Computer Science, 7 (2:3): 1--39, May 2011.Google ScholarCross Ref
- M. Wand. Continuation-based multiprocessing. In Conference Record of the 1980 LISP Conference, pages 19--28, Stanford, 1980. Google ScholarDigital Library
Index Terms
- Pushdown flow analysis of first-class control
Recommendations
Pushdown flow analysis of first-class control
ICFP '11Pushdown models are better than control-flow graphs for higher-order flow analysis. They faithfully model the call/return structure of a program, which results in fewer spurious flows and increased precision. However, pushdown models require that calls ...
Pushdown control-flow analysis for free
POPL '16Traditional control-flow analysis (CFA) for higher-order languages introduces spurious connections between callers and callees, and different invocations of a function may pollute each other's return flows. Recently, three distinct approaches have been ...
Pushdown control-flow analysis for free
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesTraditional control-flow analysis (CFA) for higher-order languages introduces spurious connections between callers and callees, and different invocations of a function may pollute each other's return flows. Recently, three distinct approaches have been ...
Comments