Slide 1

Slide 1 text

Universit´ e Libre de Bruxelles Computer Science Department MEMO-F524 Masters thesis An Efficient and Parallel Abstract Interpreter in Scala — Presentation — Olivier Pirson — [email protected] orcid.org/0000-0001-6296-9659 November 27, 2017 https://bitbucket.org/OPiMedia/efficient-parallel-abstract-interpreter-in-scala Vrije Universiteit Brussel Promotors Coen De Roover Wolfgang De Meuter Advisor Quentin Stievenart

Slide 2

Slide 2 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References 1 Abstract interpretation for static analysis 2 Concrete vs abstract interpretation 3 Parallelism 4 Next steps 5 References An Efficient and Parallel Abstract Interpreter in Scala — Presentation 2 / 24

Slide 3

Slide 3 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References How do better than testing? “The first moral of the story is that program testing can be used very effectively to show the presence of bugs but never to show their absence.” (Dijkstra, 1971–1973) Figure: First “flight” of Ariane 5 in 1996. Investigation of Ariane failure: first large-scale example of static analysis by abstract interpretation. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 3 / 24

Slide 4

Slide 4 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Static analysis Static analysis of program: analysis made without executing program. Goal? Prove some properties of program (like correctness, or some properties use to transform and optimize program). Or in the opposite, find bugs. Problem! Undecidable problem (we know that by Rice’s theorem). An Efficient and Parallel Abstract Interpreter in Scala — Presentation 4 / 24

Slide 5

Slide 5 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Static analysis by abstract interpretation Abstract interpretation: approximation technique to perform static analysis. Based on mathematical notion of partially ordered sets (in particular lattice). Difficulty! Find good abstractions: enough precise to prove desired property, and enough approximate to be decidable (and with doable complexity). Figure: Ren´ e Magritte, Le Calcul Mental. 1940. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 5 / 24

Slide 6

Slide 6 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Example of abstraction {. . . , −3, −2, −1, 0, 1, 2, 3, . . .} abstracted by sign = {⊥, +, 0, −, ⊤} ⊤ − 0 + ⊥ Figure: Hasse diagram of the complete lattice of signs. top ⊤ = {. . . , −3, −2, −1, 0, 1, 2, 3, . . .} + = {1, 2, 3, . . .} 0 = {0} − = {−1, −2, −3, . . .} bottom ⊥ = ∅ May be good abstraction for multiplication operations. With additions, directly loss of precision. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 6 / 24

Slide 7

Slide 7 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References 1 Abstract interpretation for static analysis 2 Concrete vs abstract interpretation 3 Parallelism 4 Next steps 5 References An Efficient and Parallel Abstract Interpreter in Scala — Presentation 7 / 24

Slide 8

Slide 8 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Concrete interpretation Trace: concrete interpretation with small-step semantics, for one instance. e s0 s1 s2 s3 s4 · · · injection function concrete transition function Program is executed by interpreter, described by an Abstract Machine (AM). One execution is for one instance on this program. e is for one expression, i.e. a program. si are states during this execution. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 8 / 24

Slide 9

Slide 9 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Abstract interpretation Trace: concrete interpretation with small-step semantics, for one instance. e s0 s1 s2 s3 s4 · · · s0 s1 s2 s3 s4 s3′ injection function injection function abstraction function α abstract transition function Abstracting Abstract Machine (AAM). 2 over-approximations: Finite state space. Abstract transition function returns all directly reachable states. State graph: abstract interpretation, for all instances. “The abstract simulates the concrete” (Might) An Efficient and Parallel Abstract Interpreter in Scala — Presentation 9 / 24

Slide 10

Slide 10 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Concrete interpretation Correct program Incorrect program Figure: Patrick Cousot. Abstract Interpretation in a Nutshell. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 10 / 24

Slide 11

Slide 11 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Abstract interpretation Correct program Incorrect program Figure: Patrick Cousot. Abstract Interpretation in a Nutshell. Correct abstract interpretation Incorrect abstract interpretation An Efficient and Parallel Abstract Interpreter in Scala — Presentation 11 / 24

Slide 12

Slide 12 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Abstract interpretation Correct abstract interpretation Incorrect abstract interpretation Figure: Patrick Cousot. Abstract Interpretation in a Nutshell. Summary of difficulties: Decidability? Soundness vs completeness? Good complexity vs precision? =⇒ Parallelism An Efficient and Parallel Abstract Interpreter in Scala — Presentation 12 / 24

Slide 13

Slide 13 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References 1 Abstract interpretation for static analysis 2 Concrete vs abstract interpretation 3 Parallelism 4 Next steps 5 References An Efficient and Parallel Abstract Interpreter in Scala — Presentation 13 / 24

Slide 14

Slide 14 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Goal of the thesis: parallelism to improve speed Parallelism to keep good precision and improve speed. I will parallelize Scala-AM, implemented by Quentin Stievenart. Target language: Scheme (“simple” but “general”). An Efficient and Parallel Abstract Interpreter in Scala — Presentation 14 / 24

Slide 15

Slide 15 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Actor model Actor, like an object, isolated entity with its own encapsulated data and behaviour. With some fundamental differences. Entirely private. No shared mutable state (so no data race). Communication by immutable asynchronous messages (sent and received sequentially). Each actor has a mailbox (a queue). Capability to create other actors. Figure: Richard Doyle. Using Akka and Scala to Render a Mandelbrot Set. 2014. http://blog.scottlogic.com/2014/08/15/using-akka-and-scala-to-render-a-mandelbrot-set.html An Efficient and Parallel Abstract Interpreter in Scala — Presentation 15 / 24

Slide 16

Slide 16 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Akka toolkit Akka: toolkit for Scala (and also Java). Concurrent and distributed (use many cores or several computers without modification). Reduced overhead. Light implementation of actors (in 1 GiB memory, possibility of millions actors, instead thousands of threads). An Efficient and Parallel Abstract Interpreter in Scala — Presentation 16 / 24

Slide 17

Slide 17 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Sequential worklist strategy s s s s s worklist Figure: K. Dewey, V. Kashyap, B. Hardekopf. A parallel abstract interpreter for JavaScript. 2015. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 17 / 24

Slide 18

Slide 18 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Naive worklist parallel strategy s s s s s worklist merge Figure: K. Dewey, V. Kashyap, B. Hardekopf. A parallel abstract interpreter for JavaScript. 2015. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 18 / 24

Slide 19

Slide 19 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Naive worklist parallel strategy Redundant computations. Synchronization at the merge step. Article test on few real JavaScript programs. Results show that this adaptation of the sequential algorithm is not optimal. Figure: L. Andersen, M. Might. Multi-core Parallelization of Abstracted. 2013. I am curious about the results of this algorithm with the lot of little Scheme programs with Scala-AM. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 19 / 24

Slide 20

Slide 20 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Better, per-context parallel strategy Authors introduce a per-context parallel strategy. The main idea is to separate these two parts: state exploration control of state space by some merging operations. The intuitive idea is to parallelize “functions” instead basic “blocks”. Figure: K. Dewey, V. Kashyap, B. Hardekopf. A parallel abstract interpreter for JavaScript. 2015. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 20 / 24

Slide 21

Slide 21 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References 1 Abstract interpretation for static analysis 2 Concrete vs abstract interpretation 3 Parallelism 4 Next steps 5 References An Efficient and Parallel Abstract Interpreter in Scala — Presentation 21 / 24

Slide 22

Slide 22 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References Next steps A lot of work! Become more comfortable with actors paradigm and Akka. Implement the naive parallel algorithm, and experiment. Implement better parallel algorithms. Evaluate all of them and identify problematic parts. Read more. . . . An Efficient and Parallel Abstract Interpreter in Scala — Presentation 22 / 24

Slide 23

Slide 23 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References 1 Abstract interpretation for static analysis 2 Concrete vs abstract interpretation 3 Parallelism 4 Next steps 5 References An Efficient and Parallel Abstract Interpreter in Scala — Presentation 23 / 24

Slide 24

Slide 24 text

An Efficient and Parallel Abstract Interpreter in Scala — Presentation Abstract interpretation for static analysis Concrete vs abstract interpretation Parallelism Next steps References References Thank you! Questions time. . . L. Andersen, M. Might. Multi-core Parallelization of Abstracted Abstract Machines. 2013. Patrick Cousot. Abstract Interpretation in a Nutshell. K. Dewey, V. Kashyap, B. Hardekopf. A parallel abstract interpreter for JavaScript. 2015. Matthew Might. Tutorial: Small-step CFA. 2011. Quentin Sti´ evenart. Static Analysis of Concurrency Constructs in Higher-Order Programs. 2014. D. Van Horn, M. Might. Abstracting Abstract Machines. 2010. Document, L A TEX sources, and complete references on Bitbucket: https:// Ø Ù ØºÓÖ »ÇÈ Å /efficient-parallel-abstract-interpreter-in-scala Olivier Pirson. An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work. 2017. An Efficient and Parallel Abstract Interpreter in Scala — Presentation 24 / 24