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 { do {
MOZ_ASSERT(!shape->isMarked(js::gc::GRAY)); MOZ_ASSERT(!shape->isMarked(js::gc::GRAY));
TraceChildren(&childTracer, shape, JS::TraceKind::Shape); shape->traceChildren(&childTracer);
shape = childTracer.previousShape; shape = childTracer.previousShape;
childTracer.previousShape = nullptr; childTracer.previousShape = nullptr;
} while (shape); } while (shape);
unmarkedAny |= childTracer.unmarkedAny; unmarkedAny |= childTracer.unmarkedAny;
} }
bool template <typename T>
js::UnmarkGrayCellRecursively(gc::Cell* cell, JS::TraceKind kind) static bool
TypedUnmarkGrayCellRecursively(T* t)
{ {
MOZ_ASSERT(cell); MOZ_ASSERT(t);
JSRuntime* rt = cell->runtimeFromMainThread(); JSRuntime* rt = t->runtimeFromMainThread();
MOZ_ASSERT(!rt->isHeapBusy()); MOZ_ASSERT(!rt->isHeapBusy());
bool unmarkedArg = false; bool unmarkedArg = false;
if (cell->isTenured()) { if (t->isTenured()) {
if (!cell->asTenured().isMarked(GRAY)) if (!t->asTenured().isMarked(GRAY))
return false; return false;
cell->asTenured().unmark(GRAY); t->asTenured().unmark(GRAY);
unmarkedArg = true; unmarkedArg = true;
} }
UnmarkGrayTracer trc(rt); UnmarkGrayTracer trc(rt);
TraceChildren(&trc, cell, kind); t->traceChildren(&trc);
return unmarkedArg || trc.unmarkedAny; 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 bool
js::UnmarkGrayShapeRecursively(Shape* shape) js::UnmarkGrayShapeRecursively(Shape* shape)
{ {
return js::UnmarkGrayCellRecursively(shape, JS::TraceKind::Shape); return TypedUnmarkGrayCellRecursively(shape);
} }
JS_FRIEND_API(bool) JS_FRIEND_API(bool)