Abstract
The flexibility of dynamically typed languages such as JavaScript, Python, Ruby, and Scheme comes at the cost of run-time type checks. Some of these checks can be eliminated via control-flow analysis. However, traditional control-flow analysis (CFA) is not ideal for this task as it ignores flow-sensitive information that can be gained from dynamic type predicates, such as JavaScript's 'instanceof' and Scheme's 'pair?', and from type-restricted operators, such as Scheme's 'car'. Yet, adding flow-sensitivity to a traditional CFA worsens the already significant compile-time cost of traditional CFA. This makes it unsuitable for use in just-in-time compilers. In response, we have developed a fast, flow-sensitive type-recovery algorithm based on the linear-time, flow-insensitive sub-0CFA. The algorithm has been implemented as an experimental optimization for the commercial Chez Scheme compiler, where it has proven to be effective, justifying the elimination of about 60% of run-time type checks in a large set of benchmarks. The algorithm processes on average over 100,000 lines of code per second and scales well asymptotically, running in only O(n log n) time. We achieve this compile-time performance and scalability through a novel combination of data structures and algorithms.
- Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman. On finding lowest common ancestors in trees. In Proceedings of the fifth annual ACM symposium on Theory of computing, pages 253--265. ACM, 1973. 10.1145/800125.804056. Google Scholar
Digital Library
- Stephen Alstrup, Cyril Gavoille, Haim Kaplan, and Theis Rauhe. Nearest common ancestors: A survey and a new algorithm for a distributed environment. Theory of Computing Systems, 37 (3): 441--456, May 2004. 10.1007/s00224-004--1155--5.Google Scholar
Digital Library
- J. Michael Ashley and R. Kent Dybvig. A practical and flexible flow analysis for higher-order languages. ACM Transactions on Programming Languages and Systems (TOPLAS), 20 (4): 845--868, July 1998. 10.1145/291891.291898. Google Scholar
Digital Library
- John P. Banning. An efficient way to find the side effects of procedure calls and the aliases of variables. In Proceedings of the 6th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 29--41. ACM, 1979. 10.1145/567752.567756. Google Scholar
Digital Library
- Robert Cartwright and Mike Fagan. Soft typing. In Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation, pages 278--292. ACM, 1991. 10.1145/113445.113469. Google Scholar
Digital Library
- Swarat Chaudhuri. Subcubic algorithms for recursive state machines. In Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 159--169. ACM, 2008. 10.1145/1328438.1328460. Google Scholar
Digital Library
- William D. Clinger. Description of benchmarks, 2008. URL http://www.larcenists.org/benchmarksAboutR6.html.Google Scholar
- Patrick Cousot and Radhia Cousot. Systematic design of program analysis frameworks. In Proceedings of the 6th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 269--282. ACM, 1979. 10.1145/567752.567778. Google Scholar
Digital Library
- Manuvir Das, Sorin Lerner, and Mark Seigle. ESP: Path-sensitive program verification in polynomial time. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, pages 57--68. ACM, 2002. 10.1145/512529.512538. Google Scholar
Digital Library
- R. Kent Dybvig. Chez Scheme Version 8 User's Guide. Cadence Research Systems, 2010.Google Scholar
- Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. Typing local control and state using flow analysis. In Programming Languages and Systems, volume 6602, pages 256--275. Springer Berlin / Heidelberg, 2011. 10.1007/978--3--642--19718--5_14. Google Scholar
Digital Library
- }Heintze-McAllester:ICFP97Nevin Heintze and David McAllester. On the complexity of set-based analysis. In Proceedings of the second ACM SIGPLAN international conference on Functional programming, pages 150--163. ACM, 1997. 10.1145/258948.258963. Google Scholar
Digital Library
- }Heintze-McAllester:PLDI97Nevin Heintze and David McAllester. Linear-time subtransitive control flow analysis. In Proceedings of the ACM SIGPLAN 1997 conference on Programming language design and implementation, pages 261--272. ACM, 1997. 10.1145/258915.258939. Google Scholar
Digital Library
- Fritz Henglein. Global tagging optimization by type inference. ACM SIGPLAN Lisp Pointers, V (1): 205--215, January 1992. 10.1145/141478.141542. Google Scholar
Digital Library
- Fritz Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming, 22 (3): 197--230, June 1994. 10.1016/0167--6423(94)00004--2. Google Scholar
Digital Library
- Fritz Henglein. Simple closure analysis. Semantics Report D-193, DIKU, University of Copenhagen, 1992.Google Scholar
- Suresh Jagannathan and Stephen Weeks. A unified treatment of flow analysis in higher-order languages. In Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 393--407. ACM, 1995. 10.1145/199448.199536. Google Scholar
Digital Library
- Suresh Jagannathan, Peter Thiemann, Stephen Weeks, and Andrew Wright. Single and loving it: Must-alias analysis for higher-order languages. In Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 329--341. ACM, 1998. 10.1145/268946.268973. Google Scholar
Digital Library
- Simon Jensen, Anders Møller, and Peter Thiemann. Type analysis for JavaScript. In Static Analysis, volume 5673, pages 238--255. Springer Berlin / Heidelberg, 2009. 10.1007/978--3--642-03237-0_17. Google Scholar
Digital Library
- David Melski and Thomas Reps. Interconvertibility of a class of set constraints and context-free-language reachability. Theoretical Computer Science, 248 (1--2): 29--98, October 2000. 10.1016/S0304--3975(00)00049--9. Google Scholar
Digital Library
- Jan Midtgaard and David Van Horn. Subcubic control flow analysis algorithms. Computer Science Research Report 125, Roskilde University, Roskilde, Denmark, May 2009. Revised version to appear in Higher-Order and Symbolic Computation.Google Scholar
- Torben Æ. Mogensen. Glossary for partial evaluation and related topics. Higher-Order and Symbolic Computation, 13 (4): 355--368, December 2000. 10.1023/A:1026551132647. Google Scholar
Digital Library
- Christian Mossin. Higher-order value flow graphs. Nordic Journal of Computing, 5 (3): 214--234, 1998. Google Scholar
Digital Library
- Mozilla Corporation. Doctor JS, 2011. http://doctorjs.org/.Google Scholar
- Eugene W. Myers. Efficient applicative data types. In Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 66--75. ACM, 1984. 10.1145/800017.800517. Google Scholar
Digital Library
- Flemming Nielson, Hanne Riis Nielson, and Chris Hankin. Principles of Program Analysis. Springer-Verlag, 1999. ISBN 978--3--540--65410-0. Google Scholar
Digital Library
- William Pugh. Skip lists: A probabilistic alternative to balanced trees. Communications of the ACM, 33 (6): 668--676, June 1990. 10.1145/78973.78977. Google Scholar
Digital Library
- Manuel Serrano. Control flow analysis: A functional languages compilation paradigm. In Proceedings of the 1995 ACM symposium on Applied computing, pages 118--122. ACM, 1995. 10.1145/315891.315934. Google Scholar
Digital Library
- Olin Shivers. Data-flow analysis and type recovery in Scheme. In Peter Lee, editor, Topics in Advanced Language Implementations, pages 47--87. The MIT Press, 1991.Google Scholar
- Olin 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. 10.1145/53990.54007. Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, pages 81--92, September 2006.Google Scholar
- Peter A. Steenkiste. The implementation of tags and run-time type checking. In Peter Lee, editor, Topics in Advanced Language Implementations, pages 3--24. The MIT Press, 1991.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. Logical types for untyped languages. In Proceedings of the 15th ACM SIGPLAN international conference on Functional programming, pages 117--128. ACM, 2010. 10.1145/1863543.1863561. Google Scholar
Digital Library
- Dimitrios Vardoulakis and Olin Shivers. CFA2: A context-free approach to control-flow analysis. In Programming Languages and Systems, volume 6012, pages 570--589. Springer Berlin / Heidelberg, 2010. 10.1007/978--3--642--11957--6_30.Google Scholar
Digital Library
- Mark N. Wegman and F. Kenneth Zadeck. Constant propagation with conditional branches. ACM Transactions on Programming Languages and Systems (TOPLAS), 13 (2): 181--210, April 1991. 10.1145/103135.103136. Google Scholar
Digital Library
Index Terms
Flow-sensitive type recovery in linear-log time
Recommendations
Flow-sensitive type recovery in linear-log time
OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applicationsThe flexibility of dynamically typed languages such as JavaScript, Python, Ruby, and Scheme comes at the cost of run-time type checks. Some of these checks can be eliminated via control-flow analysis. However, traditional control-flow analysis (CFA) is ...
Type-sensitive control-flow analysis
ML '06: Proceedings of the 2006 workshop on MLHigher-order typed languages, such as ML, provide strong support for data and type abstraction. While such abstraction is often viewed as costing performance, there are situations where it may provide opportunities for more aggressive program ...
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 ...







Comments