Bug 792944 - Idempotent caches should reject singleton properties that require monitoring. r=dvander

This commit is contained in:
Jan de Mooij 2012-09-25 16:16:46 +02:00
Родитель 43c5c49691
Коммит 5d62355423
2 изменённых файлов: 25 добавлений и 0 удалений

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

@ -278,6 +278,18 @@ TryAttachNativeStub(JSContext *cx, IonCacheGetProperty &cache, HandleObject obj,
if (!IsCacheableGetProp(obj, holder, shape))
return true;
// TI infers the possible types of native object properties. There's one
// edge case though: for singleton objects it does not add the initial
// "undefined" type, see the propertySet comment in jsinfer.h. We can't
// monitor the return type inside an idempotent cache though, so we don't
// handle this case.
if (cache.idempotent() &&
holder->hasSingletonType() &&
holder->getSlot(shape->slot()).isUndefined())
{
return true;
}
*isCacheableNative = true;
if (cache.stubCount() < MAX_STUBS) {

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

@ -0,0 +1,13 @@
function whoo() {
(new Object()).foo()
}
Object.prototype.foo = function() { return undefined };
whoo();
Object.prototype.foo = undefined;
gc();
try {
whoo();
assertEq(0, 1);
} catch(e) {
assertEq(e instanceof TypeError, true);
}