mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 09:05:45 +00:00
Merge backout of bug 651864.
This commit is contained in:
commit
e6723e251b
@ -3805,7 +3805,7 @@ DefineStandardSlot(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
|
||||
|
||||
const Shape *shape = obj->nativeLookup(id);
|
||||
if (!shape) {
|
||||
uint32 slot = JS_GLOBAL_PROPERTY_SLOT(key);
|
||||
uint32 slot = 2 * JSProto_LIMIT + key;
|
||||
if (!js_SetReservedSlot(cx, obj, slot, v))
|
||||
return false;
|
||||
if (!obj->addProperty(cx, id, PropertyStub, StrictPropertyStub, slot, attrs, 0, 0))
|
||||
@ -3991,7 +3991,7 @@ IsStandardClassResolved(JSObject *obj, js::Class *clasp)
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(clasp);
|
||||
|
||||
/* If the constructor is undefined, then it hasn't been initialized. */
|
||||
return (!obj->getReservedSlot(JS_GLOBAL_CTOR_SLOT(key)).isUndefined());
|
||||
return (obj->getReservedSlot(key) != UndefinedValue());
|
||||
}
|
||||
|
||||
void
|
||||
@ -4003,7 +4003,7 @@ MarkStandardClassInitializedNoProto(JSObject* obj, js::Class *clasp)
|
||||
* We use True so that it's obvious what we're doing (instead of, say,
|
||||
* Null, which might be miscontrued as an error in setting Undefined).
|
||||
*/
|
||||
if (obj->getReservedSlot(JS_GLOBAL_CTOR_SLOT(key)).isUndefined())
|
||||
if (obj->getReservedSlot(key) == UndefinedValue())
|
||||
obj->setSlot(key, BooleanValue(true));
|
||||
}
|
||||
|
||||
@ -4217,7 +4217,7 @@ js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
|
||||
return true;
|
||||
}
|
||||
|
||||
Value v = obj->getReservedSlot(JS_GLOBAL_CTOR_SLOT(key));
|
||||
Value v = obj->getReservedSlot(key);
|
||||
if (v.isObject()) {
|
||||
*objp = &v.toObject();
|
||||
return true;
|
||||
@ -4234,7 +4234,7 @@ js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
|
||||
if (JSObjectOp init = lazy_prototype_init[key]) {
|
||||
if (!init(cx, obj))
|
||||
return false;
|
||||
v = obj->getReservedSlot(JS_GLOBAL_CTOR_SLOT(key));
|
||||
v = obj->getReservedSlot(key);
|
||||
if (v.isObject())
|
||||
cobj = &v.toObject();
|
||||
}
|
||||
@ -4250,8 +4250,8 @@ js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj,
|
||||
if (!obj->isGlobal())
|
||||
return JS_TRUE;
|
||||
|
||||
return js_SetReservedSlot(cx, obj, JS_GLOBAL_CTOR_SLOT(key), ObjectOrNullValue(cobj)) &&
|
||||
js_SetReservedSlot(cx, obj, JS_GLOBAL_PROTO_SLOT(key), ObjectOrNullValue(proto));
|
||||
return js_SetReservedSlot(cx, obj, key, ObjectOrNullValue(cobj)) &&
|
||||
js_SetReservedSlot(cx, obj, JSProto_LIMIT + key, ObjectOrNullValue(proto));
|
||||
}
|
||||
|
||||
JSBool
|
||||
@ -4292,6 +4292,8 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
|
||||
return JS_FALSE;
|
||||
|
||||
if (protoKey != JSProto_Null) {
|
||||
JS_ASSERT(JSProto_Null < protoKey);
|
||||
JS_ASSERT(protoKey < JSProto_LIMIT);
|
||||
if (!js_GetClassObject(cx, obj, protoKey, &cobj))
|
||||
return JS_FALSE;
|
||||
if (cobj) {
|
||||
@ -6198,7 +6200,7 @@ js_GetClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
|
||||
}
|
||||
scopeobj = scopeobj->getGlobal();
|
||||
if (scopeobj->isGlobal()) {
|
||||
const Value &v = scopeobj->getReservedSlot(JS_GLOBAL_PROTO_SLOT(protoKey));
|
||||
const Value &v = scopeobj->getReservedSlot(JSProto_LIMIT + protoKey);
|
||||
if (v.isObject()) {
|
||||
*protop = &v.toObject();
|
||||
return true;
|
||||
|
@ -1226,7 +1226,7 @@ NewBuiltinClassInstance(JSContext *cx, Class *clasp, gc::FinalizeKind kind)
|
||||
}
|
||||
JS_ASSERT(global->isGlobal());
|
||||
|
||||
const Value &v = global->getReservedSlot(JS_GLOBAL_PROTO_SLOT(protoKey));
|
||||
const Value &v = global->getReservedSlot(JSProto_LIMIT + protoKey);
|
||||
JSObject *proto;
|
||||
if (v.isObject()) {
|
||||
proto = &v.toObject();
|
||||
@ -1477,12 +1477,12 @@ DefineConstructorAndPrototype(JSContext *cx, JSObject *global,
|
||||
jsid id = ATOM_TO_JSID(cx->runtime->atomState.classAtoms[key]);
|
||||
JS_ASSERT(!global->nativeLookup(id));
|
||||
|
||||
if (!global->addDataProperty(cx, id, JS_GLOBAL_PROPERTY_SLOT(key), 0))
|
||||
if (!global->addDataProperty(cx, id, key + JSProto_LIMIT * 2, 0))
|
||||
return false;
|
||||
|
||||
global->setSlot(JS_GLOBAL_CTOR_SLOT(key), ObjectValue(*ctor));
|
||||
global->setSlot(JS_GLOBAL_PROTO_SLOT(key), ObjectValue(*proto));
|
||||
global->setSlot(JS_GLOBAL_PROPERTY_SLOT(key), ObjectValue(*ctor));
|
||||
global->setSlot(key, ObjectValue(*ctor));
|
||||
global->setSlot(key + JSProto_LIMIT, ObjectValue(*proto));
|
||||
global->setSlot(key + JSProto_LIMIT * 2, ObjectValue(*ctor));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -107,24 +107,6 @@ typedef enum JSProtoKey {
|
||||
JSProto_LIMIT
|
||||
} JSProtoKey;
|
||||
|
||||
static void JS_CHECK_PROTOKEY_RANGE(JSProtoKey key) {
|
||||
JS_ASSERT(key >= JSProto_Null);
|
||||
JS_ASSERT(key < JSProto_LIMIT);
|
||||
}
|
||||
|
||||
uintN inline JS_GLOBAL_CTOR_SLOT(JSProtoKey key) {
|
||||
JS_CHECK_PROTOKEY_RANGE(key);
|
||||
return key;
|
||||
}
|
||||
uintN inline JS_GLOBAL_PROTO_SLOT(JSProtoKey key) {
|
||||
JS_CHECK_PROTOKEY_RANGE(key);
|
||||
return key + JSProto_LIMIT;
|
||||
}
|
||||
uintN inline JS_GLOBAL_PROPERTY_SLOT(JSProtoKey key) {
|
||||
JS_CHECK_PROTOKEY_RANGE(key);
|
||||
return key + JSProto_LIMIT * 2;
|
||||
}
|
||||
|
||||
/* js_CheckAccess mode enumeration. */
|
||||
typedef enum JSAccessMode {
|
||||
JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */
|
||||
|
@ -7385,7 +7385,7 @@ JSBool
|
||||
js_GetAnyName(JSContext *cx, jsid *idp)
|
||||
{
|
||||
JSObject *global = cx->running() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject;
|
||||
Value v = global->getReservedSlot(JS_GLOBAL_CTOR_SLOT(JSProto_AnyName));
|
||||
Value v = global->getReservedSlot(JSProto_AnyName);
|
||||
if (v.isUndefined()) {
|
||||
JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AnyNameClass, NULL, global);
|
||||
if (!obj)
|
||||
@ -7398,7 +7398,7 @@ js_GetAnyName(JSContext *cx, jsid *idp)
|
||||
METER(xml_stats.qname);
|
||||
|
||||
v.setObject(*obj);
|
||||
if (!js_SetReservedSlot(cx, global, JS_GLOBAL_CTOR_SLOT(JSProto_AnyName), v))
|
||||
if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v))
|
||||
return false;
|
||||
}
|
||||
*idp = OBJECT_TO_JSID(&v.toObject());
|
||||
|
Loading…
Reference in New Issue
Block a user