FlowSpec: A declarative specification language for intra-procedural flow-Sensitive data-flow analysis

Abstract Data-flow analysis is the static analysis of programs to estimate their approximate run-time behavior or approximate intermediate run-time values. It is an integral part of modern language specifications and compilers. In the specification of static semantics of programming languages, the concept of data-flow allows the description of well-formedness such as definite assignment of a local variable before its first use. In the implementation of compiler back-ends, data-flow analyses inform optimizations. Data-flow analysis has an established theoretical foundation. What lags behind is implementations of data-flow analysis in compilers, which are usually ad-hoc. This makes such implementations difficult to extend and maintain. In previous work researchers have proposed higher-level formalisms suitable for whole-program analysis in a separate tool, incremental analysis within editors, or bound to a specific intermediate representation. In this paper, we present FlowSpec , an executable formalism for specification of data-flow analysis. FlowSpec is a domain-specific language that enables direct and concise specification of data-flow analysis for programming languages, designed to express flow-sensitive, intra-procedural analyses. We define the formal semantics of FlowSpec in terms of monotone frameworks. We describe the design of FlowSpec using examples of standard analyses. We also include a description of our implementation of FlowSpec . In a case study we evaluate FlowSpec with the static analyses for Green-Marl , a domain-specific programming language for graph analytics.

[1]  Eelco Visser,et al.  The spoofax language workbench: rules for declarative specification of languages and IDEs , 2010, OOPSLA.

[2]  S. Doaitse Swierstra,et al.  Higher order attribute grammars , 1989, PLDI '89.

[3]  Görel Hedin,et al.  Reference Attributed Grammars , 2000, Informatica.

[4]  Eelco Visser,et al.  Declarative Name Binding and Scope Rules , 2012, SLE.

[5]  Sebastian Erdweg,et al.  An extensible framework for variable-precision data-flow analyses in MPS , 2016, 2016 31st IEEE/ACM International Conference on Automated Software Engineering (ASE).

[6]  Anthony M. Sloane,et al.  Decorated Attribute Grammars . Attribute Evaluation Meets Strategic Programming ( Extended Technical Report ) , 2008 .

[7]  Susan Horwitz,et al.  An efficient general iterative algorithm for dataflow analysis , 2004, Acta Informatica.

[8]  D UllmanJeffrey,et al.  Global Data Flow Analysis and Iterative Algorithms , 1976 .

[9]  Görel Hedin,et al.  Circular reference attributed grammars - their evaluation and applications , 2003, Sci. Comput. Program..

[10]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[11]  Eelco Visser,et al.  FlowSpec: declarative dataflow analysis specification , 2017, SLE.

[12]  Christian Wimmer,et al.  Truffle: a self-optimizing runtime system , 2012, SPLASH '12.

[13]  Yannis Smaragdakis,et al.  Strictly declarative specification of sophisticated points-to analyses , 2009, OOPSLA '09.

[14]  Martin Hopkins,et al.  An overview of the PL.8 compiler , 1982, SIGP.

[15]  Ondrej Lhoták,et al.  From Datalog to flix: a declarative language for fixed points on lattices , 2016, PLDI.

[16]  Ondrej Lhoták,et al.  Pick your contexts well: understanding object-sensitivity , 2011, POPL '11.

[17]  Torbjörn Ekman,et al.  The JastAdd system - modular extensible compiler construction , 2007, Sci. Comput. Program..

[18]  David J. Pearce,et al.  Structural and Flow-Sensitive Types for Whiley , 2010 .

[19]  Yannis Smaragdakis,et al.  Pointer Analysis , 2015, Found. Trends Program. Lang..

[20]  Guido Wachsmuth,et al.  A constraint language for static semantic analysis based on scope graphs , 2015, PEPM.

[21]  Eelco Visser,et al.  Program Transformation with Scoped Dynamic Rewrite Rules , 2006, Fundam. Informaticae.

[22]  Eelco Visser,et al.  A Theory of Name Resolution , 2015, ESOP.

[23]  Torbjörn Ekman,et al.  Extensible intraprocedural flow analysis at the abstract syntax tree level , 2013, Sci. Comput. Program..

[24]  Eelco Visser,et al.  Stratego/XT 0.17. A language and toolset for program transformation , 2008, Sci. Comput. Program..

[25]  Paul Klint,et al.  EASY Meta-programming with Rascal , 2009, GTTSE.

[26]  Jeffrey D. Ullman,et al.  Global Data Flow Analysis and Iterative Algorithms , 1976, J. ACM.

[27]  Torbjörn Ekman,et al.  Extending Attribute Grammars with Collection Attributes--Evaluation and Applications , 2007, Seventh IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM 2007).

[28]  Olin Shivers Higher-order control-flow analysis in retrospect: lessons learned, lessons abandoned , 2004, SIGP.

[29]  Kunle Olukotun,et al.  Green-Marl: a DSL for easy and efficient graph analysis , 2012, ASPLOS XVII.

[30]  Jeffrey D. Ullman,et al.  Monotone data flow analysis frameworks , 1977, Acta Informatica.

[31]  Gary A. Kildall,et al.  A unified approach to global program optimization , 1973, POPL.

[32]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[33]  Eelco Visser,et al.  Declarative specification of template-based textual editors , 2012, LDTA.

[34]  Sebastian Erdweg,et al.  IncA: A DSL for the definition of incremental program analyses , 2016, 2016 31st IEEE/ACM International Conference on Automated Software Engineering (ASE).

[35]  Tamás Szabó IncA L : A DSL for Incremental Program Analysis with Lattices , 2017 .

[36]  Didier Parigot,et al.  Techniques for Improving Grammar Flow Analysis , 1990, ESOP.

[37]  Michael F. P. O'Boyle,et al.  CAnDL: a domain specific language for compiler analysis , 2018, CC.

[38]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[39]  Anthony M. Sloane,et al.  Respect Your Parents: How Attribution and Rewriting Can Get Along , 2014, SLE.

[40]  Alex Bavelas,et al.  Communication Patterns in Task‐Oriented Groups , 1950 .

[41]  Eelco Visser,et al.  Domain-Specific Languages for Composable Editor Plugins , 2010, Electron. Notes Theor. Comput. Sci..

[42]  Robert E. Tarjan,et al.  Depth-First Search and Linear Graph Algorithms , 1972, SIAM J. Comput..

[43]  Mark Hills Streamlining Control Flow Graph Construction with DCFlow , 2014, SLE.

[44]  Eric Van Wyk,et al.  Silver: An extensible attribute grammar system , 2008, Sci. Comput. Program..

[45]  Elnar Hajiyev,et al.  Keynote Address: .QL for Source Code Analysis , 2007 .