зеркало из 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
|
||||
* operations on thing that the callback can do is to call JS_TraceChildren or
|
||||
* 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
|
||||
(* JSTraceCallback)(JSTracer *trc, void *thing, JSGCTraceKind kind);
|
||||
|
@ -1669,6 +1673,7 @@ struct JSTracer {
|
|||
JSTraceNamePrinter debugPrinter;
|
||||
const void *debugPrintArg;
|
||||
size_t debugPrintIndex;
|
||||
JSBool eagerlyTraceWeakMaps;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1768,6 +1773,7 @@ JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
|
|||
(trc)->debugPrinter = NULL; \
|
||||
(trc)->debugPrintArg = NULL; \
|
||||
(trc)->debugPrintIndex = (size_t)-1; \
|
||||
(trc)->eagerlyTraceWeakMaps = JS_TRUE; \
|
||||
JS_END_MACRO
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
|
|
|
@ -1555,6 +1555,12 @@ GCMarker::GCMarker(JSContext *cx)
|
|||
conservativeDumpFileName = getenv("JS_DUMP_CONSERVATIVE_GC_ROOTS");
|
||||
memset(&conservativeStats, 0, sizeof(conservativeStats));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The GC is recomputing the liveness of WeakMap entries, so we
|
||||
* delay visting entries.
|
||||
*/
|
||||
eagerlyTraceWeakMaps = JS_FALSE;
|
||||
}
|
||||
|
||||
GCMarker::~GCMarker()
|
||||
|
@ -1579,7 +1585,7 @@ GCMarker::delayMarkingChildren(const void *thing)
|
|||
}
|
||||
|
||||
static void
|
||||
MarkDelayedChildren(JSTracer *trc, Arena *a)
|
||||
MarkDelayedChildren(GCMarker *trc, Arena *a)
|
||||
{
|
||||
AllocKind allocKind = a->aheader.getAllocKind();
|
||||
JSGCTraceKind traceKind = MapAllocToTraceKind(allocKind);
|
||||
|
|
|
@ -144,6 +144,7 @@ class WeakMapBase {
|
|||
// 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
|
||||
// markAllIteratively.
|
||||
JS_ASSERT(!tracer->eagerlyTraceWeakMaps);
|
||||
JSRuntime *rt = tracer->context->runtime;
|
||||
next = rt->gcWeakMapList;
|
||||
rt->gcWeakMapList = this;
|
||||
|
@ -152,6 +153,7 @@ class WeakMapBase {
|
|||
// 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
|
||||
// approximation: pretend all keys are live.
|
||||
if (tracer->eagerlyTraceWeakMaps)
|
||||
nonMarkingTrace(tracer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,6 +880,10 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
|
|||
TraversalTracer trc(cb);
|
||||
|
||||
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);
|
||||
|
||||
if(traceKind != JSTRACE_OBJECT || dontTraverse)
|
||||
|
|
Загрузка…
Ссылка в новой задаче