Home

Awesome

JSAI: JavaScript Abstract Interpreter

NOTE: This is a clone of the source code for the paper "JSAI: A Static Analysis Platform for JavaScript" (FSE'14). Downloaded from the UCSB PL Lab.

I've updated the Scala and SBT versions and removed WithRewriter.jar from the unmanagedJars (this prevents dependency problems in other projects of mine.

--nystrom

The document notjs.pdf contains the formal specification of the notJS IR, its concrete and abstract semantics. This document references builtin.pdf. The document translation.pdf contains formalisms for translation from JavaScript to notJS and the document proof-sketches.pdf contains proof sketches for the object abstract domain.

Installation

In order to install and run the analysis, you will need:

  1. sbt version 0.13.15.
  2. Scala version 2.12.2.

Building

To build the project:

  1. Do a clean
$ sbt clean
  1. Do a build
$ sbt compile

Running

To run the concrete interpreter:

$ sbt "run-main notjs.concrete.interpreter.notJS <JavaScript file name> <options>"

The different options to the concrete interpreter are:

  1. --print: This will print out the argument provided to the print() calls in the provided JavaScript file.
  2. --testing: This is used for testing concrete interpreter with the abstract interpreter.
  3. --catchexc: This will reduce clutter in output produced due to exceptions thrown.
  4. --printid: This will print out the argument provided to the print calls, along with the ids of the print statements, helpful to debug along with abstract interpreter output.

To run the abstract interpreter:

$ sbt "run-main notjs.abstracted.interpreter.notJS <JavaScript file name> <options>"

The different options to the abstract interpreter are:

  1. --lightgc: Perform lightweight gc.
  2. --fullgc: Perform full gc.
  3. --prune: Perform store pruning.
  4. --testing: To be provided when tested against the concrete interpreter.
  5. --print: This will print out the argument provided to the print() calls in the provided JavaScript file.
  6. --catchexc: This will reduce clutter in output produced due to exceptions thrown.
  7. --timeout=: This is used to provide a timeout (in seconds), if the abstract interpreter takes more than the specified timeout, an exception is thrown.
  8. --trace=: This is used to provide various traces. Consult src/main/scala/abstract/interpreter.scala for available traces.

More options can be seen from src/main/scala/abstract/interpreter.scala.

Note: if the JavaScript file has with construct, please use the with rewriter in lib/WithRewriter.jar (java -jar WithRewriter.jar [inputfile name] [outputfile name]). All credits to the rewriter go to Programming Language Research Group @KAIST (http://plrg.kaist.ac.kr/research/software).

Running the tests

To run the simple abstract tests:

$ sbt "test-only notjs.tester.abstracted.SimpleTests"

To run the simple abstract tests with various options:

$ sbt "test-only notjs.tester.abstracted.SimpleTestsWithOptions"

To run the simple abstract tests with various traces:

$ sbt "test-only notjs.tester.abstracted.SimpleTestsWithTraces"

To run the Sun Spider tests (by default, the options are --prune and trace=stack-1-0:

$ sbt "test-only notjs.tester.abstracted.SunSpiderTests"

Running pretty printers

To run the text pretty printer:

$ sbt "run-main notjs.syntax.TextPrint <js file> <output file> --debug"

To run the code pretty printer:

$ sbt "run-main notjs.syntax.CodePrint <js file> <output file> --debug"

To run the dotty pretty printer:

$ sbt "run-main notjs.syntax.DotPrint <js file> <output file> --debug"

Each of these can also be run without the --debug flag, that does not treat calls to print specially.