mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
Bug 551529 - Remove __count__. r=shaver
This commit is contained in:
parent
b5ba1c7a09
commit
23f72aa6c3
@ -202,7 +202,8 @@ function compareJSON(aNodeJSON_1, aNodeJSON_2) {
|
||||
const SKIP_PROPS = ["dateAdded", "lastModified", "id"];
|
||||
|
||||
function compareObjects(obj1, obj2) {
|
||||
do_check_eq(obj1.__count__, obj2.__count__);
|
||||
function count(o) { var n = 0; for (let p in o) n++; return n; }
|
||||
do_check_eq(count(obj1), count(obj2));
|
||||
for (let prop in obj1) {
|
||||
// Skip everchanging values.
|
||||
if (SKIP_PROPS.indexOf(prop) != -1)
|
||||
|
@ -1347,7 +1347,6 @@ static JSStdName object_prototype_names[] = {
|
||||
/* Object.prototype properties (global delegates to Object.prototype). */
|
||||
{js_InitObjectClass, EAGER_ATOM(proto), NULL},
|
||||
{js_InitObjectClass, EAGER_ATOM(parent), NULL},
|
||||
{js_InitObjectClass, EAGER_ATOM(count), NULL},
|
||||
#if JS_HAS_TOSOURCE
|
||||
{js_InitObjectClass, EAGER_ATOM(toSource), NULL},
|
||||
#endif
|
||||
|
@ -132,7 +132,6 @@ const char *const js_common_atom_names[] = {
|
||||
js_caller_str, /* callerAtom */
|
||||
js_class_prototype_str, /* classPrototypeAtom */
|
||||
js_constructor_str, /* constructorAtom */
|
||||
js_count_str, /* countAtom */
|
||||
js_each_str, /* eachAtom */
|
||||
js_eval_str, /* evalAtom */
|
||||
js_fileName_str, /* fileNameAtom */
|
||||
@ -206,7 +205,6 @@ const char js_callee_str[] = "callee";
|
||||
const char js_caller_str[] = "caller";
|
||||
const char js_class_prototype_str[] = "prototype";
|
||||
const char js_constructor_str[] = "constructor";
|
||||
const char js_count_str[] = "__count__";
|
||||
const char js_each_str[] = "each";
|
||||
const char js_eval_str[] = "eval";
|
||||
const char js_fileName_str[] = "fileName";
|
||||
|
@ -246,7 +246,6 @@ struct JSAtomState {
|
||||
JSAtom *callerAtom;
|
||||
JSAtom *classPrototypeAtom;
|
||||
JSAtom *constructorAtom;
|
||||
JSAtom *countAtom;
|
||||
JSAtom *eachAtom;
|
||||
JSAtom *evalAtom;
|
||||
JSAtom *fileNameAtom;
|
||||
|
@ -2686,10 +2686,10 @@ static JSBool
|
||||
EmitSpecialPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg)
|
||||
{
|
||||
/*
|
||||
* Special case for obj.__proto__, obj.__parent__, obj.__count__ to
|
||||
* deoptimize away from fast paths in the interpreter and trace recorder,
|
||||
* which skip dense array instances by going up to Array.prototype before
|
||||
* looking up the property name.
|
||||
* Special case for obj.__proto__ and obj.__parent__ to deoptimize away
|
||||
* from fast paths in the interpreter and trace recorder, which skip dense
|
||||
* array instances by going up to Array.prototype before looking up the
|
||||
* property name.
|
||||
*/
|
||||
JSAtomListElement *ale = cg->atomList.add(cg->compiler, pn->pn_atom);
|
||||
if (!ale)
|
||||
@ -2711,11 +2711,10 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg,
|
||||
JS_ASSERT(pn->pn_arity == PN_NAME);
|
||||
pn2 = pn->maybeExpr();
|
||||
|
||||
/* Special case deoptimization on __proto__, __count__ and __parent__. */
|
||||
/* Special case deoptimization on __proto__ and __parent__. */
|
||||
if ((op == JSOP_GETPROP || op == JSOP_CALLPROP) &&
|
||||
(pn->pn_atom == cx->runtime->atomState.protoAtom ||
|
||||
pn->pn_atom == cx->runtime->atomState.parentAtom ||
|
||||
pn->pn_atom == cx->runtime->atomState.countAtom)) {
|
||||
pn->pn_atom == cx->runtime->atomState.parentAtom)) {
|
||||
if (pn2 && !js_EmitTree(cx, cg, pn2))
|
||||
return JS_FALSE;
|
||||
return EmitSpecialPropOp(cx, pn, callContext ? JSOP_CALLELEM : JSOP_GETELEM, cg);
|
||||
@ -2802,13 +2801,12 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg,
|
||||
}
|
||||
|
||||
/*
|
||||
* Special case deoptimization on __proto__, __count__ and
|
||||
* __parent__, as above.
|
||||
* Special case deoptimization on __proto__ and __parent__, as
|
||||
* above.
|
||||
*/
|
||||
if (pndot->pn_arity == PN_NAME &&
|
||||
(pndot->pn_atom == cx->runtime->atomState.protoAtom ||
|
||||
pndot->pn_atom == cx->runtime->atomState.parentAtom ||
|
||||
pndot->pn_atom == cx->runtime->atomState.countAtom)) {
|
||||
pndot->pn_atom == cx->runtime->atomState.parentAtom)) {
|
||||
if (!EmitSpecialPropOp(cx, pndot, JSOP_GETELEM, cg))
|
||||
return JS_FALSE;
|
||||
} else if (!EmitAtomOp(cx, pndot, PN_OP(pndot), cg)) {
|
||||
|
@ -133,17 +133,12 @@ obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
static JSBool
|
||||
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
obj_getCount(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
static JSPropertySpec object_props[] = {
|
||||
/* These two must come first; see object_props[slot].name usage below. */
|
||||
{js_proto_str, JSSLOT_PROTO, JSPROP_PERMANENT|JSPROP_SHARED,
|
||||
obj_getSlot, obj_setSlot},
|
||||
{js_parent_str,JSSLOT_PARENT,JSPROP_READONLY|JSPROP_PERMANENT|JSPROP_SHARED,
|
||||
obj_getSlot, obj_setSlot},
|
||||
{js_count_str, 0, JSPROP_READONLY|JSPROP_PERMANENT|JSPROP_SHARED,
|
||||
obj_getCount, NULL},
|
||||
{0,0,0,0,0}
|
||||
};
|
||||
|
||||
@ -242,29 +237,6 @@ obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
return js_SetProtoOrParent(cx, obj, slot, pobj, JS_TRUE);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
obj_getCount(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
jsid num_properties;
|
||||
|
||||
if (JS_HAS_STRICT_OPTION(cx) && !ReportStrictSlot(cx, JSSLOT_COUNT))
|
||||
return false;
|
||||
|
||||
/* Get the number of properties to enumerate. */
|
||||
AutoEnumStateRooter iterState(cx, obj);
|
||||
if (!obj->enumerate(cx, JSENUMERATE_INIT, iterState.addr(), &num_properties))
|
||||
return false;
|
||||
|
||||
if (!JSVAL_IS_INT(num_properties)) {
|
||||
JS_ASSERT(0);
|
||||
*vp = JSVAL_ZERO;
|
||||
return true;
|
||||
}
|
||||
*vp = num_properties;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#else /* !JS_HAS_OBJ_PROTO_PROP */
|
||||
|
||||
#define object_props NULL
|
||||
|
@ -5290,20 +5290,22 @@ test(testConstructorBail);
|
||||
|
||||
function testNewArrayCount()
|
||||
{
|
||||
function count(a) { var n = 0; for (var p in a) n++; return n; }
|
||||
var a = [];
|
||||
for (var i = 0; i < 5; i++)
|
||||
a = [0];
|
||||
assertEq(a.__count__, 1);
|
||||
assertEq(count(a), 1);
|
||||
for (var i = 0; i < 5; i++)
|
||||
a = [0, , 2];
|
||||
assertEq(a.__count__, 2);
|
||||
assertEq(count(a), 2);
|
||||
}
|
||||
test(testNewArrayCount);
|
||||
|
||||
function testNewArrayCount2() {
|
||||
function count(a) { var n = 0; for (var p in a) n++; return n; }
|
||||
var x = 0;
|
||||
for (var i = 0; i < 10; ++i)
|
||||
x = new Array(1,2,3).__count__;
|
||||
x = count(new Array(1,2,3));
|
||||
return x;
|
||||
}
|
||||
testNewArrayCount2.expected = 3;
|
||||
|
@ -1,11 +1,12 @@
|
||||
function testNewArrayCount()
|
||||
{
|
||||
function count(a) { var n = 0; for (var p in a) n++; return n; }
|
||||
var a = [];
|
||||
for (var i = 0; i < 5; i++)
|
||||
a = [0];
|
||||
assertEq(a.__count__, 1);
|
||||
assertEq(count(a), 1);
|
||||
for (var i = 0; i < 5; i++)
|
||||
a = [0, , 2];
|
||||
assertEq(a.__count__, 2);
|
||||
assertEq(count(a), 2);
|
||||
}
|
||||
testNewArrayCount();
|
||||
|
@ -1,7 +1,8 @@
|
||||
function testNewArrayCount2() {
|
||||
function count(a) { var n = 0; for (var p in a) n++; return n; }
|
||||
var x = 0;
|
||||
for (var i = 0; i < 10; ++i)
|
||||
x = new Array(1,2,3).__count__;
|
||||
x = count(new Array(1,2,3));
|
||||
return x;
|
||||
}
|
||||
assertEq(testNewArrayCount2(), 3);
|
||||
|
Loading…
Reference in New Issue
Block a user