The corresponding old, slow JavaScript interpreter (shipping Firefox 3.0 and older) is SpiderMonkey. The command-line version can be installed with
$ apt-get install spidermonkey-binAfter that, the command smjs file.js is available. In the executed JavaScript, the function print(expr) can be used to print a line to the terminal window, and
load(filename)
can be used to load another .js file.To get the same functionality with TraceMonkey, you have to compile TraceMonkey for yourself. Here is how to do it:
$ sudo apt-get install gcc g++ make autoconf2.13 mercurialThis creates the shell/js executable, which can be used just like smjs.
$ hg clone http://hg.mozilla.org/tracemonkey/
$ cd tracemonkey/js/src
$ CC='gcc -m32' CXX='g++ -m32' AR=ar \
./configure --disable-debug --enable-optimize --target=i686-pc-linux-gnu
$ make
$ ls -l shell/js
To get a statically linked version of the TraceMonkey command-line interpreter, run this after the regular compilation with make:
$ bash -c 'More information about compiling and benchmarking TraceMonkey can be found on http://blog.mozilla.com/nnethercote/2009/07/27/how-i-work-on-tracemonkey/.
cd shell || exit 1; rm -f js
function c++() { command c++ -static "$@"; }
function g++() { command g++ -static "$@"; }
eval "`make js`"; cd ..; ls -l shell/js'
2 comments:
Thanks for this. Before the step that starts CC= you should run autoconf-2.13. Otherwise there is no ./configure file to run.
Thanks. Also, if you're on Mac OS X, the version of autoconf you get with XCode is too low. Grab MacPorts and do "sudo port install autoconf213" to get a more recent version of autoconf.
Post a Comment