Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Mimic: Computing Models for Opaque Code

Mimic is a research prototype to automatically compute models for JavaScript functions whose source code is not available or not easily processed by automatic tools. Our research paper at the ACM SIGSOFT Symposium on the Foundations of Software Engineering 2015 conference gives some more details, and is freely available:


This project requires node, its package manager npm, as well as grunt to run. It also requires python and make. Make sure they are installed first (Ubuntu and alike):

sudo apt-get install nodejs-legacy npm make
sudo npm install -g grunt-cli

Then, install all dependencies via npm:

npm install

Finally build the project:


You may want to make sure that all tests pass to verify the build by running make test.

Note: We have mostly tried running this prototype on Ubuntu. A quick test on OS X seemed to have trouble installing some of the dependencies.


To run the model synthesis, the script mimic can be used. It's usage is as follows:

> ./mimic --help
usage: [-h] [-t <n>] --function <body> --arguments <arglist>
              [<arglist> ...] [--argnames <names>] [--args <args>]
              [--metric <m>] [--out OUT] [--nocolor] [--debug]
              [--parallel_t0 <t0>] [--parallel_f <f>]

Run Mimic to compute models for opaque code

optional arguments:
  -h, --help            show this help message and exit
  -t <n>, --threads <n>
                        Number of threads (-1 = 1/2 of cores available)
                        (default: -1)
  --function <body>     The function body of the opaque code (as JavaScript
                        source code) (default: None)
  --arguments <arglist> [<arglist> ...]
                        One (or more) initial inputs to the opaque code as a
                        comma-separated list (default: None)
  --argnames <names>    The name of the arguments (default: arg0, arg1, arg2,
                        arg3, arg4, arg5, arg6)
  --args <args>         Arguments to be passed to mimic-core (default: )
  --metric <m>          The metric to use (0 for default, 1 for naive metric)
                        (default: 0)
  --out OUT             Location where the resulting function should be
                        written to (default: result.js)
  --nocolor             Don't use any color in the output (default: False)
  --debug               Output debug information, and only do a single run of
                        mimic-core (default: False)
  --parallel_t0 <t0>    The timeout to be used in the first phase (default: 3)
  --parallel_f <f>      The factor with which to increase the timeout (based
                        on a single thread, and scaled appropriately for more
                        threads) (default: 1.025)

As an example, the following command synthesizes code for the identify function:

./mimic --function "return x" --argnames "x" --arguments "1" "2"

Mimic works by running multiple instances of mimic-core internally, each with a different random seed, and stops as soon as one of them succeeds. To understand the tool a little better, it is possible to run mimic with the option --debug, which will only launch a single copy of mimic-core, and output various information along the way. For example:

./mimic --function "return x" --argnames "x" --arguments "1" "2" --debug

It is also possible to run mimic-core directly. Furthermore, we have collected a few examples from the array standard library, and the script scripts/ can be used to conveniently access them. For instance, the following command synthesizes a JavaScript model for the Array.prototype.pop function:

scripts/ pop

Finally, there are two more useful scripts included: scripts/ repeats runs of mimic for all examples and gathers statistics. The script scripts/ can then be used to analyze that information. Pass --help to them to get more information on how to use them.


Tests are written using mocha, and can be run by the following command:

make test


The model synthesis code is distributed under the Apache License.


Synthesizer for JavaScript API models







No releases published


No packages published