15 parts · 98 chapters
JavaScript, the Engine and the Language
JavaScript is a dynamic language that runs fast because the engine guesses what your code will do and compiles for the guess. Every performance rule of thumb you have heard is a statement about when that guess holds, and this module is the machinery behind the guess, drawn piece by piece.
The engine first: what V8 does with source text, how it represents your objects, when it optimises and when it gives up, how it manages memory. Then the language as the engine sees it: prototypes, closures, iterators, promises, modules and collections, each tied to the structure underneath. Then patterns as mechanisms, and how to measure without lying to yourself.
the pipelineScanner, parser, Ignition, Sparkplug, Maglev, TurboFan: what each tier produces and when it runs.
shapesHidden classes, transitions, inline caches, and why the order you add properties decides your speed.
speculationType feedback, optimisation, the deoptimisation triggers, and reading --trace-deopt.
memoryThe young and old generations, the scavenger and the marker, write barriers, and what a leak looks like.
valuesSmis, heap numbers, cons strings, ropes, flattening: why "a" + b is cheap until it is not.
the languagePrototypes, closures, this, iterators, generators, await desugared, module linking, weak references.
patternsEach classic pattern tied to the engine feature it exploits and the moment it becomes the wrong tool.
measurementBenchmarks that survive the optimiser, flame charts, allocation profiles, and the hot-path checklist.
00
What Runs Your Code
What JavaScript is, and what it is not · What an engine has to do, and why it is hard · The V8 pipeline at ten thousand feet · Tiering: one function's life · Where startup time goes · Isolates, contexts and heaps · The host's loop and the engine's queue · The tools: d8, node flags, and natives syntax · The map of this course
9 ch · ~45 min01Parsing
From bytes to tokens: the scanner · Lazy parsing: the pre-parser and the double-scan tax · The parser: recursive descent, and what the AST holds · Scope analysis: registers or context · Startup cost: measuring and reducing it · Function size, placement, and the parser · Reading the parser: flags and traces
7 ch · ~45 min02Ignition
Why bytecode, and what kind · Reading --print-bytecode · Feedback vectors: what the interpreter learns · Dispatch, and the cost of interpretation · Contexts and closures in bytecode · Bytecode for the constructs people ask about · Reading Ignition: tools
7 ch · ~45 min03Hidden Classes And Inline Caches
Why objects need a shape · Transitions: the tree, slack tracking, and dictionary mode · Object layout: in-object, properties array, elements · Arrays and elements kinds · Inline caches: mono, poly, mega, in machine code · The rules, derived · Reading maps and ICs: tools
7 ch · ~50 min04Optimisation
Speculation: the idea that makes dynamic languages fast · The three compilers · On-stack replacement · Deoptimisation: reading the trace · Every deopt reason you will meet, and its fix · What the optimiser can and cannot do · Reading the optimiser: tools
7 ch · ~55 min05Memory And GC
The generational heap · Major GC: marking, sweeping, compacting, concurrently · Write barriers and the cost of mutation · Reading a heap snapshot · Allocation: what it costs and what the compiler removes · Leaks: shapes, detection, fixes · Limits, tuning, and out of memory · Reading memory: tools
8 ch · ~55 min06Values
Tagged values: Smis and pointers · Numbers in optimised code: unboxed, boxed, converted · Strings: five shapes behind one interface · String operations and their costs · Symbols, BigInt, and the oddballs · Reading values: tools
6 ch · ~45 min07Objects And Prototypes
The prototype chain as the engine walks it · Property kinds: fields, constants, accessors, attributes · Classes, as the engine sees them · Proxy and Reflect: the metaobject protocol and its price · Object creation patterns compared · Reading objects: tools
6 ch · ~45 min08Functions And Closures
A function object, and what it costs to make one · Scope, contexts, and the sharing rule · this: five bindings and one non-binding · Calls: frames, arity, arguments, rest, spread · Function kinds and what they cost · Reading functions: tools
6 ch · ~45 min09Iteration And Generators
The iterator protocol, and what for...of really does · Generators: a frame that pauses · Async iteration · Iteration forms compared · Reading iteration: tools
5 ch · ~40 min10Async Internals
A promise is a small object with a list · await, desugared · Microtask ordering, exactly · Async stack traces and the cost of keeping them · Unhandled rejections, cancellation, and the patterns that break · Reading async: tools
6 ch · ~45 min11Modules
Three phases: construct, link, evaluate · Live bindings and cycles · Top-level await and async module evaluation · Resolution: what the host does with a specifier · CommonJS, the bridge, and bundlers · Reading modules: tools
6 ch · ~40 min12Collections And Typed Arrays
Map and Set: an ordered hash table · WeakMap, WeakRef, FinalizationRegistry · ArrayBuffer, typed arrays, DataView · Arrays as collections: what to use when · Reading collections: tools
5 ch · ~40 min13Design Patterns, Mechanism First
Patterns as mechanisms · Module, factory, and the shape they produce · Observer, pub/sub, emitters · Strategy, command, state machine · Memoisation and caching · Proxy-based reactivity, builders, and async patterns
6 ch · ~45 min14Performance In Practice
Benchmarking without being fooled · Reading a CPU profile · Allocation profiles and GC time · The hot-path checklist · A hot path, fixed in order · Production observation · The course, in one page
7 ch · ~45 minRun everythingEvery chapter ends with a command: node with a --trace flag, d8 with natives syntax, or a snippet for the DevTools console. The claims are checkable on the machine you are reading this on; check them.