# 🛩 v8 Engine

3 min read, 540 words v8enginejavascriptcompilerruntime

v8 javascript engine logo

v8 is Javascript runtime in chrome and nodejs

~ Anonymous
  • Asynchronous IO is based in Event Loops
    • use libuv for that
  • 100k lines of JS and C++ code, glue between libuv and v8
    • inbuilt node modules, standard modules

v8 what?

called by many names

v8 Js Runtime js Engine compiler virtual machine

not in v8

  1. DOM data structure is NOT the responsibility of js engine. Its created by browser application
  2. No File System access. libuv is used for FSOperations
  3. console, responsibility of node or chrome app to provide it.
  • Majority of v8 team in Munich, Germany
  • Same release schedule as chrome, every 6 weeks
  • v8 API is a part of ECMA Script specification which is exposed to node or chrome
  • v8 compiler pipeline change - support for node 8
    • Full Cogent and crankshaft -> ignition and turbofan
    • ABI - Application Binary Interface guarentee to support node LTS version for stability
    • node v8 integration bot
  • since node 7 use devtools and CDP protocol for debugging
  • node is a first class citizen in v8 now

# 🗃 Heap vs Stack

the standard distinguishes automatic and dynamic storage duration. Local variables have automatic storage duration and compilers store them on the stack. Objects with dynamic memory allocation (created with new) are stored on the free store, conventionally referred to as the heap. In languages that are not garbage-collected, objects on the heap lead to memory leaks if they are not freed.

# Who uses it?

  • node
  • electron

# Official documentation

  • If you are a C++ developer you can use v8 in your Application
  • How javascript is used?
    • Manupulate DOM
    • v8 exposes all datatypes, operators, functions and objects as specified in ECMAScript standard
  • Uses Code Caching Technique
    • cached data is availble to seperate v8 instance as well
    • v8::ScriptCompiler::Source::GetCachedData
JIT Units Codenames
Garbage Collector Orinoco
Baseline Compiler Ignition
Optimization Compiler Turbo Fan

# 📉 Tracing

node --trace-events-enabled tracing.js
  • How to view, read trace?
    • Google chrome have built in trace viewer
    • chrome://tracing

Subscribe to our Newsletter

If you like my work and think it was helpful kindly support my work


Buy Me A Coffee