The web browser are the main part of internet world. When ever we type a URL in the address bar, it fetch resources from remote server, and display them on the screen, through this time it mainly undergoes 3 process
At first it fetching data from subsequent web servers via the internet.
Render engine, will process the received resourses. After that the
Browser Engine will performs data presentation.
so how all this happen...?
The Html Parser will fetch all scripts loaded via
<script>tag. The source code inside this script gets loaded as a UTF-16 byte stream to a byte stream decoder. This byte stream decoder then decodes the bytes into token and then its sent to parser.
AST(Abstract Syntax Tree)
The parser creates nodes based on the tokens it gets. With these nodes, it creates an Abstract Syntax Tree (AST).
The interpreter walks through the AST and generates byte code. It reads the code line by line. When the byte code has been generated, the AST is deleted for clearing up memory space.
The Profiler monitors and watches code to optimize it.
The compiler works ahead of time and creates a translation of the code that has been written and compiles down to a lower level language that machines can read.
- V8 — open source, developed by Google, written in C++
- Rhino — managed by the Mozilla Foundation, open source, developed entirely in Java
- KJS — KDE’s engine originally developed by Harri Porten for the KDE project’s Konqueror web browser
- Chakra (JScript9) — Internet Explorer
- Nashorn, open source as part of OpenJDK, written by Oracle Java Languages and Tool Group
- JerryScript — is a lightweight engine for the Internet of Things.
Lets check v8's 2 main pipelines behind its performance
Ignition interpreter and the compiler
Turbofan little bit more
- reducing memory usage
- reducing startup time
- reducing complexity
The TurboFan pipeline follows some steps to translate bytecode into machine code. Optimizations in the pipeline are performed based on feedback collected by Ignition.
TurboFan’s online, JIT-style compilations and optimizations concludes V8’s translation from source code to machine code.