Commit abd19c97 authored by Paul Bone's avatar Paul Bone
Browse files

Bug 1341752 - Assert that thing has correct runtime in js::TraceChildren. r=jonco

parent 0b39451a
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -157,23 +157,22 @@ IsMovingTracer(JSTracer *trc)
}
#endif

template <typename T> bool ThingIsPermanentAtomOrWellKnownSymbol(T* thing) { return false; }
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<JSString>(JSString* str) {
bool ThingIsPermanentAtomOrWellKnownSymbol(JSString* str) {
    return str->isPermanentAtom();
}
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<JSFlatString>(JSFlatString* str) {
bool ThingIsPermanentAtomOrWellKnownSymbol(JSFlatString* str) {
    return str->isPermanentAtom();
}
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<JSLinearString>(JSLinearString* str) {
bool ThingIsPermanentAtomOrWellKnownSymbol(JSLinearString* str) {
    return str->isPermanentAtom();
}
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<JSAtom>(JSAtom* atom) {
bool ThingIsPermanentAtomOrWellKnownSymbol(JSAtom* atom) {
    return atom->isPermanent();
}
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<PropertyName>(PropertyName* name) {
bool ThingIsPermanentAtomOrWellKnownSymbol(PropertyName* name) {
    return name->isPermanent();
}
template <> bool ThingIsPermanentAtomOrWellKnownSymbol<JS::Symbol>(JS::Symbol* sym) {
bool ThingIsPermanentAtomOrWellKnownSymbol(JS::Symbol* sym) {
    return sym->isWellKnownSymbol();
}

+13 −0
Original line number Diff line number Diff line
@@ -502,4 +502,17 @@ CheckTracedThing(JSTracer* trc, T thing);

} /* namespace js */

namespace JS {
class Symbol;
}

// Exported for Tracer.cpp
inline bool ThingIsPermanentAtomOrWellKnownSymbol(js::gc::Cell* thing) { return false; }
bool ThingIsPermanentAtomOrWellKnownSymbol(JSString*);
bool ThingIsPermanentAtomOrWellKnownSymbol(JSFlatString*);
bool ThingIsPermanentAtomOrWellKnownSymbol(JSLinearString*);
bool ThingIsPermanentAtomOrWellKnownSymbol(JSAtom*);
bool ThingIsPermanentAtomOrWellKnownSymbol(js::PropertyName*);
bool ThingIsPermanentAtomOrWellKnownSymbol(JS::Symbol*);

#endif /* gc_Marking_h */
+7 −2
Original line number Diff line number Diff line
@@ -113,8 +113,13 @@ JS::TraceChildren(JSTracer* trc, GCCellPtr thing)

struct TraceChildrenFunctor {
    template <typename T>
    void operator()(JSTracer* trc, void* thing) {
        static_cast<T*>(thing)->traceChildren(trc);
    void operator()(JSTracer* trc, void* thingArg) {
        T* thing = static_cast<T*>(thingArg);
        MOZ_ASSERT_IF(thing->runtimeFromAnyThread() != trc->runtime(),
            ThingIsPermanentAtomOrWellKnownSymbol(thing) ||
            thing->zoneFromAnyThread()->isSelfHostingZone());

        thing->traceChildren(trc);
    }
};