Bug 1178976: Add a post-write barrier to ObjectWeakMap::add. r=terrence

This commit is contained in:
Jim Blandy 2015-06-30 13:47:01 -07:00
parent d950f33c64
commit c56cf91c4a
2 changed files with 3 additions and 2 deletions

View File

@ -345,8 +345,6 @@ TryPreserveReflector(JSContext* cx, HandleObject obj)
static inline void
WeakMapPostWriteBarrier(JSRuntime* rt, ObjectValueMap* weakMap, JSObject* key)
{
// 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(gc::HashKeyRef<ObjectValueMap, JSObject*>(weakMap, key));
}
@ -708,6 +706,8 @@ ObjectWeakMap::add(JSContext* cx, JSObject* obj, JSObject* target)
ReportOutOfMemory(cx);
return false;
}
if (IsInsideNursery(obj))
cx->runtime()->gc.storeBuffer.putGeneric(StoreBufferRef(&map, obj));
return true;
}

View File

@ -34,6 +34,7 @@ class ObjectWeakMap
{
private:
ObjectValueMap map;
typedef gc::HashKeyRef<ObjectValueMap, JSObject*> StoreBufferRef;
public:
explicit ObjectWeakMap(JSContext* cx);