JavaScript Execution: Parsing, the Event Loop, JIT and GC
Four things every engineer 'knows' about JavaScript, and what V8 15.4 actually does. An inline cache does not go megamorphic at four shapes: the ceiling is TEN, and because the guard is evaluated before the new map is recorded, the tenth shape still fits and the eleventh is the one refused — and even then the call site does not jump straight to megamorphic, since IC::SetCache tries the MegaDOM and homomorphic paths before giving up. Lazy parsing does not skip function bodies: on a first read the PreParser walks every token of the body and omits only the AST, so code the first screen never calls is cheaper than eager code but is not free — the bytes are still scanned, and the full parse arrives on first call. A long task is not descheduled and resumed: V8's interrupts are cooperative, handled only at checkpoints the running code itself arrives at, and the interrupt list contains nothing resembling 'the scheduler wants the thread back' — so a 500 ms loop runs to its end and every click, keypress and frame queues behind it. The W3C's 50 ms long-task threshold is a spec definition, not an engine constant; nothing in the engine enforces it. And a FinalizationRegistry callback is a posted task with at most one outstanding, not a destructor — cleanup is neither prompt, nor ordered against your code, nor guaranteed to run before the page goes away. Change the script size, long-task length, live heap, bundling strategy, async operations, third-party scripts and call-site shape count, and watch the server-computed cascade across all five layers — parsing and compilation, the event loop, main-thread blocking, optimization tiers and memory — including the conjunctions where two settings that are each survivable alone are not survivable together. Validated against V8 15.4.80.11 and Chromium 154.0.8037.57 source (SkipFunction, PreParser::PreParseFunction, IC::SetCache, ShouldPerformCheckpoint, Heap::PerformGarbageCollection, PostFinalizationRegistryCleanupTaskIfNeeded).
- All current + future modules
- Full kata library
- Progress dashboard + weak area analysis
Cancel anytime. Billed annually.