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:
- sbt version 0.13.15.
- Scala version 2.12.2.
Building
To build the project:
- Do a clean
$ sbt clean
- 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:
--print
: This will print out the argument provided to theprint()
calls in the provided JavaScript file.--testing
: This is used for testing concrete interpreter with the abstract interpreter.--catchexc
: This will reduce clutter in output produced due to exceptions thrown.--printid
: This will print out the argument provided to theprint
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:
--lightgc
: Perform lightweight gc.--fullgc
: Perform full gc.--prune
: Perform store pruning.--testing
: To be provided when tested against the concrete interpreter.--print
: This will print out the argument provided to theprint()
calls in the provided JavaScript file.--catchexc
: This will reduce clutter in output produced due to exceptions thrown.--timeout=
: This is used to provide a timeout (in seconds), if the abstract interpreter takes more than the specified timeout, an exception is thrown.--trace=
: This is used to provide various traces. Consultsrc/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.