Flow-sensitive type recovery in linear-log time

Michael D. Adams, Andrew W. Keep, Jan Midtgaard, Matthew Might, Arun Chauhan, R. Kent Dybvig
2011 Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications - OOPSLA '11  
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. Traditional control-flow analysis (CFA) is not ideal for this task, however, as it ignores flow-sensitive information that can be gained from dynamic type predicates, such as JavaScript's instanceof or Scheme's pair?, and from type-restricted operators, such as Scheme's car. Yet, adding
more » ... ivity to a traditional CFA worsens the already significant compile-time cost of traditional CFA. This makes it unsuitable for use in just-intime compilers. In response, we have developed a fast, flow-sensitive type-recovery algorithm based on the linear-time, flowinsensitive sub-0CFA. The algorithm has been incorporated into 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. In practice, the algorithm processes on average over 75,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.
doi:10.1145/2048066.2048105 dblp:conf/oopsla/AdamsKMMCD11 fatcat:ukh6afsflnbqla5lqypzseod4m