Bug 1329113 - Use PropertyIteratorObject* in AutoCloseIterator. r=sfink
authorTooru Fujisawa <arai_a@mac.com>
Wed, 01 Mar 2017 13:34:45 +0900
changeset 374303 81c5898574dcd877c0d42b5554ee3f941d6ba55e
parent 374302 a3d1476da61fcb6278703f9ade471e20fe01978a
child 374304 34c6c2f302e7b48e3ad2cec575cbd34d423a9d32
child 374308 0a15dfecc9fa2b375e5de3ad6f195516b1de2d2f
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1329113
milestone54.0a1
Bug 1329113 - Use PropertyIteratorObject* in AutoCloseIterator. r=sfink
js/src/proxy/CrossCompartmentWrapper.cpp
--- a/js/src/proxy/CrossCompartmentWrapper.cpp
+++ b/js/src/proxy/CrossCompartmentWrapper.cpp
@@ -261,25 +261,28 @@ static bool
 CanReify(HandleObject obj)
 {
     return obj->is<PropertyIteratorObject>() &&
            (obj->as<PropertyIteratorObject>().getNativeIterator()->flags & JSITER_ENUMERATE);
 }
 
 struct AutoCloseIterator
 {
-    AutoCloseIterator(JSContext* cx, JSObject* obj) : cx(cx), obj(cx, obj) {}
+    AutoCloseIterator(JSContext* cx, PropertyIteratorObject* obj) : cx(cx), obj(cx, obj) {}
 
-    ~AutoCloseIterator() { if (obj) CloseIterator(cx, obj); }
+    ~AutoCloseIterator() {
+        if (obj)
+            MOZ_ALWAYS_TRUE(CloseIterator(cx, obj));
+    }
 
     void clear() { obj = nullptr; }
 
   private:
     JSContext* cx;
-    RootedObject obj;
+    Rooted<PropertyIteratorObject*> obj;
 };
 
 static bool
 Reify(JSContext* cx, JSCompartment* origin, MutableHandleObject objp)
 {
     Rooted<PropertyIteratorObject*> iterObj(cx, &objp->as<PropertyIteratorObject>());
     NativeIterator* ni = iterObj->getNativeIterator();
 
@@ -305,18 +308,17 @@ Reify(JSContext* cx, JSCompartment* orig
             RootedValue v(cx, StringValue(ni->begin()[i]));
             if (!ValueToId<CanGC>(cx, v, &id))
                 return false;
             keys.infallibleAppend(id);
         }
     }
 
     close.clear();
-    if (!CloseIterator(cx, iterObj))
-        return false;
+    MOZ_ALWAYS_TRUE(CloseIterator(cx, iterObj));
 
     return EnumeratedIdVectorToIterator(cx, obj, ni->flags, keys, objp);
 }
 
 bool
 CrossCompartmentWrapper::enumerate(JSContext* cx, HandleObject wrapper,
                                    MutableHandleObject objp) const
 {