зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1164042 - Log weak map entries in DumpHeapComplete. r=terrence
This commit is contained in:
Родитель
3a61d917ac
Коммит
692d366804
|
@ -886,14 +886,31 @@ JS::FormatStackDump(JSContext* cx, char* buf, bool showArgs, bool showLocals, bo
|
|||
return buf;
|
||||
}
|
||||
|
||||
struct DumpHeapTracer : public JS::CallbackTracer
|
||||
struct DumpHeapTracer : public JS::CallbackTracer, public WeakMapTracer
|
||||
{
|
||||
FILE* output;
|
||||
|
||||
DumpHeapTracer(FILE* fp, JSRuntime* rt, JSTraceCallback callback,
|
||||
WeakMapTraceKind weakTraceKind)
|
||||
: JS::CallbackTracer(rt, callback, weakTraceKind), output(fp)
|
||||
DumpHeapTracer(FILE* fp, JSRuntime* rt, JSTraceCallback callback)
|
||||
: JS::CallbackTracer(rt, callback, DoNotTraceWeakMaps),
|
||||
js::WeakMapTracer(rt, DumpWeakMap), output(fp)
|
||||
{}
|
||||
|
||||
private:
|
||||
static void
|
||||
DumpWeakMap(js::WeakMapTracer* trc, JSObject* map,
|
||||
JS::GCCellPtr key, JS::GCCellPtr value)
|
||||
{
|
||||
DumpHeapTracer* tracer =
|
||||
static_cast<DumpHeapTracer*>(trc);
|
||||
|
||||
JSObject* kdelegate = nullptr;
|
||||
if (key.isObject()) {
|
||||
kdelegate = js::GetWeakmapKeyDelegate(key.toObject());
|
||||
}
|
||||
|
||||
fprintf(tracer->output, "WeakMapEntry map=%p key=%p keyDelegate=%p value=%p\n",
|
||||
map, key.asCell(), kdelegate, value.asCell());
|
||||
}
|
||||
};
|
||||
|
||||
static char
|
||||
|
@ -976,9 +993,13 @@ js::DumpHeapComplete(JSRuntime* rt, FILE* fp, js::DumpHeapNurseryBehaviour nurse
|
|||
if (nurseryBehaviour == js::CollectNurseryBeforeDump)
|
||||
rt->gc.evictNursery(JS::gcreason::API);
|
||||
|
||||
DumpHeapTracer dtrc(fp, rt, DumpHeapVisitRoot, TraceWeakMapKeysValues);
|
||||
DumpHeapTracer dtrc(fp, rt, DumpHeapVisitRoot);
|
||||
fprintf(dtrc.output, "# Roots.\n");
|
||||
TraceRuntime(&dtrc);
|
||||
|
||||
fprintf(dtrc.output, "# Weak maps.\n");
|
||||
WeakMapBase::traceAllMappings(&dtrc);
|
||||
|
||||
fprintf(dtrc.output, "==========\n");
|
||||
|
||||
dtrc.setTraceCallback(DumpHeapVisitChild);
|
||||
|
|
|
@ -48,9 +48,9 @@ WeakMapBase::trace(JSTracer* tracer)
|
|||
MOZ_ASSERT(isInList());
|
||||
if (tracer->isMarkingTracer()) {
|
||||
// We don't trace any of the WeakMap entries at this time, just record
|
||||
// record the fact that the WeakMap has been marked. Enties are marked
|
||||
// record the fact that the WeakMap has been marked. Entries are marked
|
||||
// in the iterative marking phase by markAllIteratively(), which happens
|
||||
// when many keys as possible have been marked already.
|
||||
// when as many keys as possible have been marked already.
|
||||
MOZ_ASSERT(tracer->eagerlyTraceWeakMaps() == DoNotTraceWeakMaps);
|
||||
marked = true;
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче