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 80 and 81 Nightly release cycles. If you like these newsletters, you may also enjoy Yulia’s Compiler Compiler live stream.

With the recent changes at Mozilla, some may be worried about what this means for SpiderMonkey. The team continues to remain strong, supported and is excited to show off a lot of cool things this year and into the future.

JavaScript

👷🏽‍♀️ New features

Firefox 80
  • Ted added support for the export * as ns from “module” syntax in modules proposal.
In progress

🗑️ Garbage Collection

  • Jon moved more decommit code to the background thread.
  • Jon added prefs and improved heuristics for the number of helper threads doing GC work.
  • Yoshi added GC sub-categories to the profiler.
  • Paul removed some unused GC telemetry code to improve memory usage.
  • Jon enabled compacting for ObjectGroups.
  • Yoshi fixed shutdown GCs to not start compression tasks.

❇️ 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 performance, simplify a lot of code and improve bytecode caching. It also makes it possible to rewrite our frontend in Rust (see SmooshMonkey item below).

We expect to switch the frontend to use ParserAtoms in the next Nightly cycle (Firefox 82). At that point the frontend will work without doing any GC allocations and will be more independent from the rest of the engine, unblocking further (performance) improvements.

  • Arai decoupled Stencil structures more from the frontend data structures.
  • Ted made module parsing work with Stencils and without allocating GC things.
  • Ted deferred GC allocation of ScriptSourceObject.
  • Ted cleaned up scope/environment handling.
  • Arai added a dumpStencil(code) function to the JS shell to print the Stencil data structures.
  • Kannan landed more changes preparing for the switch to ParserAtom.

🐒 SmooshMonkey

SmooshMonkey is our project to reimplement the frontend in a safe language (Rust) and will make it easier to implement new features and improve long-term maintainability of the code base.

  • Arai hooked up the output of the Rust frontend to Stencil’s function data structures.

🚀 WarpBuilder

WarpBuilder is the JIT project to replace the frontend of our optimizing JIT (IonBuilder) and the engine’s Type Inference mechanism with a new MIR builder based on compiling CacheIR to MIR. WarpBuilder will let us improve security, performance, memory usage and maintainability of the whole engine. Since the previous newsletter we’ve ported a lot of optimizations to CacheIR and Warp.

🧹 Miscellaneous changes

  • Tom fixed syntax errors in regular expressions to use the correct source location.
  • Jan added a cache for atomizing strings to fix a performance cliff affecting Reddit.
  • Yoshi landed more changes for integrating SpiderMonkey’s helper threads with the browser’s thread pool.
  • Philip Chimento added public APIs for working with BigInts.
  • Evan Welsh added a public API for enabling code coverage.
  • Kanishk fixed an over-recursion bug in ExtractLinearSum.
  • Logan cleaned up Debugger frames code.
  • Jan optimized and cleaned up some jump relocation and jump code on x64 and ARM64.
  • Tom removed some CallNonGenericMethod calls for Number and Date functions. This improved certain error messages.
  • André converted code from ValueToId to ToPropertyKey to fix subtle correctness bugs.
  • Jeff moved more code out of jsfriendapi.h into smaller headers.
  • Barun renamed gc::AbortReason to GCAbortReason to fix a conflict with jit::AbortReason.
  • Steve added an option to the shortestPaths test function to find out why a given JS value is alive.
  • Steve enabled the JS gdb prettyprinters for the firefox binary as well as making them independent from the working directory.

WebAssembly

  • The Cranelift team landed various changes to prepare for enabling Cranelift by default for ARM64 platforms in Nightly. On ARM64 we currently only have the Wasm Baseline compiler so it’s the first platform where Cranelift will be rolled out.
  • Ryan implemented non-nullable references.
  • Lars landed optimizations for SIMD and implemented some experimental Wasm SIMD opcodes.
  • Lars added alignment of loop headers to the Ion backend.