mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 04:27:37 +00:00
Bug 686582 - Begin to specialize ObjectOps::deleteElement to not just delegate to ObjectOps::deleteProperty. r=dvander
--HG-- extra : rebase_source : ea2bd6c2511e5be83fcb826b7d4b81b6d38260ce
This commit is contained in:
parent
7c903ab2a6
commit
4507218e6f
@ -1035,7 +1035,7 @@ array_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool
|
|||||||
|
|
||||||
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
|
||||||
rval->setBoolean(false);
|
rval->setBoolean(false);
|
||||||
return JS_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (js_IdIsIndex(id, &i) && i < obj->getDenseArrayInitializedLength()) {
|
if (js_IdIsIndex(id, &i) && i < obj->getDenseArrayInitializedLength()) {
|
||||||
@ -1047,17 +1047,26 @@ array_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
rval->setBoolean(true);
|
rval->setBoolean(true);
|
||||||
return JS_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* non-static for direct deletion of array elements within the engine */
|
/* non-static for direct deletion of array elements within the engine */
|
||||||
JSBool
|
JSBool
|
||||||
array_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
array_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||||
{
|
{
|
||||||
jsid id;
|
if (!obj->isDenseArray())
|
||||||
if (!IndexToId(cx, index, &id))
|
return js_DeleteElement(cx, obj, index, rval, strict);
|
||||||
|
|
||||||
|
if (index < obj->getDenseArrayInitializedLength()) {
|
||||||
|
obj->markDenseArrayNotPacked(cx);
|
||||||
|
obj->setDenseArrayElement(index, MagicValue(JS_ARRAY_HOLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!js_SuppressDeletedElement(cx, obj, index))
|
||||||
return false;
|
return false;
|
||||||
return array_deleteProperty(cx, obj, id, rval, strict);
|
|
||||||
|
rval->setBoolean(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace js
|
} // namespace js
|
||||||
|
@ -920,6 +920,16 @@ js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id)
|
|||||||
return SuppressDeletedPropertyHelper(cx, obj, SingleIdPredicate(id));
|
return SuppressDeletedPropertyHelper(cx, obj, SingleIdPredicate(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
js_SuppressDeletedElement(JSContext *cx, JSObject *obj, uint32 index)
|
||||||
|
{
|
||||||
|
jsid id;
|
||||||
|
if (!IndexToId(cx, index, &id))
|
||||||
|
return false;
|
||||||
|
JS_ASSERT(id == js_CheckForStringIndex(id));
|
||||||
|
return SuppressDeletedPropertyHelper(cx, obj, SingleIdPredicate(id));
|
||||||
|
}
|
||||||
|
|
||||||
class IndexRangePredicate {
|
class IndexRangePredicate {
|
||||||
jsint begin, end;
|
jsint begin, end;
|
||||||
public:
|
public:
|
||||||
|
@ -148,6 +148,9 @@ js_CloseIterator(JSContext *cx, JSObject *iterObj);
|
|||||||
bool
|
bool
|
||||||
js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id);
|
js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id);
|
||||||
|
|
||||||
|
bool
|
||||||
|
js_SuppressDeletedElement(JSContext *cx, JSObject *obj, uint32 index);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
js_SuppressDeletedIndexProperties(JSContext *cx, JSObject *obj, jsint begin, jsint end);
|
js_SuppressDeletedIndexProperties(JSContext *cx, JSObject *obj, jsint begin, jsint end);
|
||||||
|
|
||||||
|
@ -6397,6 +6397,15 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
|
|||||||
return obj->removeProperty(cx, id) && js_SuppressDeletedProperty(cx, obj, id);
|
return obj->removeProperty(cx, id) && js_SuppressDeletedProperty(cx, obj, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSBool
|
||||||
|
js_DeleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||||
|
{
|
||||||
|
jsid id;
|
||||||
|
if (!IndexToId(cx, index, &id))
|
||||||
|
return false;
|
||||||
|
return js_DeleteProperty(cx, obj, id, rval, strict);
|
||||||
|
}
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -298,6 +298,9 @@ js_SetElementAttributes(JSContext *cx, JSObject *obj, uint32 index, uintN *attrs
|
|||||||
extern JSBool
|
extern JSBool
|
||||||
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
|
js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
|
||||||
|
|
||||||
|
extern JSBool
|
||||||
|
js_DeleteElement(JSContext *cx, JSObject *obj, uint32 index, js::Value *rval, JSBool strict);
|
||||||
|
|
||||||
extern JS_FRIEND_API(JSBool)
|
extern JS_FRIEND_API(JSBool)
|
||||||
js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
||||||
js::Value *statep, jsid *idp);
|
js::Value *statep, jsid *idp);
|
||||||
|
@ -484,10 +484,10 @@ ArrayBuffer::obj_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rv
|
|||||||
JSBool
|
JSBool
|
||||||
ArrayBuffer::obj_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
ArrayBuffer::obj_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||||
{
|
{
|
||||||
jsid id;
|
JSObject *delegate = DelegateObject(cx, obj);
|
||||||
if (!IndexToId(cx, index, &id))
|
if (!delegate)
|
||||||
return false;
|
return false;
|
||||||
return obj_deleteElement(cx, obj, index, rval, strict);
|
return js_DeleteElement(cx, delegate, index, rval, strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
@ -1065,10 +1065,16 @@ class TypedArrayTemplate
|
|||||||
static JSBool
|
static JSBool
|
||||||
obj_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
obj_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||||
{
|
{
|
||||||
jsid id;
|
JSObject *tarray = TypedArray::getTypedArray(obj);
|
||||||
if (!IndexToId(cx, index, &id))
|
JS_ASSERT(tarray);
|
||||||
return false;
|
|
||||||
return obj_deleteProperty(cx, obj, id, rval, strict);
|
if (index < getLength(tarray)) {
|
||||||
|
rval->setBoolean(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
rval->setBoolean(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
@ -4912,10 +4912,28 @@ xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool st
|
|||||||
static JSBool
|
static JSBool
|
||||||
xml_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
xml_deleteElement(JSContext *cx, JSObject *obj, uint32 index, Value *rval, JSBool strict)
|
||||||
{
|
{
|
||||||
jsid id;
|
JSXML *xml = reinterpret_cast<JSXML *>(obj->getPrivate());
|
||||||
if (!IndexToId(cx, index, &id))
|
if (xml->xml_class != JSXML_CLASS_LIST) {
|
||||||
|
/* See NOTE in spec: this variation is reserved for future use. */
|
||||||
|
ReportBadXMLName(cx, DoubleValue(index));
|
||||||
return false;
|
return false;
|
||||||
return xml_deleteProperty(cx, obj, id, rval, strict);
|
}
|
||||||
|
|
||||||
|
/* ECMA-357 9.2.1.3. */
|
||||||
|
DeleteListElement(cx, xml, index);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this object has its own (mutable) scope, then we may have added a
|
||||||
|
* property to the scope in xml_lookupProperty for it to return to mean
|
||||||
|
* "found" and to provide a handle for access operations to call the
|
||||||
|
* property's getter or setter. But now it's time to remove any such
|
||||||
|
* property, to purge the property cache and remove the scope entry.
|
||||||
|
*/
|
||||||
|
if (!obj->nativeEmpty() && !js_DeleteElement(cx, obj, index, rval, false))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
rval->setBoolean(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSString *
|
static JSString *
|
||||||
|
Loading…
Reference in New Issue
Block a user