Bug 1036507 - Introduce and use StandardProtoKeyOrNull. r=luke

This commit is contained in:
Bobby Holley 2014-07-11 09:09:21 -07:00
parent 8b8c93b583
commit f0ba9615ce
2 changed files with 12 additions and 3 deletions

View File

@ -3424,7 +3424,7 @@ JS::IdentifyStandardInstance(JSObject *obj)
{
// Note: The prototype shares its JSClass with instances.
JS_ASSERT(!obj->is<CrossCompartmentWrapperObject>());
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
JSProtoKey key = StandardProtoKeyOrNull(obj);
if (key != JSProto_Null && !IsStandardPrototype(obj, key))
return key;
return JSProto_Null;
@ -3435,7 +3435,7 @@ JS::IdentifyStandardPrototype(JSObject *obj)
{
// Note: The prototype shares its JSClass with instances.
JS_ASSERT(!obj->is<CrossCompartmentWrapperObject>());
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
JSProtoKey key = StandardProtoKeyOrNull(obj);
if (key != JSProto_Null && IsStandardPrototype(obj, key))
return key;
return JSProto_Null;
@ -3444,7 +3444,7 @@ JS::IdentifyStandardPrototype(JSObject *obj)
JSProtoKey
JS::IdentifyStandardInstanceOrPrototype(JSObject *obj)
{
return JSCLASS_CACHED_PROTO_KEY(obj->getClass());
return StandardProtoKeyOrNull(obj);
}
JSProtoKey

View File

@ -807,6 +807,15 @@ GenericCreatePrototype(JSContext *cx, JSProtoKey key)
return cx->global()->createBlankPrototypeInheriting(cx, clasp, *parentProto);
}
inline JSProtoKey
StandardProtoKeyOrNull(const JSObject *obj)
{
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
if (key == JSProto_Error)
return GetExceptionProtoKey(obj->as<ErrorObject>().type());
return key;
}
} // namespace js
template<>