The run-time module provides standard objects such as String, Math, Array, etc.
To get SpiderMonkey source code, you can either use the release distribution or Mercurial. At the time of this writing, the latest development release is 1.8 RC1. If you want to stay bleeding-edge, use your favorite Mercurial client to get the source code as follows:
hg clone http://hg.mozilla.org/mozilla-central/ cd mozilla-central/js/src/
This essentially grabs the entire Mozilla source code. SpiderMonkey itself is in the
To compile it, just run the following:
autoconf213 ./configure --disable-debug --enable-optimize make
Note that autoconf version 2.13 is required, so any other version might not work. For Mac OS X, you can get it via MacPorts, i.e. running
sudo port install autoconf213. Many Linux distributions also offer autoconf 2.13 under various package names (e.g.
autoconf213 on OpenSUSE), use your package manager to find it.
shell/js. If you launch it from a terminal, you can interact with the interpreter:
~/mozilla-central/js/src > shell/js js> print("Hello, SpiderMonkey") Hello, SpiderMonkey js> var x = 42; print("x is " + x); x is 42 js> quit()
As you can see, the mini interpreter has several built-in functions, notably print() and quit().
If you face a problem and/or want to know more in details, refer to the official build documentation.
You need to use Subversion to check out the code:
svn checkout http://svn.webkit.org/repository/webkit/trunk webkit cd webkit
or use Git to clone it from the git mirror:
git clone git://git.webkit.org/WebKit.git webkit cd webkit
The build process depends on your platform. Because the engine was was originally developed by Apple, it is very easy to build it on Mac OSX. On Mac OSX, just use XCode to open
build/Release/jsc for the output).
The mini interpreter will be built as a
jsc executable in the same directory.
Note: Obviously, you need Qt libraries before you can do the above steps. Almost every Linux distribution offers a ready-to-use binary package, usually under the name
libqt4-dev or some variation thereof. You also have the option to download and install it from the official Qt web site.
Compared to the previous two, V8 is the youngest engine and was developed by Google to power the Chrome browser.
The code can be obtained from its official repository using Subversion:
svn checkout http://v8.googlecode.com/svn/trunk/ v8 cd v8
or use Git to clone it from the mirror:
git clone git://github.com/v8/v8.git v8 cd v8
V8 uses scons as its build system so make sure you have it. Mac OSX users can get that easily via MacPorts. Linux users should be able to install it using the package manager.
The build steps are very simple:
scons sample=shell mode=release snapshot=on
The executable named
~/v8 > ./shell V8 version 2.4.8 (candidate) > print("Hello, V8"); Hello, V8 > quit();
SunSpider/sunspider will run the test.
Note: Before you run any benchmarks, make sure all the engines are built using the “optimized for release build” compiler settings. Otherwise, any comparison will be unfair.
To run SunSpider tests with SpiderMonkey, run the following:
perl sunspider --shell=/path/to/mozilla-central/js/src/build-release/js --args=-j
The last argument is needed so that the garbage collector can be explicitly triggered.
And finally, with V8, use:
perl sunspider --shell=/path/to/v8/directory/shell --args=-expose-gc