Bug 686582 - Begin to specialize ObjectOps::getElementAttributes to not just delegate to ObjectOps::getAttributes. r=dvander

--HG--
extra : rebase_source : a3767fed5456d13c5ee5b6a8617fa22e064c758c
This commit is contained in:
Jeff Walden 2011-08-10 14:54:52 -07:00
Родитель e96d878fa9
Коммит a237a27a20
5 изменённых файлов: 32 добавлений и 21 удалений

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

@ -1004,10 +1004,8 @@ array_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
static JSBool
array_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return array_getAttributes(cx, obj, id, attrsp);
*attrsp = JSPROP_ENUMERATE;
return true;
}
static JSBool

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

@ -6266,6 +6266,24 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
return true;
}
JSBool
js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
JSProperty *prop;
if (!js_LookupElement(cx, obj, index, &obj, &prop))
return false;
if (!prop) {
*attrsp = 0;
return true;
}
if (!obj->isNative())
return obj->getElementAttributes(cx, index, attrsp);
const Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
return true;
}
JSBool
js_SetNativeAttributes(JSContext *cx, JSObject *obj, Shape *shape, uintN attrs)
{

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

@ -286,6 +286,9 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
extern JSBool
js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
extern JSBool
js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
extern JSBool
js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
@ -1426,7 +1429,10 @@ struct JSObject : js::gc::Cell {
return (op ? op : js_GetAttributes)(cx, this, id, attrsp);
}
inline JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp);
JSBool getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) {
js::ElementAttributesOp op = getOps()->getElementAttributes;
return (op ? op : js_GetElementAttributes)(cx, this, index, attrsp);
}
inline JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp);

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

@ -1137,15 +1137,6 @@ JSObject::setElement(JSContext *cx, uint32 index, js::Value *vp, JSBool strict)
return setProperty(cx, id, vp, strict);
}
inline JSBool
JSObject::getElementAttributes(JSContext *cx, uint32 index, uintN *attrsp)
{
jsid id;
if (!js::IndexToId(cx, index, &id))
return false;
return getAttributes(cx, id, attrsp);
}
inline JSBool
JSObject::setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp)
{

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

@ -437,10 +437,10 @@ ArrayBuffer::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *att
JSBool
ArrayBuffer::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
JSObject *delegate = DelegateObject(cx, obj);
if (!delegate)
return false;
return obj_getAttributes(cx, obj, id, attrsp);
return js_GetElementAttributes(cx, delegate, index, attrsp);
}
JSBool
@ -660,10 +660,8 @@ TypedArray::obj_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attr
JSBool
TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return obj_getAttributes(cx, obj, id, attrsp);
*attrsp = JSPROP_PERMANENT | JSPROP_ENUMERATE;
return true;
}
JSBool