Multi-page · for JavaScript engineers
JavaScript internals

JavaScript internals

V8's two-tier JIT, the event loop in detail, generational garbage collection, hidden classes and inline caches, prototypes, promise internals, libuv, streams, module resolution, JIT deoptimisation. Ten mechanisms that decide how JavaScript programs actually behave at runtime.

10 sub-pages planned. Each is a long-form walkthrough with source links and references.


Deep dives

The mechanisms

Planned deep dives

Still in flight

Each will be a long-form sub-page with code, runtime / engine source links, and references.

  1. 04
    Hidden classes & inline caches
    How V8 represents objects internally, why constructor field order matters, and how property access is patched at runtime via inline caches.
    hidden class · transition tree · monomorphic IC · polymorphic IC · megamorphic
  2. 05
    Promise queue internals
    PromiseReactionJob, the microtask queue, host-defined queue draining rules. The exact order of resolution and why .then chains behave like they do.
    microtask queue · PromiseReactionJob · job · resolve · host hook
  3. 06
    libuv — Node event loop
    Phases, the thread pool, the polling step, signal handlers. Where Node's I/O concurrency actually comes from.
    phases · thread pool · pollio · check phase · epoll
  4. 07
    Streams & backpressure
    Web Streams (WHATWG) vs Node streams. How backpressure propagates, why pipe is correct and pipeline is canonical.
    ReadableStream · WritableStream · backpressure · pipe · pipeline
  5. 08
    Module resolution
    Node require algorithm, ESM resolution, the exports map, dual-package hazards. Where bundlers diverge from the runtime.
    require algorithm · exports map · conditional exports · dual-package · subpath
  6. 09
    Prototypes — the object model
    Object [[Prototype]] vs Object.prototype, the [[Get]] / [[Set]] internal slots, class as sugar. Why monkey-patching is dangerous and predictable shapes are fast.
    [[Prototype]] · [[Get]] · [[Set]] · class · inheritance
  7. 10
    JIT deoptimisation
    What makes V8 bail out — type feedback violations, unsupported operations, megamorphic call sites. How to read --trace-deopt and avoid the common traps.
    deopt · type feedback · %TraceOpt · megamorphism · eager deopt