SpiderMonkey Newsletter (Firefox 98-99)

SpiderMonkey is the JavaScript engine used in Mozilla Firefox. This newsletter gives an overview of the JavaScript and WebAssembly work we’ve done as part of the Firefox 98 and 99 Nightly release cycles.

👷🏽‍♀️ JS features

⚡ WASM features

  • We landed more changes adding support for AVX2 instructions.
  • Relaxed SIMD is now enabled by default in Firefox Nightly builds.

❇️ Stencil

Stencil is our project to create an explicit interface between the frontend (parser, bytecode emitter) and the rest of the VM, decoupling those components. This lets us improve web-browsing performance, simplify a lot of code and improve bytecode caching.

  • We landed more changes to simplify and optimize the JS string and atom code after we completed the switch to Stencil.
  • We added a mechanism to allow delazifying functions off-thread based on the Stencil.

🚿DOM Streams

We’re moving our implementation of the Streams specification out of SpiderMonkey into the DOM. This lets us take advantage of Gecko’s WebIDL machinery, making it much easier for us to implement this complex specification in a standards-compliant way and stay up-to-date.

  • We’ve switched Firefox to use the DOM implementation of ReadableStream.
  • We’ve removed the incomplete implementation of WritableStream and pipeTo in SpiderMonkey, because we’ll implement these features outside the JS engine too.

🚀 JIT optimizations

  • Contributors from Loongson landed a new JIT/Wasm backend for LoongArch64.
  • We added a new property caching mechanism to optimize megamorphic property lookups from JIT code better. This improves performance for frameworks like React.
  • We improved CacheIR optimization support for null/undefined/bool values for unary and binary arithmetic operators.
  • We reimplemented Array.prototype.indexOf (and lastIndexOf, includes) in C++.

🏎️ Performance

  • We optimized the representation of Wasm exceptions and Wasm tag objects.
  • We reverted a number of Wasm call_indirect changes after we discovered various problems with it and then landed a simpler optimization for it.
  • We improved heuristics for nursery collection to shrink the nursery if collections take a long time.
  • We removed more unnecessary checks for permanent atoms from the string marking code.
  • We now trigger major GCs during idle time if we are nearing a memory usage threshold, to avoid forcing a later GC at a bad time when we hit the actual threshold.
  • We optimized certain Firefox DevTools operations with a new debugger API.

📚 Miscellaneous

  • We fixed a memory leak involving FinalizationRegistry that affected certain websites.
  • We improved the rooting hazard static analysis to avoid a class of false positives involving reference counted values.
  • We switched the atomic operation intrinsics to inline assembly. This allowed us to add a mechanism to disable the JIT backend completely in certain Firefox processes, which let us improve the sandbox.