mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
- Enable JS_HAS_NEW_OBJ_METHODS (Object.prototype.hasOwnProperty, isPrototypeOf
and propertyIsEnumerable) for JS1.5. - Optimize obj_propertyIsEnumerable to avoid extra lookup code bloat, requiring fix to js_GetAttributes (unset out param on successful early retunr) that it exposed. - Use more righteous else-if style in shaver's jsarray.c change.
This commit is contained in:
parent
20f2a8bffa
commit
d70aa0ef6b
@ -1316,16 +1316,12 @@ Array(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
length = (jsuint) argc;
|
length = (jsuint) argc;
|
||||||
vector = argv;
|
vector = argv;
|
||||||
}
|
} else if (!ValueIsLength(cx, argv[0], &length)) {
|
||||||
else {
|
length = 1;
|
||||||
if (!ValueIsLength(cx, argv[0], &length)) {
|
vector = argv;
|
||||||
vector = argv;
|
} else {
|
||||||
length = 1;
|
vector = NULL;
|
||||||
} else {
|
}
|
||||||
vector = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return InitArrayObject(cx, obj, length, vector);
|
return InitArrayObject(cx, obj, length, vector);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@
|
|||||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
||||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
||||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */
|
||||||
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
|
||||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
||||||
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */
|
||||||
|
@ -868,24 +868,16 @@ static JSBool
|
|||||||
obj_propertyIsEnumerable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
obj_propertyIsEnumerable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
jsval *rval)
|
jsval *rval)
|
||||||
{
|
{
|
||||||
JSObject *obj2;
|
|
||||||
JSProperty *prop;
|
|
||||||
JSAtom *atom;
|
JSAtom *atom;
|
||||||
uintN attrs;
|
uintN attrs;
|
||||||
JSBool ok;
|
|
||||||
|
|
||||||
atom = js_ValueToStringAtom(cx, *argv);
|
atom = js_ValueToStringAtom(cx, *argv);
|
||||||
if (atom == NULL || !OBJ_LOOKUP_PROPERTY(cx, obj, (jsid)atom, &obj2, &prop))
|
if (atom == NULL)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!prop) {
|
if (!OBJ_GET_ATTRIBUTES(cx, obj, (jsid)atom, NULL, &attrs))
|
||||||
*rval = JSVAL_FALSE;
|
return JS_FALSE;
|
||||||
return JS_TRUE;
|
*rval = BOOLEAN_TO_JSVAL((attrs & JSPROP_ENUMERATE) != 0);
|
||||||
}
|
return JS_TRUE;
|
||||||
ok = OBJ_GET_ATTRIBUTES(cx, obj2, (jsid)atom, prop, &attrs);
|
|
||||||
if (ok)
|
|
||||||
*rval = BOOLEAN_TO_JSVAL((attrs & JSPROP_ENUMERATE) != 0);
|
|
||||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
#endif /* JS_HAS_NEW_OBJ_METHODS */
|
#endif /* JS_HAS_NEW_OBJ_METHODS */
|
||||||
|
|
||||||
@ -2075,8 +2067,10 @@ js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
|
|||||||
if (noprop) {
|
if (noprop) {
|
||||||
if (!js_LookupProperty(cx, obj, id, &obj, &prop))
|
if (!js_LookupProperty(cx, obj, id, &obj, &prop))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (!prop)
|
if (!prop) {
|
||||||
return JS_TRUE;
|
*attrsp = 0;
|
||||||
|
return JS_TRUE;
|
||||||
|
}
|
||||||
if (!OBJ_IS_NATIVE(obj)) {
|
if (!OBJ_IS_NATIVE(obj)) {
|
||||||
ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, attrsp);
|
ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, attrsp);
|
||||||
OBJ_DROP_PROPERTY(cx, obj, prop);
|
OBJ_DROP_PROPERTY(cx, obj, prop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user