The engine was initially designed solely for execution by web browsers, but the latest versions also execute JS code outside of the browser (i.e.., server-side), enabling server-side scripting (Nodejs).
Just in Time compilation is implemented is other JS engines such as Spider Monkey or Rhino etc. But the main difference is V8 doesn’t produce any intermediate code saving time.
Key components of V8:
The V8 JS engine has an interpreter named “Ignition”. This interpreter is used for interpreting and executing low-level bytecode.
Liftoff is a web assembly that generates machine code and performs its tasks in a highly optimized manner. It was introduced in the latest version of V8 for WebAssembly-based apps and modern browsers
TurboFan is a powerful compiler with a graph-based intermediate representation (IR) suitable for advanced optimizations (strength reduction, inlining, code motion, instruction combining, and sophisticated register allocation).
Orinoco is for garbage collection. Its job is to look for disconnected memory allocations and perform evacuation and compaction to free up space for more objects.
V8 parses our source code and generates an abstract syntax tree. After that, Ignition (the V8 interpreter) generates bytecode from this syntax tree so that the compiler will understand. V8 consists of an optimized compiler that converts bytecode to machine code. The next process is the execution of the code and handling garbage collection.
Applications of V8:
- Chromium-based web browsers, Google Chrome
- Node.js runtime environment
- NativeScript mobile application framework
- Electron desktop application framework, used by the Atom and Visual Studio Code text editors