Bug 949038 - Fix windows browser build error in jsweakmap.h with generational GC r=terrence

This commit is contained in:
Jon Coppeard
2013-12-12 11:21:59 +00:00
parent 2d82acadbc
commit fc5a4056da
2 changed files with 24 additions and 6 deletions

View File

@@ -269,17 +269,26 @@ TryPreserveReflector(JSContext *cx, HandleObject obj)
}
static inline void
WeakMapPostWriteBarrier(JSRuntime *rt, ObjectValueMap *map, JSObject *key)
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.
*/
typedef WeakMap<JSObject *, Value> UnbarrieredObjectValueMap;
typedef gc::HashKeyRef<UnbarrieredObjectValueMap, JSObject *> Ref;
ObjectValueMap::Base *baseHashMap = static_cast<ObjectValueMap::Base *>(weakMap);
typedef HashMap<JSObject *, Value> UnbarrieredMap;
UnbarrieredMap *unbarrieredMap = reinterpret_cast<UnbarrieredMap *>(baseHashMap);
typedef gc::HashKeyRef<UnbarrieredMap, JSObject *> Ref;
if (key && IsInsideNursery(rt, key))
rt->gcStoreBuffer.putGeneric(Ref(reinterpret_cast<UnbarrieredObjectValueMap *>(map), key));
rt->gcStoreBuffer.putGeneric(Ref((unbarrieredMap), key));
#endif
}