Bug 686582 - Begin to specialize ObjectOps::setElementAttributes to not just delegate to ObjectOps::setAttributes. r=dvander

--HG--
extra : rebase_source : fb8b2565831ba0f4457d5ae639ffa55117550445
This commit is contained in:
Jeff Walden 2011-08-10 14:54:52 -07:00
parent 2dc8a07b8f
commit 61906ba14c
5 changed files with 30 additions and 26 deletions

View File

@ -1011,18 +1011,15 @@ array_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *at
static JSBool
array_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_CANT_SET_ARRAY_ATTRS);
return JS_FALSE;
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
static JSBool
array_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return array_setAttributes(cx, obj, id, attrsp);
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
namespace js {

View File

@ -6305,6 +6305,19 @@ js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
: obj->setAttributes(cx, id, attrsp);
}
JSBool
js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
JSProperty *prop;
if (!js_LookupElement(cx, obj, index, &obj, &prop))
return false;
if (!prop)
return true;
return obj->isNative()
? js_SetNativeAttributes(cx, obj, (Shape *) prop, *attrsp)
: obj->setElementAttributes(cx, index, attrsp);
}
JSBool
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
{

View File

@ -292,6 +292,9 @@ js_GetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrs
extern JSBool
js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
extern JSBool
js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp);
extern JSBool
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
@ -1436,7 +1439,10 @@ struct JSObject : js::gc::Cell {
inline JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp);
inline JSBool setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp);
JSBool setElementAttributes(JSContext *cx, uint32 index, uintN *attrsp) {
js::ElementAttributesOp op = getOps()->setElementAttributes;
return (op ? op : js_SetElementAttributes)(cx, this, index, attrsp);
}
inline JSBool deleteProperty(JSContext *cx, jsid id, js::Value *rval, JSBool strict);

View File

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

View File

@ -461,10 +461,10 @@ ArrayBuffer::obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *att
JSBool
ArrayBuffer::obj_setElementAttributes(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_setAttributes(cx, obj, id, attrsp);
return js_SetElementAttributes(cx, delegate, index, attrsp);
}
JSBool
@ -667,18 +667,15 @@ TypedArray::obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32 index,
JSBool
TypedArray::obj_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_CANT_SET_ARRAY_ATTRS);
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
JSBool
TypedArray::obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrsp)
{
jsid id;
if (!IndexToId(cx, index, &id))
return false;
return obj_setAttributes(cx, obj, id, attrsp);
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_SET_ARRAY_ATTRS);
return false;
}
/* static */ int