Ariya Hidayat
WebKit
Graphics Dojo
Posted by Ariya Hidayat
 in WebKit, Graphics Dojo
 on Wednesday, March 04, 2009 @ 12:09

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.

9 Responses to “Lightning-fast JavaScript”

» Posted by sOuSiX
 on Wednesday, March 04, 2009 @ 12:27

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.

» Posted by ariya
 on Wednesday, March 04, 2009 @ 12:37
Ariya Hidayat

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

» Posted by Stephan Sokolow
 on Wednesday, March 04, 2009 @ 14:02

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.

» Posted by Stephan Sokolow
 on Wednesday, March 04, 2009 @ 14:03

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

» Posted by gandul
 on Wednesday, March 04, 2009 @ 14:27

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

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

» Posted by Will Stokes
 on Wednesday, March 04, 2009 @ 14:29

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

» Posted by qtuser
 on Wednesday, March 04, 2009 @ 14:56

” 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.

» Posted by ariya
 on Wednesday, March 04, 2009 @ 15:29
Ariya Hidayat

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

» Posted by Florian Link
 on Wednesday, March 04, 2009 @ 21:13

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…)



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.