Bug 942390 - Don't use the iterator cache if the object has an __iterator__ property. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 28 Nov 2013 11:09:40 +0100
changeset 157885 4c360770998dcb6400862f667945eb49eb46eff9
parent 157884 a6c1abbdf6f91ee53485cd0d0e4f6eabb17285da
child 157886 dd032c97a9a84559ae7dacb564eea13e4f63673b
push id36883
push userjandemooij@gmail.com
push dateThu, 28 Nov 2013 10:10:50 +0000
treeherdermozilla-inbound@4c360770998d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs942390
milestone28.0a1
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
Bug 942390 - Don't use the iterator cache if the object has an __iterator__ property. r=bhackett
js/src/jit-test/tests/basic/bug942390.js
js/src/jsiter.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug942390.js
@@ -0,0 +1,11 @@
+var count = 0;
+Object.defineProperty(__proto__, "__iterator__", {
+    get: (function() {
+	count++;
+    })
+})
+__proto__ = (function(){})
+for (var m = 0; m < 7; ++m) {
+    for (var a in 6) {}
+}
+assertEq(count, 7);
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -613,18 +613,20 @@ js::GetIterator(JSContext *cx, HandleObj
              * currently active.
              */
             {
                 JSObject *pobj = obj;
                 do {
                     if (!pobj->isNative() ||
                         !pobj->hasEmptyElements() ||
                         pobj->hasUncacheableProto() ||
-                        obj->getOps()->enumerate ||
-                        pobj->getClass()->enumerate != JS_EnumerateStub) {
+                        pobj->getOps()->enumerate ||
+                        pobj->getClass()->enumerate != JS_EnumerateStub ||
+                        pobj->nativeContainsPure(cx->names().iteratorIntrinsic))
+                    {
                         shapes.clear();
                         goto miss;
                     }
                     Shape *shape = pobj->lastProperty();
                     key = (key + (key << 16)) ^ (uintptr_t(shape) >> 3);
                     if (!shapes.append(shape))
                         return false;
                     pobj = pobj->getProto();