This is an archived page. It's not actively maintained.


JSAPI 38 で廃止

この記事は SpiderMonkey 1.8 の新機能について書かれています。

DEBUG のみ。ヒープに割り当てられたもののオブジェクトグラフをダンプします。


JS_DumpHeap(JSRuntime *rt, FILE *fp, void* startThing, JSGCTraceKind kind,
            void *thingToFind, size_t maxDepth, void *thingToIgnore);
Name Type Description
cx JSContext * Pointer to a JS context. Every JSContext is permanently associated with a JSRuntime; each JSRuntime contains a GC heap.
fp FILE * File for the dump output.
startThing void * NULL or a pointer to a GC thing (use JS::Value::toGCThing() to obtain a pointer to pass here). When null, dump all things reachable from the runtime roots. When non-null, dump only things reachable from the object indicated.
startKind JSGCTraceKind Trace kind of startThing, if startThing is not null. Must be JSTRACE_OBJECT when startThing is null.
thingToFind void * NULL or a pointer to a GC thing. If this is non-null, JS_DumpHeap only dumps paths in the object graph leading to the specified thing.
maxDepth size_t The upper bound on the number of edges to descend from the graph roots.
thingToIgnore void * NULL or a pointer to a GC thing that will be ignored during graph traversal.
enum JSGCTraceKind
    // These trace kinds have a publicly exposed, although opaque, C++ type.
    // Note: The order here is determined by our Value packing. Other users
    //       should sort alphabetically, for consistency.
    JSTRACE_OBJECT = 0x00,
    JSTRACE_STRING = 0x01,
    JSTRACE_SYMBOL = 0x02,
    JSTRACE_SCRIPT = 0x03,

    // Shape details are exposed through JS_TraceShapeCycleCollectorChildren.
    JSTRACE_SHAPE = 0x04,

    // The kind associated with a nullptr.
    JSTRACE_NULL = 0x06,

    // A kind that indicates the real kind should be looked up in the arena.

    // The following kinds do not have an exposed C++ idiom.



See バグ 378261 for detail.

When tracing a thing, the GC needs to know about the layout of the object it is looking at. There are a fixed number of different layouts that the GC knows about. The "trace kind" is a static map which tells which layout a GC thing has.

Although this map is public, the details are completely hidden. Not all of the matching C++ types are exposed, and those that are, are opaque.

See JS::Value::gcKind() and JSTraceCallback in <codde>Tracer.h</codde> for more details.

See Also