Lightning-fast JavaScript

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.


Blog Topics:

Comments