Bug 1447391 - Early return for strings and symbols when tracing for CC, r=mccr8

This commit is contained in:
Steve Fink
2018-03-20 10:54:29 -07:00
parent 685177a806
commit 3674e7d3d1

View File

@@ -407,6 +407,12 @@ struct TraversalTracer : public JS::CallbackTracer
void
TraversalTracer::onChild(const JS::GCCellPtr& aThing)
{
// Checking strings and symbols for being gray is rather slow, and we don't
// need either of them for the cycle collector.
if (aThing.is<JSString>() || aThing.is<JS::Symbol>()) {
return;
}
// Don't traverse non-gray objects, unless we want all traces.
if (!JS::GCThingIsMarkedGray(aThing) && !mCb.WantAllTraces()) {
return;
@@ -435,7 +441,7 @@ TraversalTracer::onChild(const JS::GCCellPtr& aThing)
// due to information attached to the groups which can lead other groups to
// be traced.
JS_TraceObjectGroupCycleCollectorChildren(this, aThing);
} else if (!aThing.is<JSString>()) {
} else {
JS::TraceChildren(this, aThing);
}
}