Bug 1187985 - Make PersistentRooted use rootKind to find its lists; r=sfink

This commit is contained in:
Terrence Cole 2015-07-23 08:19:08 -07:00
parent 28032343dd
commit e72c3891fc
3 changed files with 42 additions and 31 deletions

View File

@ -320,17 +320,16 @@ struct PersistentRootedMarker
void
js::gc::MarkPersistentRootedChainsInLists(RootLists& roots, JSTracer* trc)
{
PersistentRootedMarker<JSFunction*>::markChain(trc, roots.functionPersistentRooteds,
"PersistentRooted<JSFunction*>");
PersistentRootedMarker<JSObject*>::markChain(trc, roots.objectPersistentRooteds,
PersistentRootedMarker<JSObject*>::markChain(trc, roots.getPersistentRootedList<JSObject*>(),
"PersistentRooted<JSObject*>");
PersistentRootedMarker<JSScript*>::markChain(trc, roots.scriptPersistentRooteds,
PersistentRootedMarker<JSScript*>::markChain(trc, roots.getPersistentRootedList<JSScript*>(),
"PersistentRooted<JSScript*>");
PersistentRootedMarker<JSString*>::markChain(trc, roots.stringPersistentRooteds,
PersistentRootedMarker<JSString*>::markChain(trc, roots.getPersistentRootedList<JSString*>(),
"PersistentRooted<JSString*>");
PersistentRootedMarker<jsid>::markChain(trc, roots.idPersistentRooteds,
PersistentRootedMarker<jsid>::markChain(trc, roots.getPersistentRootedList<jsid>(),
"PersistentRooted<jsid>");
PersistentRootedMarker<Value>::markChain(trc, roots.valuePersistentRooteds,
PersistentRootedMarker<Value>::markChain(trc, roots.getPersistentRootedList<Value>(),
"PersistentRooted<Value>");
}

View File

@ -1366,12 +1366,11 @@ FinishPersistentRootedChain(mozilla::LinkedList<PersistentRooted<T>>& list)
void
js::gc::FinishPersistentRootedChains(RootLists& roots)
{
FinishPersistentRootedChain(roots.functionPersistentRooteds);
FinishPersistentRootedChain(roots.idPersistentRooteds);
FinishPersistentRootedChain(roots.objectPersistentRooteds);
FinishPersistentRootedChain(roots.scriptPersistentRooteds);
FinishPersistentRootedChain(roots.stringPersistentRooteds);
FinishPersistentRootedChain(roots.valuePersistentRooteds);
FinishPersistentRootedChain(roots.getPersistentRootedList<JSObject*>());
FinishPersistentRootedChain(roots.getPersistentRootedList<JSScript*>());
FinishPersistentRootedChain(roots.getPersistentRootedList<JSString*>());
FinishPersistentRootedChain(roots.getPersistentRootedList<jsid>());
FinishPersistentRootedChain(roots.getPersistentRootedList<Value>());
}
void

View File

@ -345,12 +345,7 @@ class RootLists
friend void js::gc::MarkPersistentRootedChainsInLists(RootLists&, JSTracer*);
friend void js::gc::FinishPersistentRootedChains(RootLists&);
mozilla::LinkedList<JS::PersistentRootedFunction> functionPersistentRooteds;
mozilla::LinkedList<JS::PersistentRootedId> idPersistentRooteds;
mozilla::LinkedList<JS::PersistentRootedObject> objectPersistentRooteds;
mozilla::LinkedList<JS::PersistentRootedScript> scriptPersistentRooteds;
mozilla::LinkedList<JS::PersistentRootedString> stringPersistentRooteds;
mozilla::LinkedList<JS::PersistentRootedValue> valuePersistentRooteds;
mozilla::LinkedList<JS::PersistentRooted<void*>> heapRoots_[THING_ROOT_LIMIT];
/* Specializations of this return references to the appropriate list. */
template<typename Referent>
@ -358,28 +353,46 @@ class RootLists
};
template<>
inline mozilla::LinkedList<JS::PersistentRootedFunction>
&RootLists::getPersistentRootedList<JSFunction*>() { return functionPersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedFunction>&
RootLists::getPersistentRootedList<JSFunction*>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<JSFunction*>>&>(
heapRoots_[THING_ROOT_OBJECT]);
}
template<>
inline mozilla::LinkedList<JS::PersistentRootedId>
&RootLists::getPersistentRootedList<jsid>() { return idPersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedObject>&
RootLists::getPersistentRootedList<JSObject*>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<JSObject*>>&>(
heapRoots_[THING_ROOT_OBJECT]);
}
template<>
inline mozilla::LinkedList<JS::PersistentRootedObject>
&RootLists::getPersistentRootedList<JSObject*>() { return objectPersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedId>&
RootLists::getPersistentRootedList<jsid>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<jsid>>&>(
heapRoots_[THING_ROOT_ID]);
}
template<>
inline mozilla::LinkedList<JS::PersistentRootedScript>
&RootLists::getPersistentRootedList<JSScript*>() { return scriptPersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedScript>&
RootLists::getPersistentRootedList<JSScript*>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<JSScript*>>&>(
heapRoots_[THING_ROOT_SCRIPT]);
}
template<>
inline mozilla::LinkedList<JS::PersistentRootedString>
&RootLists::getPersistentRootedList<JSString*>() { return stringPersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedString>&
RootLists::getPersistentRootedList<JSString*>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<JSString*>>&>(
heapRoots_[THING_ROOT_STRING]);
}
template<>
inline mozilla::LinkedList<JS::PersistentRootedValue>
&RootLists::getPersistentRootedList<JS::Value>() { return valuePersistentRooteds; }
inline mozilla::LinkedList<JS::PersistentRootedValue>&
RootLists::getPersistentRootedList<JS::Value>() {
return reinterpret_cast<mozilla::LinkedList<JS::PersistentRooted<JS::Value>>&>(
heapRoots_[THING_ROOT_VALUE]);
}
struct ContextFriendFields
{