Bug 899970 - Post barrier heap pointers in js/ipc r=terrence

This commit is contained in:
Jon Coppeard
2013-08-01 11:21:44 +01:00
parent 85dad092cb
commit c8ebdc1978
3 changed files with 26 additions and 8 deletions

View File

@@ -29,9 +29,9 @@ void
ObjectStore::trace(JSTracer *trc)
{
for (ObjectTable::Range r(table_.all()); !r.empty(); r.popFront()) {
JSObject *obj = r.front().value;
JS_CallObjectTracer(trc, &obj, "ipc-object");
MOZ_ASSERT(obj == r.front().value);
DebugOnly<JSObject *> prior = r.front().value.get();
JS_CallHeapObjectTracer(trc, &r.front().value, "ipc-object");
MOZ_ASSERT(r.front().value == prior);
}
}
@@ -87,9 +87,25 @@ ObjectIdCache::find(JSObject *obj)
}
bool
ObjectIdCache::add(JSObject *obj, ObjectId id)
ObjectIdCache::add(JSContext *cx, JSObject *obj, ObjectId id)
{
return table_.put(obj, id);
if (!table_.put(obj, id))
return false;
JS_StoreObjectPostBarrierCallback(cx, keyMarkCallback, obj, this);
return true;
}
/*
* This function is called during minor GCs for each key in the HashMap that has
* been moved.
*/
/* static */ void
ObjectIdCache::keyMarkCallback(JSTracer *trc, void *k, void *d) {
JSObject *key = static_cast<JSObject*>(k);
ObjectIdCache* self = static_cast<ObjectIdCache*>(d);
JSObject *prior = key;
JS_CallObjectTracer(trc, &key, "ObjectIdCache::table_ key");
self->table_.rekey(prior, key);
}
void