Bug 1037313 - Fix bogus assertion with watchpoint and symbol. r=jwalden.

--HG--
extra : rebase_source : c98771c4124712255a9de8282c9658219631ca06
This commit is contained in:
Jason Orendorff 2014-07-18 23:34:56 -05:00
Родитель 6f4818d737
Коммит acc12063b9
2 изменённых файлов: 32 добавлений и 3 удалений

Просмотреть файл

@ -0,0 +1,27 @@
// test against future pic support for symbols
// assignments to watched objects must not be cached
var obj = {};
var x = Symbol.for("x");
obj[x] = 0;
var hits = 0;
obj.watch(x, function (id, oldval, newval) { hits++; return newval; });
for (var i = 0; i < 10; i++)
obj[x] = i;
assertEq(hits, 10);
// assignments to watched properties via ++ must not be cached
hits = 0;
for (var i = 0; i < 10; i++)
obj[x]++;
assertEq(hits, 10);
// adding assignment + watchpoint vs. caching
hits = 0;
obj = {};
obj.watch(x, function (id, oldval, newval) { hits++; return newval; });
for (var i = 0; i < 10; i++) {
obj[x] = 1;
delete obj[x];
}
assertEq(hits, 10);

Просмотреть файл

@ -61,7 +61,7 @@ bool
WatchpointMap::watch(JSContext *cx, HandleObject obj, HandleId id,
JSWatchPointHandler handler, HandleObject closure)
{
JS_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id));
JS_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id) || JSID_IS_SYMBOL(id));
if (!obj->setWatched(cx))
return false;
@ -168,7 +168,9 @@ WatchpointMap::markIteratively(JSTracer *trc)
marked = true;
}
JS_ASSERT(JSID_IS_STRING(priorKeyId) || JSID_IS_INT(priorKeyId));
JS_ASSERT(JSID_IS_STRING(priorKeyId) ||
JSID_IS_INT(priorKeyId) ||
JSID_IS_SYMBOL(priorKeyId));
MarkId(trc, const_cast<PreBarrieredId *>(&entry.key().id), "WatchKey::id");
if (entry.value().closure && !IsObjectMarked(&entry.value().closure)) {
@ -191,7 +193,7 @@ WatchpointMap::markAll(JSTracer *trc)
Map::Entry &entry = e.front();
WatchKey key = entry.key();
WatchKey prior = key;
JS_ASSERT(JSID_IS_STRING(prior.id) || JSID_IS_INT(prior.id));
JS_ASSERT(JSID_IS_STRING(prior.id) || JSID_IS_INT(prior.id) || JSID_IS_SYMBOL(prior.id));
MarkObject(trc, const_cast<PreBarrieredObject *>(&key.object),
"held Watchpoint object");