<medium>It is portable and runs on:<medium>
Windows 7 or later
Linux systems using x64, IA-32, MIPS and ARM processor
SpiderMonkey - Firefox
Chakra JS - Microsoft Edge
Prehistory: let's start the engine!
This open-source JS engine came into being with the Chromium Project for Google Chrome and more Chromium browsers. Lars Bak, a danish programmer, was a project's creator and he's the one who led the V8 team. This man is a true virtual machine expert and guru of object-oriented design. By the way, Lars Bak spent 30 years developing programming languages. Once upon a time, he implemented a runtime system for BETA. Since then, Mr. Bak has left marks on a dramatic list of different software systems and finally get to the V8. How it was?
Supported and financed by Google, V8 engine powers today a huge amount of server-side JS code.
P.S.: After V8 Lars Bak has already realized Dart and Toit and received the Dahl-Nygaard prize in 2018. Well, that track record sounds impressive!
What goes on under the hood
It is іnteresting that V8's subprocesses are named in accordance with automotive details. That is not only a stylish brand idea. It's also a good way for users to gain insight into JS engine behavior.
In basic terms, the JS engine:
Taking your source code
The parser is generating an abstract syntax tree from the source
V8's interpreter is generating a bytecode from the syntax tree that a compiler can understand
V8's compiler is generating a graph from bytecode (replacing bytecode sections with optimized machine code)
And, ta-dah – executing!
And what is making code runs so fast? Let's consider some interesting V8 characteristics.
Interpreted or compiled?
JS is usually perceived as an interpreted language, but its modern engines are much more than just interpreters in order to get a more performant execution. The basis of the V8 that allows a high-speed JS execution is the JIT (Just-In-Time) compiler optimizing code during runtime (not Ahead-Of-Time). It combines the best features of interpreters and compilers, mixing these steps and making translation and execution faster.
The first optimizing compiler of V8 was "FullCodegen". The newest and more advanced is "Turbofan". Its backend is used by the V8's low-level register-based interpreter called 'Ignition'. This combined Ignition+TurboFan pipeline was launched in 2017.
In 2018 was released Liftoff, WebAssembly's (Wasm) first-tier compiler in V8 for a fast startup of complex websites with big Wasm modules, for example, Google Earth.
Keep calm and maintain cleanliness
Over the past years, V8's developers worked on the garbage collection process improvement a lot. Finally, they implemented a 2 generation-based garbage collector (also known as a full GC) called "Orinoco". It applies the latest effective techniques to free the thread. Collector finds objects and data that are no longer referenced and collects them. This contributes to well-improved latency and page load, smoother animation, scrolling, and user interaction.
In 2018, the Chromium team started a project called V8 Lite. The main aim was a forcefully reduce memory usage.
Originally, it was intended as a Lite mode for low-memory devices or embedded use cases. But soon developers decided to fully implement optimization bonuses in the regular V8, advancing all vee-eight usage areas. You can consult technical details of memory savings and improved execution speed without wizardry in V8's official blog.
Vroom vroom: drive on!
There is a short list of presented developer-facing goodies:
40% less memory use due to pointer compression
faster higher-order builtins
All roads lead to chrome
All those v.8.0 highlights are especially enjoyable in anticipation of the new Chrome release. Chrome 80 Stable will be released on February 4th, 2020, as reported by Chromium. So let's check bug fixes and performance improvements and<medium>drive on with V8 JS in 2020!<medium>
Freshcode team keeps up V8-driven solutions to power up our customers' projects. So don't hesitate to contact us if you have any questions or need for consultation.