Bug 1335862 - Implement mayResolve for arguments objects. r=jandem

This commit is contained in:
Tom Schuster 2017-02-15 23:24:44 +01:00
parent 60a646160e
commit 799aa36a27
2 changed files with 19 additions and 2 deletions

View File

@ -430,6 +430,21 @@ ArgumentsObject::obj_delProperty(JSContext* cx, HandleObject obj, HandleId id,
return result.succeed();
}
/* static */ bool
ArgumentsObject::obj_mayResolve(const JSAtomState& names, jsid id, JSObject*)
{
// Arguments might resolve indexes or Symbol.iterator.
if (!JSID_IS_ATOM(id))
return true;
JSAtom* atom = JSID_TO_ATOM(id);
uint32_t index;
if (atom->isIndex(&index))
return true;
return atom == names.length || atom == names.callee;
}
static bool
MappedArgGetter(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp)
{
@ -854,7 +869,7 @@ const ClassOps MappedArgumentsObject::classOps_ = {
nullptr, /* setProperty */
MappedArgumentsObject::obj_enumerate,
MappedArgumentsObject::obj_resolve,
nullptr, /* mayResolve */
ArgumentsObject::obj_mayResolve,
ArgumentsObject::finalize,
nullptr, /* call */
nullptr, /* hasInstance */
@ -891,7 +906,7 @@ const ClassOps UnmappedArgumentsObject::classOps_ = {
nullptr, /* setProperty */
UnmappedArgumentsObject::obj_enumerate,
UnmappedArgumentsObject::obj_resolve,
nullptr, /* mayResolve */
ArgumentsObject::obj_mayResolve,
ArgumentsObject::finalize,
nullptr, /* call */
nullptr, /* hasInstance */

View File

@ -185,6 +185,8 @@ class ArgumentsObject : public NativeObject
static bool obj_delProperty(JSContext* cx, HandleObject obj, HandleId id,
ObjectOpResult& result);
static bool obj_mayResolve(const JSAtomState& names, jsid id, JSObject*);
public:
static const uint32_t RESERVED_SLOTS = 4;
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;