We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS


This article covers features introduced in SpiderMonkey 1.8

Note: in JSAPI 12, the macro JS_TRACER_INIT has been replaced by the function JS_TracerInit

Initialize a JSTracer for object graph tracing.


JS_TracerInit(trc, cx, callback)
Name Type Description
trc JSTracer * The tracer to be initialized.
cx JSContext * The context in which to perform tracing.
callback JSTraceCallback A callback, described below, which the tracing APIs will call each time a pointer is found from one GC thing to another.

Callback syntax

typedef void (*JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
Name Type Description
trc JSTracer * The tracer visiting obj.
thing void * A GC thing.
kind uint32 One of the constants JSTRACE_OBJECT, JSTRACE_DOUBLE, JSTRACE_STRING; or a tag denoting an internal implementation-specific traversal kind. In the latter case, the only operations the callback may perform on thing are to call JS_TraceChildren or the DEBUG-only JS_PrintTraceThingInfo function.


JS_TraceChildren and other tracing APIs call the tracer callback for each traceable thing directly referenced by a particular object or runtime structure. It is the callback's responsibility to ensure the traversal of the full object graph, if desired, by eventually calling JS_TraceChildren on the passed thing. In this case the callback must be prepared to deal with cycles in the traversal graph.

MXR ID Search for JS_TracerInit

Document Tags and Contributors

Last updated by: tschneidereit,