Bug 1088307 - Pull out WeakMap unbarriering to a single location, r=terrence

This commit is contained in:
Steve Fink
2014-10-27 14:11:31 -07:00
parent b3d01af48a
commit f9c90a3a36
3 changed files with 27 additions and 32 deletions

View File

@@ -352,23 +352,10 @@ static inline void
WeakMapPostWriteBarrier(JSRuntime *rt, ObjectValueMap *weakMap, JSObject *key)
{
#ifdef JSGC_GENERATIONAL
/*
* Strip the barriers from the type before inserting into the store buffer.
* This will automatically ensure that barriers do not fire during GC.
*
* Some compilers complain about instantiating the WeakMap class for
* unbarriered type arguments, so we cast to a HashMap instead. Because of
* WeakMap's multiple inheritace, We need to do this in two stages, first to
* the HashMap base class and then to the unbarriered version.
*/
ObjectValueMap::Base *baseHashMap = static_cast<ObjectValueMap::Base *>(weakMap);
typedef HashMap<JSObject *, Value> UnbarrieredMap;
UnbarrieredMap *unbarrieredMap = reinterpret_cast<UnbarrieredMap *>(baseHashMap);
typedef HashKeyRef<UnbarrieredMap, JSObject *> Ref;
// Strip the barriers from the type before inserting into the store buffer.
// This will automatically ensure that barriers do not fire during GC.
if (key && IsInsideNursery(key))
rt->gc.storeBuffer.putGeneric(Ref((unbarrieredMap), key));
rt->gc.storeBuffer.putGeneric(UnbarrieredRef(weakMap, key));
#endif
}