8 Suggested reading
Dominic Gannaway edited this page 2018-05-08 11:22:25 +01:00

If you are new to the project, and want to pick up some background knowledge, here are some pointers.

JavaScript code processing

Prepack uses Babel to parse and generator JavaScript code. The Prepack's interpreter is directly interpreting the Babel AST.

JavaScript semantics

At the core of Prepack is an almost ECMAScript 5 compatible interpreter — implemented in JavaScript! The interpreter closely follows the ECMAScript 2016 Language Specification, with a focus on correctness and spec conformance. You can think of the interpreter in Prepack as a clean reference implementation of JavaScript.

Symbolic execution

Prepack's interpreter has the ability to operate on abstract values which typically arise from environment interactions. For example, Date.now can return an abstract value. You can also manually inject abstract values via auxiliary helper functions such as __abstract(). Prepack tracks all operations that are performed over abstract values. When branching over abstract values, Prepack will fork execution and explore all possibilities. Thus, Prepack implements a Symbolic Execution engine for JavaScript. To deal with the state exploration problem, Prepack may join variables and heap properties, resulting in conditional abstract values.

Partial evaluation

In its main mode of operation, Prepack achieves similar effects to partial evaluation, but it doesn't do so using the traditional partial evaluation approach. In any case, here are some references:

Abstract interpretation

At this time, Prepack only makes limited use of abstract interpretation, in particular around tracking type and value domains, and to compute limited loop and recursion fixed points.

Code generation

After interpretation has computed all relevant effects of the code, in the form of a final heap, the effects are being serialized as another JavaScript program.