AI 摘要A recent V8 engineering effort made JSON.stringify more than twice as fast through a side-effect-free fast path that is iterative rather than recursive, templatized handling of one-byte and two-byte strings, SIMD and SWAR-accelerated character scanning, an 'express lane' that skips property checks for fast-json-iterable hidden classes, the Dragonbox algorithm replacing Grisu3 for number-to-string conversion, and a segmented output buffer that avoids costly reallocation and copying. The fast path applies only when serialization uses plain data objects with no replacer, space argument, custom toJSON methods, or indexed properties, and falls back to the general-purpose serializer otherwise. These optimizations are available starting with V8 13.8 (Chrome 138), and were validated on the JetStream2 json-stringify-inspector benchmark.
AI 摘要The article describes two optimizations recently implemented in V8 and shipped with Chrome M137: speculative call_indirect inlining and deoptimization (deopt) support for WebAssembly. By recording runtime call-target feedback to inline up to four likely targets and falling back to unoptimized code when assumptions are violated, the compiler can generate much better machine code, especially benefiting WasmGC programs. These optimizations yield more than 50% average speedup on Dart microbenchmarks and 1–8% improvements on larger, realistic applications, and deopts also lay the groundwork for future optimizations.
AI 摘要The article describes V8's new Explicit Compile Hints feature, which lets web developers mark JavaScript files or functions for eager compilation instead of lazy on-demand compilation, reducing page load bottlenecks. Experiments on popular web pages showed that 17 out of 20 improved, with an average reduction of 630 ms in foreground parse and compile times. Chrome 136 ships file-level eager compilation via the magic comment //# allFunctionsCalledOnLoad, with per-function hints planned for the future.
AI 摘要V8's optimizing compiler Turbofan, long known for using the Sea of Nodes intermediate representation, has over the past three years been migrated to Turboshaft, a more traditional control-flow-graph-based IR, which now covers the entire JavaScript backend and the whole WebAssembly pipeline. The article recounts how Turbofan was created in 2013 to replace Crankshaft, explains how Sea of Nodes differs from a CFG by letting operations float freely via value, control, and effect edges, and details why the V8 team concluded its downsides outweigh its benefits. Key problems include that Sea of Nodes graphs are hard to visually inspect and reason about, and that too many nodes end up tied to the effect chain or requiring control inputs, undermining the flexibility the IR was supposed to provide.
AI 摘要The V8 team optimized the JetStream2 async-fs benchmark, which was slowed by a custom Math.random implementation that stored its seed variable in a ScriptContext slot, causing costly HeapNumber allocations and slower floating-point arithmetic on every update. They introduced mutable heap number slots and Int32 type tracking for script context slots, allowing the seed to be updated in place with efficient integer instructions and deoptimizing only if the slot's type changes. These optimizations resulted in a ~2.5x speedup on the async-fs benchmark and a ~1.6% improvement in the overall JetStream2 score.
AI 摘要The JavaScript Promise Integration (JSPI) API enables WebAssembly applications written with synchronous assumptions to work smoothly with asynchronous Web APIs by intercepting Promises, suspending the WebAssembly code, and resuming it once the asynchronous operation completes. The article explains how JSPI works through wrapping imports and exports during module instantiation, notes its low constant-time overhead, and states that it is now standardized (phase 4) and available in Chrome 137 and Firefox 139. Practical examples using Emscripten demonstrate computing Fibonacci via Promises and lazily loading WebAssembly code on a function's first call.
AI 摘要WebAssembly's JavaScript Promise Integration (JSPI) has a redesigned API shipping in Chrome M126 that removes explicit Suspender objects and WebAssembly.Function in favor of simpler constructs (WebAssembly.promising and WebAssembly.Suspending), and now only suspends when a JavaScript function actually returns a Promise. Emscripten users on version 3.1.61 or later need no code changes, while the old API will be removed after Chrome M128 (October 2024). Future work includes growable stacks to support millions of suspended coroutines and advancing JSPI through the W3C Wasm CG standardization process, where it is currently at phase 3.
AI 摘要The V8 Sandbox, a lightweight in-process sandbox for V8, has matured from an experimental security feature to the point of being included in Chrome's Vulnerability Reward Program, with Chrome 123 effectively serving as its 'beta' release. The article explains that V8 vulnerabilities are typically subtle logic bugs rather than classic memory corruption issues, meaning existing solutions like memory-safe languages or hardware memory tagging are ineffective. The sandbox addresses this by isolating V8's heap memory and replacing raw pointers and sizes with sandbox-compatible alternatives (such as offsets and pointer table indirections), preventing memory corruption in V8 from spreading to the rest of the host process.
AI 摘要WebAssembly's JavaScript Promise Integration (JSPI) API is entering an origin trial with Chrome M123, allowing developers to test how sequential WebAssembly code can access asynchronous Web APIs by suspending when a Promise is returned and resuming when it is resolved. To participate, developers can set a Chrome flag or register for an origin trial token, and should use tools like Emscripten (version 3.1.47 or later) to generate the necessary code. While some API changes and known issues—such as performance costs for intensive wrapped calls and memory pressure from fixed-size stacks—exist, they are not expected to impede experimentation, and feedback can be submitted via the standards-track issue tracker.
AI 摘要The article describes V8's "static roots" feature, which hardcodes compile-time constant memory addresses for core JavaScript objects (like undefined and true) living in the read-only heap, enabling fast direct references instead of runtime lookups. This is achieved by deterministically generating the read-only heap layout through the mksnapshot build process and exploiting pointer compression by placing the heap at the start of the compression cage, with generated offsets cached in a static-roots.h header. The feature, which landed in Chrome 111, delivered performance gains across the VM—especially in C++ code and builtin functions—and enables further optimizations such as identifying object types via address range checks.