Labs/Jetpack/Binary Components
nsJetpack
nsJetpack is a binary component used to provide services to Jetpack that aren't otherwise available to scripted chrome code in the Mozilla platform.
Accessing the Component
Because the goal of nsJetpack is to provide functionality to scripted code, and because much of its functionality is concerned with providing access to SpiderMonkey internals, the XPCOM interface for the component is rather trivial. To obtain the component, simply do:
var nsJetpack = Cc["@labs.mozilla.com/jetpackdi;1"]
.createInstance(Ci.nsIJetpack).get();
This will give you the nsJetpack native JavaScript object, which provides access to all the component's functionality.
Flexible Membrane Functionality
nsJetpack contains functionality that exposes many SpiderMonkey C API calls to JavaScript, allowing chrome code to create custom wrappers (aka membranes) that allow trusted and untrusted code to interoperate.
The source code for this functionality is in wrapper.cpp.
wrap()
unwrap()
getWrapper()
Memory Profiling
nsJetpack contains functionality allowing chrome code to examine the JavaScript heap. The semantics of this are described at a high level in Atul's blog post entitled Fun with SpiderMonkey.
The source code for this functionality is in memory_profiler.cpp.
profileMemory()
Miscellaneous Functions
The source code for this functionality is in tcb.cpp.