Deep Dive into JavaScript and V8 Engine 9.0

JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997.

“The best thing about JavaScript is its implementation of functions. It got almost everything right. But, as you should expect with JavaScript, it didn’t get everything right.” Douglas Crockford, JavaScript: The Good Parts: The Good Parts

What is JavaScript Engine ?

A JavaScript engine is a computer program or an interpreter that executes JavaScript code. It can be written in a number of different languages. A JavaScript engine can be implemented as a standard interpreter, or just-in-time compiler that compiles JavaScript to bytecode in some form. The first JavaScript engines were almost only interpreters, but most modern engines employ just-in-time (JIT) compilation for upgraded performance.

Every popular browser has its own JavaScript engine implementation.
Here are some well-known JavaScript engines.

Chrome’s V8 engine

Firefox’s SpiderMonkey

Safari’s JavaScriptCore (a.k.a Nitro, SquirrelFish and SquirrelFish Extreme)

Edge’s Chakra — but Edge has recently embraced Chromium‘s V8 engine

However with the release of NodeJs in 2011 we now can use the V8 engine outside of the web browsers and directly on our machines.

If you’ve ever wondered how your JavaScript is processed, here’s a simplified flow diagram to help you out.

Why Chrome’s V8 engine is special?

V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. Chrome V8, or just V8, can execute JavaScript code either within or outside of a browser, which makes server-side scripting possible.

Chrome V8 is fast and powerful, much like a V8 (eight-cylinder) car engine.
V8 translates JavaScript code directly into machine code, allowing computers to understand it, and then executes the translated, or compiled, code.V8 also optimizes JavaScript execution.

Furthermore, V8 can run standalone, or can be embedded into any C++ application. And it supports windows 7 or later, macOS 10.12 or later, and Linux systems with x64, IA-32, ARM, or MIPS processors.

Newly introduced V8 v9.0

Every six weeks, V8 engine developers create a new branch of V8 as part of their release process. Each version is branched from V8’s Git master immediately before a Chrome Beta milestone. V8 version 9.0 is in beta until its release in coordination with Chrome 90 Stable in several weeks.

The 9.0 release of the V8 JavaScript engine, improves the performance of making WebAssembly calls from JavaScript, adds regular expression match indices, and speeds up super property access.

The wrapper call can now get inlined at the call site to minimize the performance overhead of the JavaScript to WebAssembly wrapper. Using this experimental --turbo-inline-js-wasm-calls flag, performance benchmarks show typical calls completing within approximately one-third of the time without the inline wrapper.

Accessing super properties has been optimized by using V8’s inline cache system and optimized code generation in TurboFan. super property access is now closer to being on par with regular property access. And also, starting in v9.0, developers may opt into getting an array of the start and end positions of matched capture groups in regular expression matches.

Additional information about the latest version of the JavaScript engine Can be found in the post on the V8 blog.

Hi ! I am Sanda. I am a Software Engineering undergraduate from Colombo.