Bug 924690 - Remove unnecessary post-barriering of watchpoint hash table r=terrence

This commit is contained in:
Jon Coppeard 2013-10-10 10:28:17 +01:00
parent b2f69acb8e
commit b9b5b047df
2 changed files with 31 additions and 27 deletions

View File

@ -0,0 +1,25 @@
x = []
try {
(function() {
schedulegc(1);
((function() {
return {
y: function() {
u() = []
}
}
})())
})()
watch.call(x, "valueOf", function() {})
gc()
} catch (e) { print(e); }
try {
(function() {
x.valueOf =
(function() {
y();
})
})()
x + 2
print('foo')
} catch (e) { print(e); }

View File

@ -81,31 +81,6 @@ WatchpointMap::init()
return map.init();
}
#ifdef JSGC_GENERATIONAL
void
Mark(JSTracer *trc, WatchKey *key, const char *name)
{
MarkId(trc, &key->id, "WatchKey id");
MarkObject(trc, &key->object, "WatchKey id");
}
#endif
static void
WatchpointWriteBarrierPost(JSRuntime *rt, WatchpointMap::Map *map, const WatchKey &key,
const WatchpointStackValue &val)
{
#ifdef JSGC_GENERATIONAL
if ((JSID_IS_OBJECT(key.id) && IsInsideNursery(rt, JSID_TO_OBJECT(key.id))) ||
(JSID_IS_STRING(key.id) && IsInsideNursery(rt, JSID_TO_STRING(key.id))) ||
IsInsideNursery(rt, key.object) ||
IsInsideNursery(rt, val.closure))
{
typedef HashKeyRef<WatchpointMap::Map, WatchKey> WatchKeyRef;
rt->gcStoreBuffer.putGeneric(WatchKeyRef(map, key));
}
#endif
}
bool
WatchpointMap::watch(JSContext *cx, HandleObject obj, HandleId id,
JSWatchPointHandler handler, HandleObject closure)
@ -120,7 +95,11 @@ WatchpointMap::watch(JSContext *cx, HandleObject obj, HandleId id,
js_ReportOutOfMemory(cx);
return false;
}
WatchpointWriteBarrierPost(cx->runtime(), &map, WatchKey(obj, id), w);
/*
* For generational GC, we don't need to post-barrier writes to the
* hashtable here because we mark all watchpoints as part of root marking in
* markAll().
*/
return true;
}
@ -243,7 +222,7 @@ WatchpointMap::markAll(JSTracer *trc)
MarkObject(trc, &entry.value.closure, "Watchpoint::closure");
if (prior.object != key.object || prior.id != key.id)
e.rekeyFront(prior, key);
e.rekeyFront(key);
}
}