зеркало из https://github.com/mozilla/pjs.git
Bug 731618 - remove JSContext * parameter from heap iteration API. r=:Billm
This commit is contained in:
Родитель
90436a3ea0
Коммит
9a8f93d9c8
|
@ -1534,11 +1534,13 @@ public:
|
|||
bool
|
||||
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
{
|
||||
JSAutoSuspendRequest asr(aCx);
|
||||
|
||||
*mSucceeded = mIsQuick
|
||||
? JS::GetExplicitNonHeapForRuntime(JS_GetRuntime(aCx), static_cast<int64_t*>(mData), JsWorkerMallocSizeOf)
|
||||
: JS::CollectRuntimeStats(JS_GetRuntime(aCx), static_cast<JS::RuntimeStats*>(mData));
|
||||
JSRuntime *rt = JS_GetRuntime(aCx);
|
||||
if (mIsQuick) {
|
||||
*static_cast<int64_t*>(mData) = JS::GetExplicitNonHeapForRuntime(rt, JsWorkerMallocSizeOf);
|
||||
*mSucceeded = true;
|
||||
} else {
|
||||
*mSucceeded = JS::CollectRuntimeStats(rt, static_cast<JS::RuntimeStats*>(mData));
|
||||
}
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
|
|
@ -61,7 +61,7 @@ struct TypeInferenceSizes
|
|||
size_t temporary;
|
||||
};
|
||||
|
||||
typedef void* (* GetNameCallback)(JSContext *cx, JSCompartment *c);
|
||||
typedef void* (* GetNameCallback)(JSRuntime *rt, JSCompartment *c);
|
||||
typedef void (* DestroyNameCallback)(void *string);
|
||||
|
||||
struct CompartmentStats
|
||||
|
@ -192,9 +192,8 @@ struct RuntimeStats
|
|||
extern JS_PUBLIC_API(bool)
|
||||
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount,
|
||||
JSMallocSizeOfFun mallocSizeOf);
|
||||
extern JS_PUBLIC_API(int64_t)
|
||||
GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace JS {
|
|||
using namespace js;
|
||||
|
||||
static void
|
||||
StatsCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment)
|
||||
StatsCompartmentCallback(JSRuntime *rt, void *data, JSCompartment *compartment)
|
||||
{
|
||||
// Append a new CompartmentStats to the vector.
|
||||
RuntimeStats *rtStats = static_cast<RuntimeStats *>(data);
|
||||
|
@ -63,19 +63,19 @@ StatsCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment)
|
|||
// CollectRuntimeStats reserves enough space.
|
||||
MOZ_ALWAYS_TRUE(rtStats->compartmentStatsVector.growBy(1));
|
||||
CompartmentStats &cStats = rtStats->compartmentStatsVector.back();
|
||||
cStats.init(rtStats->getNameCb(cx, compartment), rtStats->destroyNameCb);
|
||||
cStats.init(rtStats->getNameCb(rt, compartment), rtStats->destroyNameCb);
|
||||
rtStats->currCompartmentStats = &cStats;
|
||||
|
||||
// Get the compartment-level numbers.
|
||||
#ifdef JS_METHODJIT
|
||||
cStats.mjitCode = compartment->sizeOfMjitCode();
|
||||
#endif
|
||||
compartment->sizeOfTypeInferenceData(cx, &cStats.typeInferenceSizes, rtStats->mallocSizeOf);
|
||||
compartment->sizeOfTypeInferenceData(&cStats.typeInferenceSizes, rtStats->mallocSizeOf);
|
||||
cStats.shapesCompartmentTables = compartment->sizeOfShapeTable(rtStats->mallocSizeOf);
|
||||
}
|
||||
|
||||
static void
|
||||
StatsChunkCallback(JSContext *cx, void *data, gc::Chunk *chunk)
|
||||
StatsChunkCallback(JSRuntime *rt, void *data, gc::Chunk *chunk)
|
||||
{
|
||||
// Nb: This function is only called for dirty chunks, which is why we
|
||||
// increment gcHeapChunkDirtyDecommitted.
|
||||
|
@ -86,7 +86,7 @@ StatsChunkCallback(JSContext *cx, void *data, gc::Chunk *chunk)
|
|||
}
|
||||
|
||||
static void
|
||||
StatsArenaCallback(JSContext *cx, void *data, gc::Arena *arena,
|
||||
StatsArenaCallback(JSRuntime *rt, void *data, gc::Arena *arena,
|
||||
JSGCTraceKind traceKind, size_t thingSize)
|
||||
{
|
||||
RuntimeStats *rtStats = static_cast<RuntimeStats *>(data);
|
||||
|
@ -103,7 +103,7 @@ StatsArenaCallback(JSContext *cx, void *data, gc::Arena *arena,
|
|||
}
|
||||
|
||||
static void
|
||||
StatsCellCallback(JSContext *cx, void *data, void *thing, JSGCTraceKind traceKind,
|
||||
StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKind,
|
||||
size_t thingSize)
|
||||
{
|
||||
RuntimeStats *rtStats = static_cast<RuntimeStats *>(data);
|
||||
|
@ -183,45 +183,35 @@ StatsCellCallback(JSContext *cx, void *data, void *thing, JSGCTraceKind traceKin
|
|||
JS_PUBLIC_API(bool)
|
||||
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats)
|
||||
{
|
||||
JSContext *cx = JS_NewContext(rt, 0);
|
||||
if (!cx)
|
||||
if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
|
||||
return false;
|
||||
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
|
||||
return false;
|
||||
|
||||
rtStats->gcHeapChunkCleanDecommitted =
|
||||
rt->gcChunkPool.countCleanDecommittedArenas(rt) * gc::ArenaSize;
|
||||
rtStats->gcHeapChunkCleanUnused =
|
||||
size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize -
|
||||
rtStats->gcHeapChunkCleanDecommitted;
|
||||
rtStats->gcHeapChunkTotal =
|
||||
size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
|
||||
|
||||
IterateCompartmentsArenasCells(cx, rtStats, StatsCompartmentCallback,
|
||||
StatsArenaCallback, StatsCellCallback);
|
||||
IterateChunks(cx, rtStats, StatsChunkCallback);
|
||||
|
||||
rtStats->runtimeObject = rtStats->mallocSizeOf(rt);
|
||||
|
||||
rt->sizeOfExcludingThis(rtStats->mallocSizeOf,
|
||||
&rtStats->runtimeNormal,
|
||||
&rtStats->runtimeTemporary,
|
||||
&rtStats->runtimeRegexpCode,
|
||||
&rtStats->runtimeStackCommitted,
|
||||
&rtStats->runtimeGCMarker);
|
||||
|
||||
rtStats->runtimeAtomsTable =
|
||||
rt->atomState.atoms.sizeOfExcludingThis(rtStats->mallocSizeOf);
|
||||
|
||||
for (ContextIter acx(rt); !acx.done(); acx.next())
|
||||
rtStats->runtimeContexts += acx->sizeOfIncludingThis(rtStats->mallocSizeOf);
|
||||
}
|
||||
|
||||
JS_DestroyContextNoGC(cx);
|
||||
|
||||
rtStats->gcHeapChunkCleanDecommitted =
|
||||
rt->gcChunkPool.countCleanDecommittedArenas(rt) * gc::ArenaSize;
|
||||
rtStats->gcHeapChunkCleanUnused =
|
||||
size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize -
|
||||
rtStats->gcHeapChunkCleanDecommitted;
|
||||
rtStats->gcHeapChunkTotal =
|
||||
size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
|
||||
|
||||
IterateCompartmentsArenasCells(rt, rtStats, StatsCompartmentCallback,
|
||||
StatsArenaCallback, StatsCellCallback);
|
||||
IterateChunks(rt, rtStats, StatsChunkCallback);
|
||||
|
||||
rtStats->runtimeObject = rtStats->mallocSizeOf(rt);
|
||||
|
||||
rt->sizeOfExcludingThis(rtStats->mallocSizeOf,
|
||||
&rtStats->runtimeNormal,
|
||||
&rtStats->runtimeTemporary,
|
||||
&rtStats->runtimeRegexpCode,
|
||||
&rtStats->runtimeStackCommitted,
|
||||
&rtStats->runtimeGCMarker);
|
||||
|
||||
rtStats->runtimeAtomsTable =
|
||||
rt->atomState.atoms.sizeOfExcludingThis(rtStats->mallocSizeOf);
|
||||
|
||||
for (ContextIter acx(rt); !acx.done(); acx.next())
|
||||
rtStats->runtimeContexts += acx->sizeOfIncludingThis(rtStats->mallocSizeOf);
|
||||
|
||||
// This is initialized to all bytes stored in used chunks, and then we
|
||||
// subtract used space from it each time around the loop.
|
||||
|
@ -298,7 +288,7 @@ CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats)
|
|||
}
|
||||
|
||||
static void
|
||||
ExplicitNonHeapCompartmentCallback(JSContext *cx, void *data, JSCompartment *compartment)
|
||||
ExplicitNonHeapCompartmentCallback(JSRuntime *rt, void *data, JSCompartment *compartment)
|
||||
{
|
||||
#ifdef JS_METHODJIT
|
||||
size_t *n = static_cast<size_t *>(data);
|
||||
|
@ -306,43 +296,29 @@ ExplicitNonHeapCompartmentCallback(JSContext *cx, void *data, JSCompartment *com
|
|||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount,
|
||||
JSMallocSizeOfFun mallocSizeOf)
|
||||
JS_PUBLIC_API(int64_t)
|
||||
GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
JSContext *cx = JS_NewContext(rt, 0);
|
||||
if (!cx)
|
||||
return false;
|
||||
|
||||
// explicit/<compartment>/gc-heap/*
|
||||
*amount = int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) *
|
||||
gc::ChunkSize;
|
||||
size_t n = size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
|
||||
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
// explicit/<compartment>/mjit-code
|
||||
JS_IterateCompartments(rt, &n, ExplicitNonHeapCompartmentCallback);
|
||||
|
||||
// explicit/runtime/regexp-code
|
||||
// explicit/runtime/stack-committed
|
||||
size_t regexpCode, stackCommitted;
|
||||
rt->sizeOfExcludingThis(mallocSizeOf,
|
||||
NULL,
|
||||
NULL,
|
||||
®expCode,
|
||||
&stackCommitted,
|
||||
NULL);
|
||||
|
||||
n += regexpCode;
|
||||
n += stackCommitted;
|
||||
|
||||
// explicit/<compartment>/mjit-code
|
||||
size_t n = 0;
|
||||
JS_IterateCompartments(cx, &n, ExplicitNonHeapCompartmentCallback);
|
||||
*amount += n;
|
||||
|
||||
// explicit/runtime/regexp-code
|
||||
// explicit/runtime/stack-committed
|
||||
size_t regexpCode, stackCommitted;
|
||||
rt->sizeOfExcludingThis(mallocSizeOf,
|
||||
NULL,
|
||||
NULL,
|
||||
®expCode,
|
||||
&stackCommitted,
|
||||
NULL);
|
||||
|
||||
*amount += regexpCode;
|
||||
*amount += stackCommitted;
|
||||
}
|
||||
|
||||
JS_DestroyContextNoGC(cx);
|
||||
|
||||
return true;
|
||||
return int64_t(n);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(size_t)
|
||||
|
|
|
@ -2685,8 +2685,7 @@ class JS_PUBLIC_API(JSAutoEnterCompartment)
|
|||
JS_BEGIN_EXTERN_C
|
||||
#endif
|
||||
|
||||
typedef void (*JSIterateCompartmentCallback)(JSContext *cx, void *data,
|
||||
JSCompartment *compartment);
|
||||
typedef void (*JSIterateCompartmentCallback)(JSRuntime *rt, void *data, JSCompartment *compartment);
|
||||
|
||||
/*
|
||||
* This function calls |compartmentCallback| on every compartment. Beware that
|
||||
|
@ -2694,7 +2693,7 @@ typedef void (*JSIterateCompartmentCallback)(JSContext *cx, void *data,
|
|||
* returns.
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_IterateCompartments(JSContext *cx, void *data,
|
||||
JS_IterateCompartments(JSRuntime *rt, void *data,
|
||||
JSIterateCompartmentCallback compartmentCallback);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
|
|
|
@ -689,9 +689,9 @@ JSCompartment::updateForDebugMode(JSContext *cx)
|
|||
|
||||
/*
|
||||
* Discard JIT code and bytecode analyses for any scripts that change
|
||||
* debugMode. This assumes that 'comp' is in the same thread as 'cx'.
|
||||
* debugMode.
|
||||
*/
|
||||
for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->debugMode != enabled) {
|
||||
mjit::ReleaseScriptCode(cx, script);
|
||||
|
@ -739,7 +739,7 @@ JSCompartment::removeDebuggee(JSContext *cx,
|
|||
void
|
||||
JSCompartment::clearBreakpointsIn(JSContext *cx, js::Debugger *dbg, JSObject *handler)
|
||||
{
|
||||
for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->hasAnyBreakpointsOrStepMode())
|
||||
script->clearBreakpointsIn(cx, dbg, handler);
|
||||
|
@ -749,7 +749,7 @@ JSCompartment::clearBreakpointsIn(JSContext *cx, js::Debugger *dbg, JSObject *ha
|
|||
void
|
||||
JSCompartment::clearTraps(JSContext *cx)
|
||||
{
|
||||
for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(this, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->hasAnyBreakpointsOrStepMode())
|
||||
script->clearTraps(cx);
|
||||
|
|
|
@ -262,8 +262,7 @@ struct JSCompartment
|
|||
js::RegExpCompartment regExps;
|
||||
|
||||
size_t sizeOfShapeTable(JSMallocSizeOfFun mallocSizeOf);
|
||||
void sizeOfTypeInferenceData(JSContext *cx, JS::TypeInferenceSizes *stats,
|
||||
JSMallocSizeOfFun mallocSizeOf);
|
||||
void sizeOfTypeInferenceData(JS::TypeInferenceSizes *stats, JSMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
/*
|
||||
* Shared scope property tree, and arena-pool for allocating its nodes.
|
||||
|
|
|
@ -1629,20 +1629,26 @@ JS_DumpPCCounts(JSContext *cx, JSScript *script)
|
|||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
typedef Vector<JSScript *, 0, SystemAllocPolicy> ScriptsToDump;
|
||||
|
||||
static void
|
||||
DumpBytecodeScriptCallback(JSContext *cx, void *data, void *thing,
|
||||
DumpBytecodeScriptCallback(JSRuntime *rt, void *data, void *thing,
|
||||
JSGCTraceKind traceKind, size_t thingSize)
|
||||
{
|
||||
JS_ASSERT(traceKind == JSTRACE_SCRIPT);
|
||||
JSScript *script = static_cast<JSScript *>(thing);
|
||||
reinterpret_cast<Vector<JSScript *> *>(data)->append(script);
|
||||
static_cast<ScriptsToDump *>(data)->append(script);
|
||||
}
|
||||
|
||||
} /* anonymous namespace */
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DumpCompartmentBytecode(JSContext *cx)
|
||||
{
|
||||
Vector<JSScript *> scripts(cx);
|
||||
IterateCells(cx, cx->compartment, gc::FINALIZE_SCRIPT, &scripts, DumpBytecodeScriptCallback);
|
||||
ScriptsToDump scripts;
|
||||
IterateCells(cx->runtime, cx->compartment, gc::FINALIZE_SCRIPT, &scripts, DumpBytecodeScriptCallback);
|
||||
|
||||
for (size_t i = 0; i < scripts.length(); i++)
|
||||
JS_DumpBytecode(cx, scripts[i]);
|
||||
|
@ -1651,7 +1657,7 @@ JS_DumpCompartmentBytecode(JSContext *cx)
|
|||
JS_PUBLIC_API(void)
|
||||
JS_DumpCompartmentPCCounts(JSContext *cx)
|
||||
{
|
||||
for (CellIter i(cx, cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (CellIter i(cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->pcCounters)
|
||||
JS_DumpPCCounts(cx, script);
|
||||
|
|
|
@ -3793,41 +3793,38 @@ TraceRuntime(JSTracer *trc)
|
|||
|
||||
struct IterateArenaCallbackOp
|
||||
{
|
||||
JSContext *cx;
|
||||
JSRuntime *rt;
|
||||
void *data;
|
||||
IterateArenaCallback callback;
|
||||
JSGCTraceKind traceKind;
|
||||
size_t thingSize;
|
||||
IterateArenaCallbackOp(JSContext *cx, void *data, IterateArenaCallback callback,
|
||||
IterateArenaCallbackOp(JSRuntime *rt, void *data, IterateArenaCallback callback,
|
||||
JSGCTraceKind traceKind, size_t thingSize)
|
||||
: cx(cx), data(data), callback(callback), traceKind(traceKind), thingSize(thingSize)
|
||||
: rt(rt), data(data), callback(callback), traceKind(traceKind), thingSize(thingSize)
|
||||
{}
|
||||
void operator()(Arena *arena) { (*callback)(cx, data, arena, traceKind, thingSize); }
|
||||
void operator()(Arena *arena) { (*callback)(rt, data, arena, traceKind, thingSize); }
|
||||
};
|
||||
|
||||
struct IterateCellCallbackOp
|
||||
{
|
||||
JSContext *cx;
|
||||
JSRuntime *rt;
|
||||
void *data;
|
||||
IterateCellCallback callback;
|
||||
JSGCTraceKind traceKind;
|
||||
size_t thingSize;
|
||||
IterateCellCallbackOp(JSContext *cx, void *data, IterateCellCallback callback,
|
||||
IterateCellCallbackOp(JSRuntime *rt, void *data, IterateCellCallback callback,
|
||||
JSGCTraceKind traceKind, size_t thingSize)
|
||||
: cx(cx), data(data), callback(callback), traceKind(traceKind), thingSize(thingSize)
|
||||
: rt(rt), data(data), callback(callback), traceKind(traceKind), thingSize(thingSize)
|
||||
{}
|
||||
void operator()(Cell *cell) { (*callback)(cx, data, cell, traceKind, thingSize); }
|
||||
void operator()(Cell *cell) { (*callback)(rt, data, cell, traceKind, thingSize); }
|
||||
};
|
||||
|
||||
void
|
||||
IterateCompartmentsArenasCells(JSContext *cx, void *data,
|
||||
IterateCompartmentsArenasCells(JSRuntime *rt, void *data,
|
||||
JSIterateCompartmentCallback compartmentCallback,
|
||||
IterateArenaCallback arenaCallback,
|
||||
IterateCellCallback cellCallback)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
AutoLockGC lock(rt);
|
||||
|
@ -3839,25 +3836,22 @@ IterateCompartmentsArenasCells(JSContext *cx, void *data,
|
|||
|
||||
AutoCopyFreeListToArenas copy(rt);
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
(*compartmentCallback)(cx, data, c);
|
||||
(*compartmentCallback)(rt, data, c);
|
||||
|
||||
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
|
||||
JSGCTraceKind traceKind = MapAllocToTraceKind(AllocKind(thingKind));
|
||||
size_t thingSize = Arena::thingSize(AllocKind(thingKind));
|
||||
IterateArenaCallbackOp arenaOp(cx, data, arenaCallback, traceKind, thingSize);
|
||||
IterateCellCallbackOp cellOp(cx, data, cellCallback, traceKind, thingSize);
|
||||
IterateArenaCallbackOp arenaOp(rt, data, arenaCallback, traceKind, thingSize);
|
||||
IterateCellCallbackOp cellOp(rt, data, cellCallback, traceKind, thingSize);
|
||||
ForEachArenaAndCell(c, AllocKind(thingKind), arenaOp, cellOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IterateChunks(JSContext *cx, void *data, IterateChunkCallback chunkCallback)
|
||||
IterateChunks(JSRuntime *rt, void *data, IterateChunkCallback chunkCallback)
|
||||
{
|
||||
/* :XXX: Any way to common this preamble with IterateCompartmentsArenasCells? */
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
AutoLockGC lock(rt);
|
||||
|
@ -3868,17 +3862,14 @@ IterateChunks(JSContext *cx, void *data, IterateChunkCallback chunkCallback)
|
|||
AutoUnlockGC unlock(rt);
|
||||
|
||||
for (js::GCChunkSet::Range r = rt->gcChunkSet.all(); !r.empty(); r.popFront())
|
||||
chunkCallback(cx, data, r.front());
|
||||
chunkCallback(rt, data, r.front());
|
||||
}
|
||||
|
||||
void
|
||||
IterateCells(JSContext *cx, JSCompartment *compartment, AllocKind thingKind,
|
||||
IterateCells(JSRuntime *rt, JSCompartment *compartment, AllocKind thingKind,
|
||||
void *data, IterateCellCallback cellCallback)
|
||||
{
|
||||
/* :XXX: Any way to common this preamble with IterateCompartmentsArenasCells? */
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
AutoLockGC lock(rt);
|
||||
|
@ -3895,11 +3886,11 @@ IterateCells(JSContext *cx, JSCompartment *compartment, AllocKind thingKind,
|
|||
|
||||
if (compartment) {
|
||||
for (CellIterUnderGC i(compartment, thingKind); !i.done(); i.next())
|
||||
cellCallback(cx, data, i.getCell(), traceKind, thingSize);
|
||||
cellCallback(rt, data, i.getCell(), traceKind, thingSize);
|
||||
} else {
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
for (CellIterUnderGC i(c, thingKind); !i.done(); i.next())
|
||||
cellCallback(cx, data, i.getCell(), traceKind, thingSize);
|
||||
cellCallback(rt, data, i.getCell(), traceKind, thingSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4456,7 +4447,7 @@ static void ReleaseAllJITCode(JSContext *cx)
|
|||
#ifdef JS_METHODJIT
|
||||
for (GCCompartmentsIter c(cx->runtime); !c.done(); c.next()) {
|
||||
mjit::ClearAllFrames(c);
|
||||
for (CellIter i(cx, c, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (CellIter i(c, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
mjit::ReleaseScriptCode(cx, script);
|
||||
}
|
||||
|
@ -4537,7 +4528,7 @@ StopPCCountProfiling(JSContext *cx)
|
|||
return;
|
||||
|
||||
for (GCCompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
for (CellIter i(cx, c, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (CellIter i(c, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->pcCounters && script->types) {
|
||||
ScriptOpcodeCountsPair info;
|
||||
|
@ -4569,19 +4560,16 @@ PurgePCCounts(JSContext *cx)
|
|||
} /* namespace js */
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_IterateCompartments(JSContext *cx, void *data,
|
||||
JS_IterateCompartments(JSRuntime *rt, void *data,
|
||||
JSIterateCompartmentCallback compartmentCallback)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JS_ASSERT(!rt->gcRunning);
|
||||
|
||||
AutoLockGC lock(rt);
|
||||
AutoHeapSession session(rt);
|
||||
|
||||
for (CompartmentsIter c(rt); !c.done(); c.next())
|
||||
(*compartmentCallback)(cx, data, c);
|
||||
(*compartmentCallback)(rt, data, c);
|
||||
}
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
|
|
|
@ -1932,10 +1932,10 @@ SetMarkStackLimit(JSRuntime *rt, size_t limit);
|
|||
void
|
||||
MarkStackRangeConservatively(JSTracer *trc, Value *begin, Value *end);
|
||||
|
||||
typedef void (*IterateChunkCallback)(JSContext *cx, void *data, gc::Chunk *chunk);
|
||||
typedef void (*IterateArenaCallback)(JSContext *cx, void *data, gc::Arena *arena,
|
||||
typedef void (*IterateChunkCallback)(JSRuntime *rt, void *data, gc::Chunk *chunk);
|
||||
typedef void (*IterateArenaCallback)(JSRuntime *rt, void *data, gc::Arena *arena,
|
||||
JSGCTraceKind traceKind, size_t thingSize);
|
||||
typedef void (*IterateCellCallback)(JSContext *cx, void *data, void *thing,
|
||||
typedef void (*IterateCellCallback)(JSRuntime *rt, void *data, void *thing,
|
||||
JSGCTraceKind traceKind, size_t thingSize);
|
||||
|
||||
/*
|
||||
|
@ -1944,7 +1944,7 @@ typedef void (*IterateCellCallback)(JSContext *cx, void *data, void *thing,
|
|||
* cell in the GC heap.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IterateCompartmentsArenasCells(JSContext *cx, void *data,
|
||||
IterateCompartmentsArenasCells(JSRuntime *rt, void *data,
|
||||
JSIterateCompartmentCallback compartmentCallback,
|
||||
IterateArenaCallback arenaCallback,
|
||||
IterateCellCallback cellCallback);
|
||||
|
@ -1953,14 +1953,14 @@ IterateCompartmentsArenasCells(JSContext *cx, void *data,
|
|||
* Invoke chunkCallback on every in-use chunk.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IterateChunks(JSContext *cx, void *data, IterateChunkCallback chunkCallback);
|
||||
IterateChunks(JSRuntime *rt, void *data, IterateChunkCallback chunkCallback);
|
||||
|
||||
/*
|
||||
* Invoke cellCallback on every in-use object of the specified thing kind for
|
||||
* the given compartment or for all compartments if it is null.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
IterateCells(JSContext *cx, JSCompartment *compartment, gc::AllocKind thingKind,
|
||||
IterateCells(JSRuntime *rt, JSCompartment *compartment, gc::AllocKind thingKind,
|
||||
void *data, IterateCellCallback cellCallback);
|
||||
|
||||
} /* namespace js */
|
||||
|
|
|
@ -349,7 +349,7 @@ class CellIter : public CellIterImpl
|
|||
size_t *counter;
|
||||
#endif
|
||||
public:
|
||||
CellIter(JSContext *cx, JSCompartment *comp, AllocKind kind)
|
||||
CellIter(JSCompartment *comp, AllocKind kind)
|
||||
: lists(&comp->arenas),
|
||||
kind(kind)
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ class CellIter : public CellIterImpl
|
|||
lists->copyFreeListToArena(kind);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
counter = &cx->runtime->noGCOrAllocationCheck;
|
||||
counter = &comp->rt->noGCOrAllocationCheck;
|
||||
++*counter;
|
||||
#endif
|
||||
init(comp, kind);
|
||||
|
|
|
@ -2204,7 +2204,7 @@ TypeCompartment::nukeTypes(JSContext *cx)
|
|||
|
||||
/* Throw away all JIT code in the compartment, but leave everything else alone. */
|
||||
|
||||
for (gc::CellIter i(cx, cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->hasJITCode())
|
||||
mjit::ReleaseScriptCode(cx, script);
|
||||
|
@ -2319,7 +2319,7 @@ TypeCompartment::markSetsUnknown(JSContext *cx, TypeObject *target)
|
|||
* new type objects as well or trigger GC.
|
||||
*/
|
||||
Vector<TypeSet *> pending(cx);
|
||||
for (gc::CellIter i(cx, cx->compartment, gc::FINALIZE_TYPE_OBJECT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(cx->compartment, gc::FINALIZE_TYPE_OBJECT); !i.done(); i.next()) {
|
||||
TypeObject *object = i.get<TypeObject>();
|
||||
|
||||
unsigned count = object->getPropertyCount();
|
||||
|
@ -2335,7 +2335,7 @@ TypeCompartment::markSetsUnknown(JSContext *cx, TypeObject *target)
|
|||
for (unsigned i = 0; i < pending.length(); i++)
|
||||
pending[i]->addType(cx, Type::AnyObjectType());
|
||||
|
||||
for (gc::CellIter i(cx, cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->types) {
|
||||
unsigned count = TypeScript::NumTypeSets(script);
|
||||
|
@ -2455,14 +2455,14 @@ TypeCompartment::print(JSContext *cx, bool force)
|
|||
if (!force && !InferSpewActive(ISpewResult))
|
||||
return;
|
||||
|
||||
for (gc::CellIter i(cx, compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->hasAnalysis() && script->analysis()->ranInference())
|
||||
script->analysis()->printTypes(cx);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
for (gc::CellIter i(cx, compartment, gc::FINALIZE_TYPE_OBJECT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(compartment, gc::FINALIZE_TYPE_OBJECT); !i.done(); i.next()) {
|
||||
TypeObject *object = i.get<TypeObject>();
|
||||
object->print(cx);
|
||||
}
|
||||
|
@ -6322,8 +6322,7 @@ SizeOfScriptTypeInferenceData(JSScript *script, TypeInferenceSizes *sizes,
|
|||
}
|
||||
|
||||
void
|
||||
JSCompartment::sizeOfTypeInferenceData(JSContext *cx, TypeInferenceSizes *sizes,
|
||||
JSMallocSizeOfFun mallocSizeOf)
|
||||
JSCompartment::sizeOfTypeInferenceData(TypeInferenceSizes *sizes, JSMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
/*
|
||||
* Note: not all data in the pool is temporary, and some will survive GCs
|
||||
|
@ -6338,7 +6337,7 @@ JSCompartment::sizeOfTypeInferenceData(JSContext *cx, TypeInferenceSizes *sizes,
|
|||
/* TypeCompartment::pendingRecompiles is non-NULL only while inference code is running. */
|
||||
JS_ASSERT(!types.pendingRecompiles);
|
||||
|
||||
for (gc::CellIter i(cx, this, gc::FINALIZE_SCRIPT); !i.done(); i.next())
|
||||
for (gc::CellIter i(this, gc::FINALIZE_SCRIPT); !i.done(); i.next())
|
||||
SizeOfScriptTypeInferenceData(i.get<JSScript>(), sizes, mallocSizeOf);
|
||||
|
||||
if (types.allocationSiteTable)
|
||||
|
|
|
@ -371,7 +371,7 @@ GlobalObject::clear(JSContext *cx)
|
|||
* can directly call scripts which have associated JIT code, and do so
|
||||
* without checking whether the script's global has been cleared.
|
||||
*/
|
||||
for (gc::CellIter i(cx, cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
for (gc::CellIter i(cx->compartment, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
||||
JSScript *script = i.get<JSScript>();
|
||||
if (script->compileAndGo && script->hasJITCode() && script->hasClearedGlobal()) {
|
||||
mjit::Recompiler::clearStackReferences(cx, script);
|
||||
|
|
|
@ -1250,20 +1250,20 @@ GetCompartmentNameHelper(JSCompartment *c, bool getAddress)
|
|||
return name;
|
||||
}
|
||||
|
||||
static void*
|
||||
GetCompartmentNameAndAddress(JSRuntime *rt, JSCompartment *c)
|
||||
{
|
||||
return GetCompartmentNameHelper(c, /* get address = */true);
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
|
||||
void*
|
||||
GetCompartmentName(JSContext *cx, JSCompartment *c)
|
||||
GetCompartmentName(JSRuntime *rt, JSCompartment *c)
|
||||
{
|
||||
return GetCompartmentNameHelper(c, /* get address = */false);
|
||||
}
|
||||
|
||||
void*
|
||||
GetCompartmentNameAndAddress(JSContext *cx, JSCompartment *c)
|
||||
{
|
||||
return GetCompartmentNameHelper(c, /* get address = */true);
|
||||
}
|
||||
|
||||
void
|
||||
DestroyCompartmentName(void *string)
|
||||
{
|
||||
|
@ -1745,11 +1745,11 @@ class JSCompartmentsMultiReporter : public nsIMemoryMultiReporter
|
|||
|
||||
typedef js::Vector<nsCString, 0, js::SystemAllocPolicy> Paths;
|
||||
|
||||
static void CompartmentCallback(JSContext *cx, void* data, JSCompartment *c)
|
||||
static void CompartmentCallback(JSRuntime *rt, void* data, JSCompartment *c)
|
||||
{
|
||||
Paths *paths = static_cast<Paths *>(data);
|
||||
nsCString *name =
|
||||
static_cast<nsCString *>(xpc::GetCompartmentName(cx, c));
|
||||
static_cast<nsCString *>(xpc::GetCompartmentName(rt, c));
|
||||
nsCString path;
|
||||
if (js::IsSystemCompartment(c))
|
||||
path = NS_LITERAL_CSTRING("compartments/system/") + *name;
|
||||
|
@ -1769,15 +1769,11 @@ class JSCompartmentsMultiReporter : public nsIMemoryMultiReporter
|
|||
// from within CompartmentCallback() leads to all manner of assertions.
|
||||
|
||||
// Collect.
|
||||
XPCJSRuntime *xpcrt = nsXPConnect::GetRuntimeInstance();
|
||||
JSContext *cx = JS_NewContext(xpcrt->GetJSRuntime(), 0);
|
||||
if (!cx)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
Paths paths;
|
||||
JS_IterateCompartments(cx, &paths, CompartmentCallback);
|
||||
JS_DestroyContextNoGC(cx);
|
||||
|
||||
JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->GetJSRuntime(),
|
||||
&paths, CompartmentCallback);
|
||||
|
||||
// Report.
|
||||
for (size_t i = 0; i < paths.length(); i++)
|
||||
// These ones don't need a description, hence the "".
|
||||
|
@ -1823,7 +1819,7 @@ public:
|
|||
// the callback. Separating these steps is important because the
|
||||
// callback may be a JS function, and executing JS while getting these
|
||||
// stats seems like a bad idea.
|
||||
JS::RuntimeStats rtStats(JsMallocSizeOf, xpc::GetCompartmentNameAndAddress,
|
||||
JS::RuntimeStats rtStats(JsMallocSizeOf, GetCompartmentNameAndAddress,
|
||||
xpc::DestroyCompartmentName);
|
||||
if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1941,10 +1937,7 @@ public:
|
|||
GetExplicitNonHeap(PRInt64 *n)
|
||||
{
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
|
||||
if (!JS::GetExplicitNonHeapForRuntime(rt, reinterpret_cast<int64_t*>(n), JsMallocSizeOf))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*reinterpret_cast<int64_t*>(n) = JS::GetExplicitNonHeapForRuntime(rt, JsMallocSizeOf);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -222,7 +222,7 @@ bool Base64Decode(JSContext *cx, JS::Value val, JS::Value *out);
|
|||
bool StringToJsval(JSContext *cx, nsAString &str, JS::Value *rval);
|
||||
bool NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval);
|
||||
|
||||
void *GetCompartmentName(JSContext *cx, JSCompartment *c);
|
||||
void *GetCompartmentName(JSRuntime *rt, JSCompartment *c);
|
||||
void DestroyCompartmentName(void *string);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
Загрузка…
Ссылка в новой задаче