SpiderMonkey Newsletter (Firefox 106-107)

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 106 and 107 Nightly release cycles.

👷🏽‍♀️ New features

  • We’ve implemented support for module import.meta.resolve (disabled by default).
  • We’re working on implementing more Wasm GC instructions (disabled by default).

⚙️ Modernizing JS modules

We’re working on improving our implementation of modules. This includes supporting modules in Workers, adding support for Import Maps, and ESMification (replacing the JSM module system for Firefox internal JS code with standard ECMAScript modules).

  • See the AreWeESMifiedYet website for the status of ESMification.

💾 Robust Caching

We’re working on better (in-memory) caching of JS scripts based on the new Stencil format. This will let us integrate better with other resource caches used in Gecko and might also allow us to potentially cache JIT-related hints.

The team is currently working on removing the dependency on JSContext for off-thread parsing. This will make it easier to integrate with browser background threads and will further simplify the JS engine.

  • We’re refactoring exception handling in the frontend to be less dependent on JSContext.
  • We’ve simplified the Stencil APIs for off-thread parsing.

🚀 Performance

  • We’ve added a separate GC Zone for shared permanent things. This allowed us to make some fields non-atomic.
  • We optimized the megamorphic cache by inlining certain cache lookups in JIT code.
  • We fixed a performance cliff in the frontend with concurrent delazification enabled.
  • We fixed scalar replacement of ‘call objects’ to work again.
  • We improved performance of lexical environment objects.
  • We improved bytecode generated for certain post-increment/decrement operations.
  • We implemented JIT inlining of String.prototype.toLowerCase based on a lookup table.
  • We simplified and optimized the object slots (re)allocation code.
  • We added a fast path for megamorphic property set/add for plain objects.
  • We optimized code in the JITs for adding new dense elements to objects.

📚 Miscellaneous

  • We changed GC allocations to avoid undefined behavior.
  • We added an API for the Firefox profiler to access JIT code.
  • We cleaned up Wasm GC objects.
  • We added more documentation for the register allocator.
  • We updated irregexp to the latest version.
  • We updated wast to the latest version.
  • We cleaned up a lot of code in the frontend.