Bug 973566, part 2 - Change some code to use a new, simpler js::HasOwnProperty signature. r=jimb.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 26 Feb 2014 08:55:35 -0600
changeset 171033 b130f02b5151dda4b7046c4028ad4f849499f129
parent 171032 5d7c2275e34668e5f23ebec57517fdfeef6e1319
child 171034 7a2bb8e2f3cb90771f190016e5f8cd1ca6988266
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersjimb
bugs973566
milestone30.0a1
Bug 973566, part 2 - Change some code to use a new, simpler js::HasOwnProperty signature. r=jimb.
js/src/builtin/Object.cpp
js/src/jsobj.h
js/src/vm/StructuredClone.cpp
--- 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 {