Back out dbf70d71fe29 (bug 1198701) for breaking test_document.all_iteration.html
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 20 Mar 2016 22:35:54 -0700
changeset 313337 2678b91f4165e884f043df42bcddc91f91d2bb69
parent 313336 ea2b3a89986eacac865dd97b9fd306a275bbe48b
child 313338 4037eb98974db1b1e0b5012c8a7f3a36428eaa11
child 313387 558a789116f264db1a27f73d73a6dd067ce207f0
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1198701
milestone48.0a1
backs outdbf70d71fe29d0c0738f1fb08312c260c9351774
Back out dbf70d71fe29 (bug 1198701) for breaking test_document.all_iteration.html
js/src/builtin/Array.js
js/src/tests/ecma_6/Array/iterator_next.js
--- a/js/src/builtin/Array.js
+++ b/js/src/builtin/Array.js
@@ -710,71 +710,53 @@ function CreateArrayIteratorAt(obj, kind
     UnsafeSetReservedSlot(iterator, ITERATOR_SLOT_NEXT_INDEX, n);
     UnsafeSetReservedSlot(iterator, ITERATOR_SLOT_ITEM_KIND, kind);
     return iterator;
 }
 function CreateArrayIterator(obj, kind) {
     return CreateArrayIteratorAt(obj, kind, 0);
 }
 
-// ES6, 22.1.5.2.1
-// https://tc39.github.io/ecma262/#sec-%arrayiteratorprototype%.next
+
 function ArrayIteratorNext() {
-    // Step 1-3.
     if (!IsObject(this) || !IsArrayIterator(this)) {
         return callFunction(CallArrayIteratorMethodIfWrapped, this,
                             "ArrayIteratorNext");
     }
-
-    // Step 4.
-    var a = UnsafeGetReservedSlot(this, ITERATOR_SLOT_TARGET);
-    var result = { value: undefined, done: false };
-
-    // Step 5.
-    if (!a) {
-      result.done = true;
-      return result;
-    }
-
-    // Step 6.
+    var a = UnsafeGetObjectFromReservedSlot(this, ITERATOR_SLOT_TARGET);
     // The index might not be an integer, so we have to do a generic get here.
     var index = UnsafeGetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX);
-
-    // Step 7.
     var itemKind = UnsafeGetInt32FromReservedSlot(this, ITERATOR_SLOT_ITEM_KIND);
-
-    // Step 8-9.
+    var result = { value: undefined, done: false };
     var len = IsPossiblyWrappedTypedArray(a)
               ? PossiblyWrappedTypedArrayLength(a)
               : TO_UINT32(a.length);
 
-    // Step 10.
+    // FIXME: This should be ToLength, which clamps at 2**53.  Bug 924058.
     if (index >= len) {
-        UnsafeSetReservedSlot(this, ITERATOR_SLOT_TARGET, null);
+        // When the above is changed to ToLength, use +1/0 here instead
+        // of MAX_UINT32.
+        UnsafeSetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX, 0xffffffff);
         result.done = true;
         return result;
     }
 
-    // Step 11.
     UnsafeSetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX, index + 1);
 
-    // Step 16.
     if (itemKind === ITEM_KIND_VALUE) {
         result.value = a[index];
         return result;
     }
 
-    // Step 13.
     if (itemKind === ITEM_KIND_KEY_AND_VALUE) {
         var pair = [index, a[index]];
         result.value = pair;
         return result;
     }
 
-    // Step 12.
     assert(itemKind === ITEM_KIND_KEY, itemKind);
     result.value = index;
     return result;
 }
 
 function ArrayValuesAt(n) {
     return CreateArrayIteratorAt(this, ITEM_KIND_VALUE, n);
 }
deleted file mode 100644
--- a/js/src/tests/ecma_6/Array/iterator_next.js
+++ /dev/null
@@ -1,23 +0,0 @@
-function testIteratorNextGetLength() {
-  var lengthCalledTimes = 0;
-  var array = {
-    __proto__: Array.prototype,
-    get length() {
-      lengthCalledTimes += 1;
-      return {
-        valueOf() {
-          return 0;
-        }
-      };
-    }
-  };
-  var it = array[Symbol.iterator]();
-  it.next();
-  it.next();
-  if (typeof reportCompare === 'function') {
-    reportCompare(1, lengthCalledTimes,
-      "when an iterator get length zero, it shouldn't access it again");
-  }
-}
-testIteratorNextGetLength();
-