Beispiel #1
0
void
JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtSizes)
{
    rtSizes->object = mallocSizeOf(this);

    rtSizes->atomsTable = atoms.sizeOfExcludingThis(mallocSizeOf);

    rtSizes->contexts = 0;
    for (ContextIter acx(this); !acx.done(); acx.next())
        rtSizes->contexts += acx->sizeOfIncludingThis(mallocSizeOf);

    rtSizes->dtoa = mallocSizeOf(dtoaState);

    rtSizes->temporary = tempLifoAlloc.sizeOfExcludingThis(mallocSizeOf);

    if (execAlloc_) {
        execAlloc_->sizeOfCode(&rtSizes->jaegerCode, &rtSizes->ionCode, &rtSizes->regexpCode,
                               &rtSizes->unusedCode);
    } else {
        rtSizes->jaegerCode = 0;
        rtSizes->ionCode    = 0;
        rtSizes->regexpCode = 0;
        rtSizes->unusedCode = 0;
    }

    rtSizes->stack = stackSpace.sizeOf();

    rtSizes->gcMarker = gcMarker.sizeOfExcludingThis(mallocSizeOf);

    rtSizes->mathCache = mathCache_ ? mathCache_->sizeOfIncludingThis(mallocSizeOf) : 0;

    rtSizes->scriptFilenames = scriptFilenameTable.sizeOfExcludingThis(mallocSizeOf);
    for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
        rtSizes->scriptFilenames += mallocSizeOf(r.front());
}
void
JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *runtime)
{
    runtime->object = mallocSizeOf(this);

    runtime->atomsTable = atomState.atoms.sizeOfExcludingThis(mallocSizeOf);

    runtime->contexts = 0;
    for (ContextIter acx(this); !acx.done(); acx.next())
        runtime->contexts += acx->sizeOfIncludingThis(mallocSizeOf);

    runtime->dtoa = mallocSizeOf(dtoaState);

    runtime->temporary = tempLifoAlloc.sizeOfExcludingThis(mallocSizeOf);

    if (execAlloc_)
        execAlloc_->sizeOfCode(&runtime->mjitCode, &runtime->regexpCode,
                               &runtime->unusedCodeMemory);
    else
        runtime->mjitCode = runtime->regexpCode = runtime->unusedCodeMemory = 0;

    runtime->stackCommitted = stackSpace.sizeOfCommitted();

    runtime->gcMarker = gcMarker.sizeOfExcludingThis(mallocSizeOf);

    runtime->mathCache = mathCache_ ? mathCache_->sizeOfIncludingThis(mallocSizeOf) : 0;

    runtime->scriptFilenames = scriptFilenameTable.sizeOfExcludingThis(mallocSizeOf);
    for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
        runtime->scriptFilenames += mallocSizeOf(r.front());

    runtime->scriptSources = 0;
    for (ScriptSource *n = scriptSources; n; n = n->next)
        runtime->scriptSources += n->sizeOfIncludingThis(mallocSizeOf);

    runtime->compartmentObjects = 0;
    CallbackData data(mallocSizeOf);
    JS_IterateCompartments(this, &data, CompartmentCallback);
    runtime->compartmentObjects = data.n;
}