Bug 973566, part 2 - Change some code to use a new, simpler js::HasOwnProperty signature. r=jimb.
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -651,31 +651,31 @@ obj_hasOwnProperty(JSContext *cx, unsign
return false;
/* Step 2. */
RootedObject obj(cx, ToObject(cx, args.thisv()));
if (!obj)
return false;
/* Non-standard code for proxies. */
- RootedObject obj2(cx);
- RootedShape prop(cx);
if (obj->is<ProxyObject>()) {
bool has;
if (!Proxy::hasOwn(cx, obj, idRoot, &has))
return false;
args.rval().setBoolean(has);
return true;
}
/* Step 3. */
- if (!HasOwnProperty<CanGC>(cx, obj->getOps()->lookupGeneric, obj, idRoot, &obj2, &prop))
+ bool found;
+ if (!HasOwnProperty(cx, obj, idRoot, &found))
return false;
+
/* Step 4,5. */
- args.rval().setBoolean(!!prop);
+ args.rval().setBoolean(found);
return true;
}
/* ES5 15.2.4.6. */
static bool
obj_isPrototypeOf(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1281,16 +1281,17 @@ DenseRangeRef::mark(JSTracer *trc)
js::gc::IsObjectMarked(&owner);
uint32_t initLen = owner->getDenseInitializedLength();
uint32_t clampedStart = Min(start, initLen);
gc::MarkArraySlots(trc, Min(end, initLen) - clampedStart,
owner->getDenseElements() + clampedStart, "element");
}
#endif
+/* Set *resultp to tell whether obj has an own property with the given id. */
bool
HasOwnProperty(JSContext *cx, HandleObject obj, HandleId id, bool *resultp);
template <AllowGC allowGC>
extern bool
HasOwnProperty(JSContext *cx, LookupGenericOp lookup,
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
typename MaybeRooted<jsid, allowGC>::HandleType id,
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -1028,24 +1028,21 @@ JSStructuredCloneWriter::write(const Val
ids.popBack();
checkStack();
if (JSID_IS_STRING(id) || JSID_IS_INT(id)) {
/*
* If obj still has an own property named id, write it out.
* The cost of re-checking could be avoided by using
* NativeIterators.
*/
- RootedObject obj2(context());
- RootedShape prop(context());
- if (!HasOwnProperty<CanGC>(context(), obj->getOps()->lookupGeneric, obj, id,
- &obj2, &prop)) {
+ bool found;
+ if (!HasOwnProperty(context(), obj, id, &found))
return false;
- }
- if (prop) {
+ if (found) {
RootedValue val(context());
if (!writeId(id) ||
!JSObject::getGeneric(context(), obj, obj, id, &val) ||
!startWrite(val))
return false;
}
}
} else {