Followers

Tuesday, February 10, 2009

New Opera JavaScript engine supports native code generation

By Ryan Paul

New Opera JavaScript engine supports native code generation

The Opera web browser could soon get a script execution performance boost from a new JavaScript engine that supports native code generation. The new engine, which is called Carakan, was unveiled through a technical overview published on the official Opera developer blog on Wednesday.

The growing relevance of script-intensive web applications has compelled browser makers to search for ways to improve the performance of their JavaScript implementations. Renewed competition in the browser space has helped to accelerate this process, as the primary contenders battle to be the fastest. Apple's immensely impressive SquirrelFish Extreme engine currently leads the pack, but Mozilla and Google are also moving forward with new high-performance JavaScript engines. These all use JIT compilation and native code generators to achieve their performance gains.

The new Carackan engine aims to deliver similar functionality and help Opera stay competitive. According to developer Jens Lindström, Opera has had a small team working on the new engine for several months. Carakan will replace Futhark, the engine that is used in the latest stable version of Opera. Futhark, which was introduced in Opera 9.5, is a lightweight, stack-based bytecode interpreter that was designed with an emphasis on low memory consumption rather than optimal execution speed. Carakan supports a new register-based virtual machine and a nascent native code generator that leverages static type analysis.

Although the native code generator isn't ready yet, the new virtual machine is already much faster than the previous one. Builds aren't available to the public yet, but Opera says that it's internal benchmarking shows that Carackan is roughly 2.5 times faster in the SunSpider benchmark. With native code generation, the performance difference will be much more significant.

"The native code generation in Carakan is not yet ready for full-scale testing, but the few individual benchmark tests that it is already compatible with runs between 5 and 50 times faster, so it is looking promising so far," Lindström wrote. "On ECMAScript code that is particularly well-suited for native code conversion, our generated native code looks more or less like assembly code someone could have written by hand, trying to keep everything in registers."

The conventional x86 and 64-bit native code generator backends have already been mostly implemented, but the ARM backend is still only at a very early stage of development. ARM support could potentially enable a whole new class of JavaScript-heavy web applications to work on handsets that run Opera's mobile browser.

Opera has also released some additional technical details about Vega, a hardware-accelerated vector graphics library that is used by the browser. Vega was originally developed to facilitate the implementation of SVG support in Opera, and it has since been adapted to power the HTML5 Canvas element. Opera developer Tim Johansson says that the browser could soon use Vega for all HTML rendering. This could potentially simplify the codebase by eliminating the need for platform-specific rendering code paths. It will also simplify implementation of some advanced CSS3 features and make it possible to leverage hardware acceleration for complex drawing.

Opera's move towards high-performance JavaScript and hardware accelerated graphics is another indication of how the reinvigorated browser market is leaving even the smaller players with a stark choice: keep pace or face irrelevance. The winners are clearly users, who can use the latest and greatest on the web with the browser of their choice.

Original here

No comments: