diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 825d27790368..65d5c8f89456 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -3424,7 +3424,7 @@ JS::IdentifyStandardInstance(JSObject *obj) { // Note: The prototype shares its JSClass with instances. JS_ASSERT(!obj->is()); - 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()); - 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 diff --git a/js/src/vm/GlobalObject.h b/js/src/vm/GlobalObject.h index bd0a92a0826d..27e61ff654a7 100644 --- a/js/src/vm/GlobalObject.h +++ b/js/src/vm/GlobalObject.h @@ -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().type()); + return key; +} + } // namespace js template<>