diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index f102c192b19..e1531a231b9 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2037,9 +2037,8 @@ JS_EnumerateStandardClasses(JSContext *cx, JSObject *objArg) * Since ES5 15.1.1.3 undefined can't be deleted. */ RootedPropertyName undefinedName(cx, cx->runtime->atomState.typeAtoms[JSTYPE_VOID]); - RootedId undefinedId(cx, NameToId(undefinedName)); RootedValue undefinedValue(cx, UndefinedValue()); - if (!obj->nativeContains(cx, undefinedId) && + if (!obj->nativeContains(cx, undefinedName) && !JSObject::defineProperty(cx, obj, undefinedName, undefinedValue, JS_PropertyStub, JS_StrictPropertyStub, JSPROP_PERMANENT | JSPROP_READONLY)) { @@ -2114,11 +2113,10 @@ AddNameToArray(JSContext *cx, PropertyName *name, JSIdArray *ida, int *ip) } static JSIdArray * -EnumerateIfResolved(JSContext *cx, JSHandleObject obj, PropertyName *name, JSIdArray *ida, - int *ip, JSBool *foundp) +EnumerateIfResolved(JSContext *cx, Handle obj, Handle name, + JSIdArray *ida, int *ip, JSBool *foundp) { - RootedId id(cx, NameToId(name)); - *foundp = obj->nativeContains(cx, id); + *foundp = obj->nativeContains(cx, name); if (*foundp) ida = AddNameToArray(cx, name, ida, ip); return ida; @@ -2130,7 +2128,6 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *objArg, JSIdArray * RootedObject obj(cx, objArg); JSRuntime *rt; int i, j, k; - PropertyName *name; JSBool found; JSClassInitializerOp init; @@ -2148,7 +2145,7 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *objArg, JSIdArray * } /* Check whether 'undefined' has been resolved and enumerate it if so. */ - name = rt->atomState.typeAtoms[JSTYPE_VOID]; + Rooted name(cx, rt->atomState.typeAtoms[JSTYPE_VOID]); ida = EnumerateIfResolved(cx, obj, name, ida, &i, &found); if (!ida) return NULL; diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 6af5e069935..58f0e022ec1 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -312,12 +312,6 @@ struct JSObject : public js::ObjectImpl */ bool setSlotSpan(JSContext *cx, uint32_t span); - inline bool nativeContains(JSContext *cx, js::HandleId id); - inline bool nativeContains(JSContext *cx, js::HandleShape shape); - - inline bool nativeContainsNoAllocation(jsid id); - inline bool nativeContainsNoAllocation(const js::Shape &shape); - /* Upper bound on the number of elements in an object. */ static const uint32_t NELEMENTS_LIMIT = JS_BIT(28); diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index bf85d979d62..ffde3d51375 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -935,30 +935,6 @@ JSObject::nativeSetSlotWithType(JSContext *cx, js::Shape *shape, const js::Value js::types::AddTypePropertyId(cx, this, shape->propid(), value); } -inline bool -JSObject::nativeContains(JSContext *cx, js::HandleId id) -{ - return nativeLookup(cx, id) != NULL; -} - -inline bool -JSObject::nativeContains(JSContext *cx, js::HandleShape shape) -{ - return nativeLookup(cx, shape->propid()) == shape; -} - -inline bool -JSObject::nativeContainsNoAllocation(jsid id) -{ - return nativeLookupNoAllocation(id) != NULL; -} - -inline bool -JSObject::nativeContainsNoAllocation(const js::Shape &shape) -{ - return nativeLookupNoAllocation(shape.propid()) == &shape; -} - inline bool JSObject::nativeEmpty() const { diff --git a/js/src/jspropertycache.cpp b/js/src/jspropertycache.cpp index 26c927e1cad..42bfd317410 100644 --- a/js/src/jspropertycache.cpp +++ b/js/src/jspropertycache.cpp @@ -163,8 +163,8 @@ PropertyCache::fullTest(JSContext *cx, jsbytecode *pc, JSObject **objp, JSObject if (pobj->lastProperty() == entry->pshape) { #ifdef DEBUG - PropertyName *name = GetNameFromBytecode(cx, script, pc, op); - JS_ASSERT(pobj->nativeContainsNoAllocation(NameToId(name))); + Rooted name(cx, GetNameFromBytecode(cx, script, pc, op)); + JS_ASSERT(pobj->nativeContainsNoAllocation(name)); #endif *pobjp = pobj; return NULL; diff --git a/js/src/vm/ObjectImpl-inl.h b/js/src/vm/ObjectImpl-inl.h index fefcf6d5748..f2265d2fcd8 100644 --- a/js/src/vm/ObjectImpl-inl.h +++ b/js/src/vm/ObjectImpl-inl.h @@ -64,6 +64,42 @@ js::ObjectImpl::nativeLookupNoAllocation(PropertyName *name) return nativeLookupNoAllocation(PropertyId(name)); } +inline bool +js::ObjectImpl::nativeContains(JSContext *cx, JS::Handle id) +{ + return nativeLookup(cx, id) != NULL; +} + +inline bool +js::ObjectImpl::nativeContains(JSContext *cx, JS::Handle name) +{ + return nativeLookup(cx, name) != NULL; +} + +inline bool +js::ObjectImpl::nativeContains(JSContext *cx, JS::Handle shape) +{ + return nativeLookup(cx, shape->propid()) == shape; +} + +inline bool +js::ObjectImpl::nativeContainsNoAllocation(jsid id) +{ + return nativeLookupNoAllocation(id) != NULL; +} + +inline bool +js::ObjectImpl::nativeContainsNoAllocation(PropertyName *name) +{ + return nativeLookupNoAllocation(name) != NULL; +} + +inline bool +js::ObjectImpl::nativeContainsNoAllocation(Shape &shape) +{ + return nativeLookupNoAllocation(shape.propid()) == &shape; +} + inline bool js::ObjectImpl::isExtensible() const { diff --git a/js/src/vm/ObjectImpl.h b/js/src/vm/ObjectImpl.h index 0c97fdec1b0..31571444736 100644 --- a/js/src/vm/ObjectImpl.h +++ b/js/src/vm/ObjectImpl.h @@ -1162,6 +1162,14 @@ class ObjectImpl : public gc::Cell inline Shape * nativeLookupNoAllocation(PropertyId pid); inline Shape * nativeLookupNoAllocation(PropertyName *name); + inline bool nativeContains(JSContext *cx, Handle id); + inline bool nativeContains(JSContext *cx, Handle name); + inline bool nativeContains(JSContext *cx, Handle shape); + + inline bool nativeContainsNoAllocation(jsid id); + inline bool nativeContainsNoAllocation(PropertyName *name); + inline bool nativeContainsNoAllocation(Shape &shape); + inline Class *getClass() const; inline JSClass *getJSClass() const; inline bool hasClass(const Class *c) const;