Backed out 2 changesets (bug 952873) for build bustage on a CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Tue, 28 Jan 2014 17:34:42 -0800
changeset 181696 b9cf7a013b6277d2e2f8949dfcb36384b195db41
parent 181695 d7a6a64b42f0268cecb94026aa334fb3eb13304c
child 181697 3b88bcc4c3d4cf4bde110eb83d70810d5dd00a1c
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs952873
milestone29.0a1
backs out92dfed2592ae21d8e7d9d230f431261edfe4aac1
1ae58fcd61a9f77dc18fb0bc3f6d7b700201ca83
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 952873) for build bustage on a CLOSED TREE Backed out changeset 92dfed2592ae (bug 952873) Backed out changeset 1ae58fcd61a9 (bug 952873)
js/src/builtin/MapObject.cpp
js/src/jsapi.h
js/src/jsiter.cpp
js/src/jsiter.h
--- a/js/src/builtin/MapObject.cpp
+++ b/js/src/builtin/MapObject.cpp
@@ -22,17 +22,16 @@
 using namespace js;
 
 using mozilla::DoubleIsInt32;
 using mozilla::Forward;
 using mozilla::IsNaN;
 using mozilla::Move;
 using mozilla::ArrayLength;
 using JS::DoubleNaNValue;
-using JS::ForOfIterator;
 
 
 /*** OrderedHashTable ****************************************************************************/
 
 /*
  * Define two collection templates, js::OrderedHashMap and js::OrderedHashSet.
  * They are like js::HashMap and js::HashSet except that:
  *
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4802,68 +4802,11 @@ struct AsmJSCacheOps
     OpenAsmJSCacheEntryForWriteOp openEntryForWrite;
     CloseAsmJSCacheEntryForWriteOp closeEntryForWrite;
     BuildIdOp buildId;
 };
 
 extern JS_PUBLIC_API(void)
 SetAsmJSCacheOps(JSRuntime *rt, const AsmJSCacheOps *callbacks);
 
-/*
- * Convenience class for imitating a JS level for-of loop. Typical usage:
- *
- *     ForOfIterator it(cx);
- *     if (!it.init(iterable))
- *       return false;
- *     RootedValue val(cx);
- *     while (true) {
- *       bool done;
- *       if (!it.next(&val, &done))
- *         return false;
- *       if (done)
- *         break;
- *       if (!DoStuff(cx, val))
- *         return false;
- *     }
- */
-class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) {
-  protected:
-    JSContext *cx_;
-    JS::RootedObject iterator;
-
-    ForOfIterator(const ForOfIterator &) MOZ_DELETE;
-    ForOfIterator &operator=(const ForOfIterator &) MOZ_DELETE;
-
-  public:
-    ForOfIterator(JSContext *cx) : cx_(cx), iterator(cx) { }
-
-    enum NonIterableBehavior {
-        ThrowOnNonIterable,
-        AllowNonIterable
-    };
-
-    /*
-     * Initialize the iterator.  If AllowNonIterable is passed then if iterable
-     * does not have a callable @@iterator init() will just return true instead
-     * of throwing.  Callers should then check valueIsIterable() before
-     * continuing with the iteration.
-     */
-    JS_PUBLIC_API(bool) init(JS::HandleValue iterable,
-                             NonIterableBehavior nonIterableBehavior = ThrowOnNonIterable);
-
-    /*
-     * Get the next value from the iterator.  If false *done is true
-     * after this call, do not examine val.
-     */
-    JS_PUBLIC_API(bool) next(JS::MutableHandleValue val, bool *done);
-
-    /*
-     * If initialized with throwOnNonCallable = false, check whether
-     * the value is iterable.
-     */
-    bool valueIsIterable() const {
-        return iterator;
-    }
-};
-
 } /* namespace JS */
 
 #endif /* jsapi_h */
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -10,17 +10,16 @@
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 
 #include "jsarray.h"
 #include "jsatom.h"
 #include "jscntxt.h"
-#include "jsfriendapi.h"
 #include "jsgc.h"
 #include "jsobj.h"
 #include "jsopcode.h"
 #include "jsproxy.h"
 #include "jsscript.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
@@ -35,17 +34,16 @@
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
-using JS::ForOfIterator;
 
 using mozilla::ArrayLength;
 #ifdef JS_MORE_DETERMINISTIC
 using mozilla::PodCopy;
 #endif
 using mozilla::PodZero;
 
 typedef Rooted<PropertyIteratorObject*> RootedPropertyIteratorObject;
@@ -1265,41 +1263,37 @@ const Class StopIterationObject::class_ 
     JS_ResolveStub,
     JS_ConvertStub,
     nullptr,                 /* finalize    */
     nullptr,                 /* call        */
     stopiter_hasInstance,
     nullptr                  /* construct   */
 };
 
-JS_FRIEND_API(bool)
-ForOfIterator::init(HandleValue iterable, NonIterableBehavior nonIterableBehavior)
+bool
+ForOfIterator::init(HandleValue iterable)
 {
-    JSContext *cx = cx_;
     RootedObject iterableObj(cx, ToObject(cx, iterable));
     if (!iterableObj)
         return false;
 
     // The iterator is the result of calling obj[@@iterator]().
     InvokeArgs args(cx);
     if (!args.init(0))
         return false;
     args.setThis(ObjectValue(*iterableObj));
 
     RootedValue callee(cx);
     if (!JSObject::getProperty(cx, iterableObj, iterableObj, cx->names().std_iterator, &callee))
         return false;
 
-    // Throw if obj[@@iterator] isn't callable if we were asked to do so.
-    // js::Invoke is about to check for this kind of error anyway, but it would
-    // throw an inscrutable error message about |method| rather than this nice
-    // one about |obj|.
+    // Throw if obj[@@iterator] isn't callable. js::Invoke is about to check
+    // for this kind of error anyway, but it would throw an inscrutable
+    // error message about |method| rather than this nice one about |obj|.
     if (!callee.isObject() || !callee.toObject().isCallable()) {
-        if (nonIterableBehavior == AllowNonIterable)
-            return true;
         char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, iterable, NullPtr());
         if (!bytes)
             return false;
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_ITERABLE, bytes);
         js_free(bytes);
         return false;
     }
 
@@ -1309,22 +1303,21 @@ ForOfIterator::init(HandleValue iterable
 
     iterator = ToObject(cx, args.rval());
     if (!iterator)
         return false;
 
     return true;
 }
 
-JS_FRIEND_API(bool)
+bool
 ForOfIterator::next(MutableHandleValue vp, bool *done)
 {
     JS_ASSERT(iterator);
 
-    JSContext *cx = cx_;
     RootedValue method(cx);
     if (!JSObject::getProperty(cx, iterator, iterator, cx->names().next, &method))
         return false;
 
     InvokeArgs args(cx);
     if (!args.init(1))
         return false;
     args.setCallee(method);
--- a/js/src/jsiter.h
+++ b/js/src/jsiter.h
@@ -214,16 +214,50 @@ extern bool
 js_IteratorNext(JSContext *cx, js::HandleObject iterobj, js::MutableHandleValue rval);
 
 extern bool
 js_ThrowStopIteration(JSContext *cx);
 
 namespace js {
 
 /*
+ * Convenience class for imitating a JS level for-of loop. Typical usage:
+ *
+ *     ForOfIterator it(cx, iterable);
+ *     while (it.next()) {
+ *        if (!DoStuff(cx, it.value()))
+ *            return false;
+ *     }
+ *     if (!it.close())
+ *         return false;
+ *
+ * The final it.close() check is needed in order to check for cases where
+ * any of the iterator operations fail.
+ *
+ * it.close() may be skipped only if something in the body of the loop fails
+ * and the failure is allowed to propagate on cx, as in this example if DoStuff
+ * fails. In that case, ForOfIterator's destructor does all necessary cleanup.
+ */
+class ForOfIterator
+{
+  private:
+    JSContext *cx;
+    RootedObject iterator;
+
+    ForOfIterator(const ForOfIterator &) MOZ_DELETE;
+    ForOfIterator &operator=(const ForOfIterator &) MOZ_DELETE;
+
+  public:
+    ForOfIterator(JSContext *cx) : cx(cx), iterator(cx) { }
+
+    bool init(HandleValue iterable);
+    bool next(MutableHandleValue val, bool *done);
+};
+
+/*
  * Create an object of the form { value: VALUE, done: DONE }.
  * ES6 draft from 2013-09-05, section 25.4.3.4.
  */
 extern JSObject *
 CreateItrResultObject(JSContext *cx, js::HandleValue value, bool done);
 
 } /* namespace js */