BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News V8's New JavaScript Interpreter Improves Memory Consumption

V8's New JavaScript Interpreter Improves Memory Consumption

This item in japanese

Bookmarks

Google has announced that their new JavaScript interpreter, Ignition, will go live in Chrome 53 for some limited memory Android devices.

In a blog post, Google Staff Software Engineer Ross McIlroy dove into the reasons behind building Ignition.

Currently, V8 does not have an interpreter. Instead, initial execution JavaScript code is first parsed and compiled into an unoptimized state. Because of the way the parser and compilers work together, some code is later parsed two or even three times. In all, Google says that V8 spends 33% of a page's startup time parsing and compiling code. This also results in significant memory cost.

By using an interpreter, Google hopes to reduce the memory usage of the current system. Ignition still relies on a parser, but the JavaScript is compiled to bytecodes rather than native code. "Rather than compiling to machine code, we're compiling [with Ignition] to concise bytecodes that can be much smaller. So, we can reduce the memory usage, particularly with functions that aren't executed very often," says McIlroy.

Because the bytecode is small, it can compile the entire source rather than trying to avoid compiling code that isn't used. This means the script only has to be parsed once rather than the multiple times of the current compilation process.

McIlroy also provided some technical details:

The Ignition interpreter uses TurboFan’s low-level, architecture-independent macro-assembly instructions to generate bytecode handlers for each opcode. TurboFan compiles these instructions to the target architecture, performing low-level instruction selection and machine register allocation in the process. Ignition is a register machine, with each bytecode specifying its inputs and outputs as explicit register operands, as opposed to a stack machine where each bytecode would consume inputs and push outputs on an implicit stack.

Other browser vendors already use an interpreter as a first stage. Both Mozilla's SpiderMonkey and Microsoft's Chakra JavaScript engines start with an interpreter and both are connected to a two-tier compilation system.

Starting with Chrome 53, set for stable release in early September, Android devices with 512 MB or less of RAM will start using Ignition. For a deep-dive into Ignition, Google has posted the design document.

Rate this Article

Adoption
Style

BT