And what is making code runs so fast? Let's consider some interesting V8's characteristics.
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 executing 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, Chromium team started a project called V8 Lite. The main aim was a forcefully reducing memory usage.