For the V8 JavaScript engine

Feb 5, 2009 12:40 GMT  ·  By

As early as the first Beta build, Google Chrome 1.0 indicated a consistent appetite for JS performance, and the Mountain View search giant is committed to the evolution of the underlying V8 JavaScript engine. An illustrative example in this regard is the Google Chrome 2.0.160.0 release, which brings to the table enhancements delivering even more horsepower to the JS engine. The Google Chrome 2.0.160.0 dev-channel build comes to the table with an overhauled implementation of regular expressions (regexps). Google labeled the new V8 JavaScript engine feature Irregexp, explaining that the regexp performance has seen a considerable boost, because of the way the evolved memory management and native code generation manages regexps in JavaScript programs on the Internet.

“While the V8 team has been working hard to improve JavaScript performance, one part of the language that we have so far not given much attention is regexps. Our previous implementation was based on the widely used PCRE library developed by Philip Hazel at the University of Cambridge. The version we used, known as JSCRE, was adapted and improved by the WebKit project for use with JavaScript. Using JSCRE gave us a regular expression implementation that was compatible with industry standards and has served us well. However, as we've improved other parts of the language, regexps started to stand out as being slower than the rest,” explained Erik Corry, Christian Plesner Hansen and Lasse Reichstein Holst Nielsen, software engineers.

Moving onward with the V8 JavaScript engine, Google turned to its own infrastructure in the detriment of external libraries. The Mountain View-based search giant decided to allocate extra time to compiling a regular expression just to increase speed. In this regard, the company explained that regexp is converted into an intermediate automaton representation, in the initial steps of the compiling process.

“After optimization we generate native machine code which uses backtracking to try different alternatives,” the Chrome engineers explained. “Backtracking can be time-consuming so we use optimizations to avoid as much of it as we can. There are techniques to avoid backtracking altogether but the nature of regexps in JavaScript makes it difficult to apply them in our case, though it is something we may implement in the future.” Following the integration of the new implementation Google tested Chrome with the first 1 million webpages in order to ensure compatibility.

Google Chrome 2.0.160.0 is available for download here.