days
-6
-3
hours
-1
-7
minutes
-2
-8
seconds
-1
-3
search
3, 2, 1, Liftoff!

Liftoff: Speedy new compiler for the V8 JavaScript engine

Sarah Schlothauer
javascript
© Shutterstock / Alones

The V8 JavaScript engine has a new baseline compiler. The new compilation pipeline is Liftoff, and it has some seriously fast results.

Are you ready for high-performance? It’s time to Liftoff.

Liftoff is a new baseline compiler for WebAssembly and comes default on the desktop system of the V8 JavaScript Engine.

Since its release, WebAssembly has been making waves. Wasm is a “binary instruction format for a stack-based virtual machine…designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications”.

First of all, what does V8 do for WebAssembly? V8 is an open source JavaScript engine created by Google and written in C++. It allows for WebAssembly to run fast and meet high-performance goals. Ahead of time,  code is compiled in V8, so high performance goals can be reached.

From it’s GitHub about page: “V8 implements ECMAScript as specified in ECMA-262, 5th edition, and runs on Windows (XP or newer), Mac OS X (10.5 or newer), and Linux systems that use IA-32, x64, or ARM processors.

SEE ALSO: Life: WebAssembly on your smart fridge? This new VM written in Go makes it possible

V8 compiles and executes JavaScript source code, handles memory allocation for objects, and garbage collects objects it no longer needs. V8’s stop-the-world, generational, accurate garbage collector is one of the keys to V8’s performance.” Now with Liftoff, V8 has a whole new kind of power.

Take a look at Liftoff

How does Liftoff improve an already sleek engine? The new compilation pipeline reduces startup time for apps written in WebAssembly.

Speed is the name of the game. There are only two stages to Liftoff: Function body decoder and code generation.

The release blog explains these two steps:

“…the function body decoder does a single pass over the raw WebAssembly bytes and interacts with the subsequent stage via callbacks, so code generation is performed while decoding and validating the function body. Together with WebAssembly’s streaming APIs, this allows V8 to compile WebAssembly code to machine code while downloading over the network.”

Liftoff’s single pass over the opcodes of a function is what allows to maintain such high speed. For more information on how a function is handled, check out the sample on the release blog.

High performance

With Liftoff, you can see a performance increase of up to 10x (or more).

SEE ALSO: Top 5 JavaScript IDEs

It isn’t just for high-end machines either. V8 tested Liftoff’s speed on both a MacBook and a Z840. It ran up against V8’s old engine: TurboFan. The results were crystal clear. In both cases, Liftoff compiled code faster by a wide margin.

javascript

Source: V8project.blogspot.com

What does the future hold?

The release blog lists some future plans for Liftoff that developers can look forward to seeing.

  • Improved startup times and reduced memory usage
  • Porting Liftoff to mobile devices
  • Improved code generation performance
  • Dynamic tier-up for mobile devices

As of right now, Liftoff is only usable on desktop. However, once it is ported to mobile devices, it will reach a broader audience of developers.

Interesting in contributing to V8’s success? Learn more on GitHub and be sure to join the mailing list so you don’t miss out on new features and future improvements.

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University in Long Branch, New Jersey and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.