Hacking Tips

These tips were archived from MDN: This may be out of date!

This is archived here because it captures valuable documentation that even if potentially out of date, provides inspiration.


This page lists a few tips to help you investigate issues related to SpiderMonkey. All tips listed here are dealing with the JavaScript shell obtained at the end of the build documentation of SpiderMonkey. It is separated in 2 parts, one section related to debugging and another section related to drafting optimizations. Many of these tips only apply to debug builds of the JS shell; they will not function in a release build.

Tools

Here are some debugging tools above and beyond your standard debugger that might help you:

  • rr is a record-and-replay deterministic debugger for Linux

  • Pernosco takes an rr recording and adds omniscient debugging tools to help you

    • It is a paid service with a free trial

    • Mozilla has a license for internal developers; you can contact Matthew Gaudet mgaudet@mozilla.com for details

Debugging Tips

Getting help (from JS shell)

Use the help function to get the list of all primitive functions of the shell with their description. Note that some functions have been moved under an ‘os’ object, and help(os) will give brief help on just the members of that “namespace”.

You can also use help(/Regex/) to get help for members of the global namespace that match the given regular expression.

Getting the bytecode of a function (from JS shell)

The shell has a small function named dis to dump the bytecode of a function with its source notes. Without arguments, it will dump the bytecode of its caller.

js> function f () {
  return 1;
}
js> dis