Systematic abstraction of abstract machines

We describe a derivational approach to abstract interpretation that yields novel and transparently sound static analyses when applied to well-established abstract machines for higher-order and imperative programming languages. To demonstrate the technique and support our claim, we transform the CEK machine of Felleisen and Friedman (Proc. of the 14th ACM SIGACT-SIGPLAN Symp. Prin. Program. Langs, 1987, pp. 314-325), a lazy variant of Krivine's machine (Higher-Order Symb. Comput. Vol 20, 2007, pp. 199-207), and the stack-inspecting CM machine of Clements and Felleisen (ACM Trans. Program. Lang. Syst. Vol 26, 2004, pp. 1029-1052) into abstract interpretations of themselves. The resulting analyses bound temporal ordering of program events; predict return-flow and stack-inspection behavior; and approximate the flow and evaluation of by-need parameters. For all of these machines, we find that a series of well-known concrete machine refactorings, plus a technique of store-allocated continuations, leads to machines that abstract into static analyses simply by bounding their stores. These machines are parameterized by allocation functions that tune performance and precision and substantially expand the space of analyses that this framework can represent. We demonstrate that the technique scales up uniformly to allow static analysis of realistic language features, including tail calls, conditionals, mutation, exceptions, first-class continuations, and even garbage collection. In order to close the gap between formalism and implementation, we provide translations of the mathematics as running Haskell code for the initial development of our method.

[1]  Matthias Felleisen,et al.  Modeling an Algebraic Stepper , 2001, ESOP.

[2]  Andrew Edward Ayers Abstract analysis and optimization of scheme , 1993 .

[3]  Thomas W. Reps,et al.  Program analysis via graph reachability , 1997, Inf. Softw. Technol..

[4]  Matthias Felleisen,et al.  Modular set-based analysis from contracts , 2006, POPL '06.

[5]  Jan Midtgaard Control-Flow Analysis of Functional Programs , 2007 .

[6]  Alexander Aiken,et al.  The set constraint/CFL reachability connection in practice , 2004, PLDI '04.

[7]  Karl-Filip Faxén,et al.  Optimizing Lazy Functional Programs Using Flow Inference , 1995, SAS.

[8]  Peter Sestoft,et al.  Analysis and efficient implementation of functional programs , 1991 .

[9]  Matthias Felleisen,et al.  Semantics Engineering with PLT Redex , 2009 .

[10]  Matthew Might,et al.  Pushdown Control-Flow Analysis of Higher-Order Programs , 2010, ArXiv.

[11]  Neil D. Jones,et al.  Program Flow Analysis: Theory and Application , 1981 .

[12]  Suresh Jagannathan,et al.  Polymorphic splitting: an effective polyvariant flow analysis , 1998, TOPL.

[13]  Matthias Felleisen,et al.  A calculus for assignments in higher-order languages , 1987, POPL '87.

[14]  Jan Midtgaard,et al.  Control-flow analysis of functional programs , 2007, CSUR.

[15]  James Cheney,et al.  Functional programs that explain their work , 2012, ICFP.

[16]  Matthew Might,et al.  Abstracting abstract machines , 2010, ICFP '10.

[17]  Matthias Felleisen,et al.  A tail-recursive machine with stack inspection , 2004, TOPL.

[18]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[19]  Thomas P. Jensen,et al.  Control-flow analysis of function calls and returns by abstract interpretation , 2012, Inf. Comput..

[20]  Jean-Louis Krivine,et al.  A call-by-name lambda-calculus machine , 2007, High. Order Symb. Comput..

[21]  Scott F. Smith,et al.  Static enforcement of security with types , 2000, ICFP '00.

[22]  Neil D. Jones,et al.  Flow Analysis of Lambda Expressions (Preliminary Version) , 1981, ICALP.

[23]  Vincent Danos,et al.  Rule-Based Modelling of Cellular Signalling , 2007, CONCUR.

[24]  Manfred Broy,et al.  Calculational system design , 1999 .

[25]  Olin Shivers,et al.  Control-flow analysis of higher-order languages of taming lambda , 1991 .

[26]  Williams Ludwell Harrison,et al.  The interprocedural analysis and automatic parallelization of Scheme programs , 1990, LISP Symb. Comput..

[27]  Matthew Might,et al.  Improving flow analyses via ΓCFA: abstract garbage collection and counting , 2006, ICFP '06.

[28]  Andrew W. Appel,et al.  Space-efficient closure representations , 1994, LFP '94.

[29]  P. J. Landin The Mechanical Evaluation of Expressions , 1964, Comput. J..

[30]  Olin Shivers,et al.  CFA2: A Context-Free Approach to Control-Flow Analysis , 2010, ESOP.

[31]  Scott F. Smith,et al.  A systematic approach to static access control , 2001, TOPL.

[32]  Matthias Felleisen,et al.  The calculi of lambda-nu-cs conversion: a syntactic theory of control and state in imperative higher-order programming languages , 1987 .

[33]  Patrick Cousot,et al.  The calculational design of a generic abstract interpreter , 1999 .

[34]  Matthias Felleisen,et al.  Control operators, the SECD-machine, and the λ-calculus , 1987, Formal Description of Programming Concepts.

[35]  Patrick Cousot,et al.  Systematic design of program analysis frameworks , 1979, POPL.

[36]  Matthew Might,et al.  Abstracting abstract machines: a systematic approach to higher-order program analysis , 2011, CACM.

[37]  Patrick Cousot,et al.  Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints , 1977, POPL.

[38]  Neil D. Jones,et al.  Flow analysis of lazy higher-order functional programs , 2007, Theor. Comput. Sci..

[39]  Neil D. Jones,et al.  A flexible approach to interprocedural data flow analysis and programs with recursive data structures , 1982, POPL '82.

[40]  Amr Sabry,et al.  The essence of compiling with continuations , 1993, PLDI '93.

[41]  Olivier Danvy,et al.  A concrete framework for environment machines , 2005, TOCL.

[42]  Matthias Felleisen,et al.  Abstract models of memory management , 1995, FPCA '95.

[43]  Olivier Danvy,et al.  A functional correspondence between call-by-need evaluators and lazy abstract machines , 2003, Inf. Process. Lett..

[44]  Flemming Nielson,et al.  Principles of Program Analysis , 1999, Springer Berlin Heidelberg.

[45]  Thomas P. Jensen,et al.  A Calculational Approach to Control-Flow Analysis by Abstract Interpretation , 2008, SAS.

[46]  Javier Esparza,et al.  Reachability Analysis of Pushdown Automata: Application to Model-Checking , 1997, CONCUR.

[47]  Lasse R. Nielsen,et al.  Refocusing in Reduction Semantics , 2004 .

[48]  David Van Horn,et al.  Types and trace effects of higher order programs , 2008, J. Funct. Program..

[49]  Philip Wadler,et al.  Once upon a type , 1995, FPCA '95.