Bug 1088307 - Pull out WeakMap unbarriering to a single location, r=terrence
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user