зеркало из https://github.com/mozilla/gecko-dev.git
Bug 681104 - Add JSTracer flag to disable visiting WeakMap mappings. r=billm
This commit is contained in:
Родитель
8e90b142a0
Коммит
77e5d2474d
|
@ -1659,6 +1659,10 @@ JSVAL_TRACE_KIND(jsval v)
|
||||||
* internal implementation-specific traversal kind. In the latter case the only
|
* internal implementation-specific traversal kind. In the latter case the only
|
||||||
* operations on thing that the callback can do is to call JS_TraceChildren or
|
* operations on thing that the callback can do is to call JS_TraceChildren or
|
||||||
* DEBUG-only JS_PrintTraceThingInfo.
|
* DEBUG-only JS_PrintTraceThingInfo.
|
||||||
|
*
|
||||||
|
* If eagerlyTraceWeakMaps is true, when we trace a WeakMap visit all
|
||||||
|
* of its mappings. This should be used in cases where the tracer
|
||||||
|
* wants to use the existing liveness of entries.
|
||||||
*/
|
*/
|
||||||
typedef void
|
typedef void
|
||||||
(* JSTraceCallback)(JSTracer *trc, void *thing, JSGCTraceKind kind);
|
(* JSTraceCallback)(JSTracer *trc, void *thing, JSGCTraceKind kind);
|
||||||
|
@ -1669,6 +1673,7 @@ struct JSTracer {
|
||||||
JSTraceNamePrinter debugPrinter;
|
JSTraceNamePrinter debugPrinter;
|
||||||
const void *debugPrintArg;
|
const void *debugPrintArg;
|
||||||
size_t debugPrintIndex;
|
size_t debugPrintIndex;
|
||||||
|
JSBool eagerlyTraceWeakMaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1768,6 +1773,7 @@ JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
|
||||||
(trc)->debugPrinter = NULL; \
|
(trc)->debugPrinter = NULL; \
|
||||||
(trc)->debugPrintArg = NULL; \
|
(trc)->debugPrintArg = NULL; \
|
||||||
(trc)->debugPrintIndex = (size_t)-1; \
|
(trc)->debugPrintIndex = (size_t)-1; \
|
||||||
|
(trc)->eagerlyTraceWeakMaps = JS_TRUE; \
|
||||||
JS_END_MACRO
|
JS_END_MACRO
|
||||||
|
|
||||||
extern JS_PUBLIC_API(void)
|
extern JS_PUBLIC_API(void)
|
||||||
|
|
|
@ -1555,6 +1555,12 @@ GCMarker::GCMarker(JSContext *cx)
|
||||||
conservativeDumpFileName = getenv("JS_DUMP_CONSERVATIVE_GC_ROOTS");
|
conservativeDumpFileName = getenv("JS_DUMP_CONSERVATIVE_GC_ROOTS");
|
||||||
memset(&conservativeStats, 0, sizeof(conservativeStats));
|
memset(&conservativeStats, 0, sizeof(conservativeStats));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The GC is recomputing the liveness of WeakMap entries, so we
|
||||||
|
* delay visting entries.
|
||||||
|
*/
|
||||||
|
eagerlyTraceWeakMaps = JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCMarker::~GCMarker()
|
GCMarker::~GCMarker()
|
||||||
|
@ -1579,7 +1585,7 @@ GCMarker::delayMarkingChildren(const void *thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
MarkDelayedChildren(JSTracer *trc, Arena *a)
|
MarkDelayedChildren(GCMarker *trc, Arena *a)
|
||||||
{
|
{
|
||||||
AllocKind allocKind = a->aheader.getAllocKind();
|
AllocKind allocKind = a->aheader.getAllocKind();
|
||||||
JSGCTraceKind traceKind = MapAllocToTraceKind(allocKind);
|
JSGCTraceKind traceKind = MapAllocToTraceKind(allocKind);
|
||||||
|
|
|
@ -144,6 +144,7 @@ class WeakMapBase {
|
||||||
// many keys as possible have been marked, and add ourselves to the list of
|
// many keys as possible have been marked, and add ourselves to the list of
|
||||||
// known-live WeakMaps to be scanned in the iterative marking phase, by
|
// known-live WeakMaps to be scanned in the iterative marking phase, by
|
||||||
// markAllIteratively.
|
// markAllIteratively.
|
||||||
|
JS_ASSERT(!tracer->eagerlyTraceWeakMaps);
|
||||||
JSRuntime *rt = tracer->context->runtime;
|
JSRuntime *rt = tracer->context->runtime;
|
||||||
next = rt->gcWeakMapList;
|
next = rt->gcWeakMapList;
|
||||||
rt->gcWeakMapList = this;
|
rt->gcWeakMapList = this;
|
||||||
|
@ -152,7 +153,8 @@ class WeakMapBase {
|
||||||
// nicely as needed by the true ephemeral marking algorithm --- custom tracers
|
// nicely as needed by the true ephemeral marking algorithm --- custom tracers
|
||||||
// must use their own means for cycle detection. So here we do a conservative
|
// must use their own means for cycle detection. So here we do a conservative
|
||||||
// approximation: pretend all keys are live.
|
// approximation: pretend all keys are live.
|
||||||
nonMarkingTrace(tracer);
|
if (tracer->eagerlyTraceWeakMaps)
|
||||||
|
nonMarkingTrace(tracer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -880,6 +880,10 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
|
||||||
TraversalTracer trc(cb);
|
TraversalTracer trc(cb);
|
||||||
|
|
||||||
JS_TRACER_INIT(&trc, cx, NoteJSChild);
|
JS_TRACER_INIT(&trc, cx, NoteJSChild);
|
||||||
|
// When WeakMaps are properly integrated with the cycle
|
||||||
|
// collector in Bug 668855, don't eagerly trace weak maps when
|
||||||
|
// building the cycle collector graph.
|
||||||
|
// trc.eagerlyTraceWeakMaps = JS_FALSE;
|
||||||
JS_TraceChildren(&trc, p, traceKind);
|
JS_TraceChildren(&trc, p, traceKind);
|
||||||
|
|
||||||
if(traceKind != JSTRACE_OBJECT || dontTraverse)
|
if(traceKind != JSTRACE_OBJECT || dontTraverse)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче