Function mozjs_sys::jsapi::JS_GlobalObjectTraceHook

source ยท
pub unsafe extern "C" fn JS_GlobalObjectTraceHook(
    trc: *mut JSTracer,
    global: *mut JSObject,
)
Expand description

Spidermonkey does not have a good way of keeping track of what compartments should be marked on their own. We can mark the roots unconditionally, but marking GC things only relevant in live compartments is hard. To mitigate this, we create a static trace hook, installed on each global object, from which we can be sure the compartment is relevant, and mark it.

It is still possible to specify custom trace hooks for global object classes. They can be provided via the RealmOptions passed to JS_NewGlobalObject.