diff --git a/js/public/HeapAPI.h b/js/public/HeapAPI.h index 836a29c583..835068c4df 100644 --- a/js/public/HeapAPI.h +++ b/js/public/HeapAPI.h @@ -74,9 +74,7 @@ const size_t ArenaHeaderSize = sizeof(size_t) + 2 * sizeof(uintptr_t) + * depends on the size of the GCThing. Objects marked gray are eligible for * cycle collection. */ -static const uint32_t BLACK = 0; -static const uint32_t GRAY = 1; - + /* * Two bits determine the mark color as follows: * BlackBit GrayOrBlackBit color diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 2dc6ef311f..c28e4a6629 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -622,7 +622,7 @@ struct VisitGrayCallbackFunctor { template void operator()(T tp) const { - if ((*tp)->isTenured() && (*tp)->asTenured().isMarkedGray()) + if ((*tp)->isMarkedGray()) callback_(closure_, JS::GCCellPtr(*tp)); } }; @@ -1083,10 +1083,13 @@ static char MarkDescriptor(void* thing) { gc::TenuredCell* cell = gc::TenuredCell::fromPointer(thing); + if (cell->isMarkedBlack()) + return 'B'; + if (cell->isMarkedGray()) + return 'G'; if (cell->isMarkedAny()) - return cell->isMarkedGray() ? 'G' : 'B'; - else - return cell->isMarkedGray() ? 'X' : 'W'; + return 'X'; + return 'W'; } static void diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 9fdb9bc45b..77105a17ec 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -2009,7 +2009,7 @@ RelocateArena(Arena* arena, SliceBudget& sliceBudget) TenuredCell* src = i.getCell(); MOZ_ASSERT(RelocationOverlay::isCellForwarded(src)); TenuredCell* dest = Forwarded(src); - MOZ_ASSERT(src->isMarkedAny() == dest->isMarkedAny()); + MOZ_ASSERT(src->isMarkedBlack() == dest->isMarkedBlack()); MOZ_ASSERT(src->isMarkedGray() == dest->isMarkedGray()); } #endif @@ -4452,7 +4452,7 @@ js::gc::MarkingValidator::validate() uintptr_t thing = arena->thingsStart(); uintptr_t end = arena->thingsEnd(); while (thing < end) { - Cell* cell = (Cell*)thing; + auto cell = reinterpret_cast(thing); /* * If a non-incremental GC wouldn't have collected a cell, then @@ -4572,7 +4572,7 @@ JSCompartment::findOutgoingEdges(ZoneComponentFinder& finder) bool needsEdge = true; if (key.is()) { TenuredCell& other = key.as()->asTenured(); - needsEdge = !other.isMarkedAny() || other.isMarkedGray(); + needsEdge = !other.isMarkedBlack(); } key.applyToWrapped(AddOutgoingEdgeFunctor(needsEdge, finder)); } @@ -4815,21 +4815,22 @@ js::gc::DelayCrossCompartmentGrayMarking(JSObject* src) } static void -MarkIncomingCrossCompartmentPointers(JSRuntime* rt, const uint32_t color) +MarkIncomingCrossCompartmentPointers(JSRuntime* rt, MarkColor color) { - MOZ_ASSERT(color == BLACK || color == GRAY); + MOZ_ASSERT(color == MarkColor::Black || color == MarkColor::Gray); static const gcstats::Phase statsPhases[] = { gcstats::PHASE_SWEEP_MARK_INCOMING_BLACK, gcstats::PHASE_SWEEP_MARK_INCOMING_GRAY }; - gcstats::AutoPhase ap1(rt->gc.stats, statsPhases[color]); - bool unlinkList = color == GRAY; + gcstats::AutoPhase ap1(rt->gc.stats(), statsPhases[unsigned(color)]); + + bool unlinkList = color == MarkColor::Gray; for (SweepGroupCompartmentsIter c(rt); !c.done(); c.next()) { - MOZ_ASSERT_IF(color == GRAY, c->zone()->isGCMarkingGray()); - MOZ_ASSERT_IF(color == BLACK, c->zone()->isGCMarkingBlack()); + MOZ_ASSERT_IF(color == MarkColor::Gray, c->zone()->isGCMarkingGray()); + MOZ_ASSERT_IF(color == MarkColor::Black, c->zone()->isGCMarkingBlack()); MOZ_ASSERT_IF(c->gcIncomingGrayPointers, IsGrayListObject(c->gcIncomingGrayPointers)); for (JSObject* src = c->gcIncomingGrayPointers; @@ -4839,7 +4840,7 @@ MarkIncomingCrossCompartmentPointers(JSRuntime* rt, const uint32_t color) JSObject* dst = CrossCompartmentPointerReferent(src); MOZ_ASSERT(dst->compartment() == c); - if (color == GRAY) { + if (color == MarkColor::Gray) { if (IsMarkedUnbarriered(rt, &src) && src->asTenured().isMarkedGray()) TraceManuallyBarrieredEdge(&rt->gc.marker, &dst, "cross-compartment gray pointer"); @@ -4950,7 +4951,7 @@ GCRuntime::endMarkingSweepGroup(FreeOp* fop, SliceBudget& budget) * whose referents are not marked. This can occur when gray cells become * black by the action of UnmarkGray. */ - MarkIncomingCrossCompartmentPointers(rt, BLACK); + MarkIncomingCrossCompartmentPointers(rt, MarkColor::Black); markWeakReferencesInCurrentGroup(gcstats::PHASE_SWEEP_MARK_WEAK); /* @@ -4966,7 +4967,7 @@ GCRuntime::endMarkingSweepGroup(FreeOp* fop, SliceBudget& budget) marker.setMarkColorGray(); /* Mark incoming gray pointers from previously swept compartments. */ - MarkIncomingCrossCompartmentPointers(rt, GRAY); + MarkIncomingCrossCompartmentPointers(rt, MarkColor::Gray); /* Mark gray roots and mark transitively inside the current compartment group. */ markGrayReferencesInCurrentGroup(gcstats::PHASE_SWEEP_MARK_GRAY); @@ -7199,7 +7200,7 @@ GCRuntime::maybeDoCycleCollection() for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { ++compartmentsTotal; GlobalObject* global = c->unsafeUnbarrieredMaybeGlobal(); - if (global && global->asTenured().isMarkedGray()) + if (global && global->isMarkedGray()) ++compartmentsGray; } double grayFraction = double(compartmentsGray) / double(compartmentsTotal); diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index c219c37571..ea5e96efa4 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -3419,7 +3419,7 @@ js::detail::CopyScript(JSContext* cx, HandleScript src, HandleScript dst, /* NB: Keep this in sync with XDRScript. */ /* Some embeddings are not careful to use ExposeObjectToActiveJS as needed. */ - MOZ_ASSERT(!src->sourceObject()->asTenured().isMarkedGray()); + MOZ_ASSERT(!src->sourceObject()->isMarkedGray()); uint32_t nconsts = src->hasConsts() ? src->consts()->length : 0; uint32_t nobjects = src->hasObjects() ? src->objects()->length : 0; diff --git a/js/src/jsweakmap.cpp b/js/src/jsweakmap.cpp index 14ac3549bc..435dfaf6fa 100644 --- a/js/src/jsweakmap.cpp +++ b/js/src/jsweakmap.cpp @@ -137,7 +137,7 @@ ObjectValueMap::findZoneEdges() JS::AutoSuppressGCAnalysis nogc; for (Range r = all(); !r.empty(); r.popFront()) { JSObject* key = r.front().key(); - if (key->asTenured().isMarkedAny() && !key->asTenured().isMarkedGray()) + if (key->asTenured().isMarkedBlack()) continue; JSObject* delegate = getDelegate(key); if (!delegate) diff --git a/js/src/proxy/Wrapper.cpp b/js/src/proxy/Wrapper.cpp index 0121b4f496..d6ba505baa 100644 --- a/js/src/proxy/Wrapper.cpp +++ b/js/src/proxy/Wrapper.cpp @@ -335,7 +335,7 @@ Wrapper::wrappedObject(JSObject* wrapper) // of black wrappers black but while it is in progress we can observe gray // targets. Expose rather than returning a gray object in this case. if (target) { - if (wrapper->isMarkedAny() && !wrapper->isMarkedGray()) + if (wrapper->isMarkedBlack()) MOZ_ASSERT(JS::ObjectIsNotGray(target)); if (!wrapper->isMarkedGray()) JS::ExposeObjectToActiveJS(target);