Lightning-fast JavaScript

Posted by Ariya Hidayat on March 4, 2009 · 9 comments

Since Qt 4.5 is released already, it is about time we – the QtWebKit team inside Qt Software – show few cool features that you can get from QtWebKit in this new release. This time let us focus on JavaScript. If you read the What’s New on our website, it mentions something about “lighting-fast JavaScript engine”. Fast is qualitative, right? As software engineers, we always want to know how fast is fast.

For Qt 4.5, the JavaScript engine is powered by a new bytecode interpreter, along with optional JIT (just-in-time) compile support. They are often referred as SquirrelFish and SquirrelFish Extreme, respectively. This interpreter has been developed by Apple engineers working on WebKit in order to speed-up JavaScriptCore, the backbone of WebKit’s JavaScript engine. The interpreter makes its first appearance in the recent Safari 4 Public Beta, where it is dubbed as Nitro JavaScript Engine.

Specific to QtWebKit in 4.5, we enable the JIT compiler for the following supported platforms: Linux with gcc 4.1 or newer and Microsoft Windows with MSVC. There are several reasons why other platform combinations are not supported (yet), but the main reason is our own priority and resource availability. However, even without the JIT, the new JavaScript engine should be much faster already compared to the one shipped with Qt 4.4.

To compare the performance, here is the result running SunSpider benchmark with our demo browser in Qt 4.4 and Qt 4.5, the latter with and without JIT. The test machine is a typical four-core desktop running OpenSUSE 10.3. The test duration is converted to the number of runs per minute. Longer is better.

Let us try another one: V8 benchmark suite. The raw scores are shown here, again longer is better.

So even without JIT, JavaScript-heavy application could already benefit from the speed-up. And if you plan to build hybrid web/C++ applications, do not be afraid to put more and more application logic in its JavaScript side.

PS: For Qt 4.6 we would evaluate the possibility of using JavaScriptCore as the back-end for QtScript. However, please treat it like a research project, hence do not hold your breath as right now we can not give any guarantee that it will make it for 4.6.

QShare(this)

Possibly related posts:

  1. Qt people, our JavaScript platform is burning rubber

9 comments

1 sOuSiX March 4, 2009 at 1:27 pm
 

Yes, that a good point but JIT is only available on x86. So no optimisation for ARM cpu. :-/
The JIT compile support of Tracemonkey (Firefox 3.1+) and V8 (Google Chrome) are available for x86 and ARM.

2 ariya March 4, 2009 at 1:37 pm
 

@sOuSiX: One step at a time, please. Sooner or later ARM support will be there.

3 Stephan Sokolow March 4, 2009 at 3:02 pm
 

The x86-only bit really annoys me because I’m running x86_64 to make sure I don’t accidentally rely on applications with word-size issues.

4 Stephan Sokolow March 4, 2009 at 3:03 pm
 

Oops. Well… I think you know what I meant to say.

5 gandul March 4, 2009 at 3:27 pm
 

Hello, any news about the DOM API that was promised long time ago?

Other than that: Great work this is an epic release!

6 Will Stokes March 4, 2009 at 3:29 pm
 

Why no JIT for Windows w/ MinGW (aka gcc)?

7 qtuser March 4, 2009 at 3:56 pm
 

” Linux with gcc 4.1 or newer and Microsoft Windows with MSVC. ”

and OS X correct?

ps. this is my 4th try on the captcha. let’s see if THIS time works.

8 ariya March 4, 2009 at 4:29 pm
 

@Will: Because nobody has the time yet to make it work.

9 Florian Link March 4, 2009 at 10:13 pm
 

Yes, please write a JavaScriptCore backend for QtScript! And unify the Qt script binding, so that you can access the whole Qt API from WebKit/JavaScriptCore (not only QObject and QWidget pointers…)

Comments on this entry are closed.

Previous post:

Next post: