Monday, February 4th, 2008

Adobe Tamarin Tracing JIT for JavaScript

Category: JavaScript, Performance

Chris Double attended the Tamarin Tech summit, and gives us some information about Tamarin Tracing the new trace based JIT experiment:

‘Tamarin Tracing’ is an implementation that uses a ‘tracing jit’. This type of ‘just in time compiler’ traces code executing during hotspots and compiles it so when those hotspots are entered again the compiled code is run instead. It traces each statement executed, including within other function calls, and this entire execution path is compiled. This is different from compiling individual functions. You can gain more information for the optimizer to operate on, and remove some of the overhead of the calls. Anytime the compiled code makes a call to code that has not been jitted, the interpreter is called to continue.

Apparently the JIT for Lua is also being written using a tracing jit method and a post by Mike Pall describes the approach they are taking in some detail and lists references. A followup post provides more information and mentions Tamarin Tracing.

Brendan Eich talked about trace based JIT’s as being the future of JavaScript VM’s, and a reason why we will see insanely fast JavaScript without needing all of the type fun.

Here is one simple benchmark of a fibonaci equation solution that doesn’t do any caching tricks:

# Turn off the tracer
$ shell/avmshell -lifespan -interp fib.abc
fib 30 = 1346269
Run time was 26249 msec = 26.25 sec

# Turn on the tracer
$ shell/avmshell -lifespan fib.abc
fib 30 = 1346269
Run time was 1967 msec = 1.97 sec

Chris finishes with some fun facts:

  • The interpreter is written in Forth. There are .fs files in the ‘core’ subdirectory that contains the Forth source code. Each ‘abc’ bytecode is implemented in lower level instructions which are implemented in Forth. The tracing jit operates on these lower level instructions. The system can be extended with Forth code to call native C functions. The compiler from Forth to C++ is written in Python and is in ‘utils/fc.py’
  • The jit has two backends. One for Intel x86 32 bit, and the other for ARM. See the ‘nanojit’ subdirectory.
  • The complete interpreter source can be rebuilt from the Forth using ‘core/builtin.py’. This requires ‘asc.jar’ to be placed in the ‘utils’ subdirectory of Tamarin Tracing.

Posted by Dion Almaer at 9:33 am
Comment here

++++-
4 rating from 27 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.