Bug 1199843 - Part 1: Prefer T::traceChildren over tag dispatched TraceChildren; r=jonco

This commit is contained in:
Terrence Cole 2015-08-28 16:21:16 -07:00
parent 1e07994b39
commit c0c676b7ac

View File

@ -2591,40 +2591,51 @@ UnmarkGrayTracer::onChild(const JS::GCCellPtr& thing)
do {
MOZ_ASSERT(!shape->isMarked(js::gc::GRAY));
TraceChildren(&childTracer, shape, JS::TraceKind::Shape);
shape->traceChildren(&childTracer);
shape = childTracer.previousShape;
childTracer.previousShape = nullptr;
} while (shape);
unmarkedAny |= childTracer.unmarkedAny;
}
bool
js::UnmarkGrayCellRecursively(gc::Cell* cell, JS::TraceKind kind)
template <typename T>
static bool
TypedUnmarkGrayCellRecursively(T* t)
{
MOZ_ASSERT(cell);
MOZ_ASSERT(t);
JSRuntime* rt = cell->runtimeFromMainThread();
JSRuntime* rt = t->runtimeFromMainThread();
MOZ_ASSERT(!rt->isHeapBusy());
bool unmarkedArg = false;
if (cell->isTenured()) {
if (!cell->asTenured().isMarked(GRAY))
if (t->isTenured()) {
if (!t->asTenured().isMarked(GRAY))
return false;
cell->asTenured().unmark(GRAY);
t->asTenured().unmark(GRAY);
unmarkedArg = true;
}
UnmarkGrayTracer trc(rt);
TraceChildren(&trc, cell, kind);
t->traceChildren(&trc);
return unmarkedArg || trc.unmarkedAny;
}
struct UnmarkGrayCellRecursivelyFunctor {
template <typename T> bool operator()(T* t) { return TypedUnmarkGrayCellRecursively(t); }
};
bool
js::UnmarkGrayCellRecursively(Cell* cell, JS::TraceKind kind)
{
return DispatchTraceKindTyped(UnmarkGrayCellRecursivelyFunctor(), cell, kind);
}
bool
js::UnmarkGrayShapeRecursively(Shape* shape)
{
return js::UnmarkGrayCellRecursively(shape, JS::TraceKind::Shape);
return TypedUnmarkGrayCellRecursively(shape);
}
JS_FRIEND_API(bool)