Bug 1012480 - Do not treat star generator's iterator as legacy generator's iterator in for..in loop. r=jorendorff, a=bkerensa
authorTooru Fujisawa <arai_a@mac.com>
Tue, 29 Jul 2014 03:05:46 +0900
changeset 200512 f0e283a4a325d108dd1da197f788304a1d8c874b
parent 200511 f3bb687f75c0cb8c0fd8fc43b7ce6a57082670bd
child 200513 db219b061ce240b0e38e84e08b031b21a7e7adbd
push id165
push userarai_a@mac.com
push dateFri, 16 Jan 2015 06:30:56 +0000
treeherdermozilla-esr31@f0e283a4a325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff, bkerensa
bugs1012480
milestone31.4.0
Bug 1012480 - Do not treat star generator's iterator as legacy generator's iterator in for..in loop. r=jorendorff, a=bkerensa
js/src/jit-test/tests/generators/star-generator-forin.js
js/src/jsiter.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/generators/star-generator-forin.js
@@ -0,0 +1,48 @@
+load(libdir + "eqArrayHelper.js");
+
+var iter;
+var hit;
+
+hit = 0;
+iter = function*(){ hit++; };
+assertEqArray([x for (x in iter)],
+              []);
+assertEqArray([x for each (x in iter)],
+              []);
+assertEq(hit, 0);
+
+hit = 0;
+iter = function*(){ hit++; };
+iter["foo"] = "bar";
+assertEqArray([x for (x in iter)],
+              ["foo"]);
+assertEqArray([x for each (x in iter)],
+              ["bar"]);
+assertEq(hit, 0);
+
+hit = 0;
+iter = function*(){ hit++; }();
+assertEqArray([x for (x in iter)],
+              []);
+assertEqArray([x for each (x in iter)],
+              []);
+assertEq(hit, 0);
+
+hit = 0;
+iter = function*(){ hit++; }();
+iter["foo"] = "bar";
+assertEqArray([x for (x in iter)],
+              ["foo"]);
+assertEqArray([x for each (x in iter)],
+              ["bar"]);
+assertEq(hit, 0);
+
+hit = 0;
+iter = function*(){ hit++; }();
+iter["foo"] = 10;
+iter["bar"] = 20;
+assertEqArray([x for (x in iter)].sort(),
+              ["bar", "foo"]);
+assertEqArray([x for each (x in iter)].sort(),
+              [10, 20]);
+assertEq(hit, 0);
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -1624,22 +1624,16 @@ const Class StarGeneratorObject::class_ 
     JS_EnumerateStub,
     JS_ResolveStub,
     JS_ConvertStub,
     FinalizeGenerator<StarGeneratorObject>,
     nullptr,                 /* call        */
     nullptr,                 /* hasInstance */
     nullptr,                 /* construct   */
     TraceGenerator<StarGeneratorObject>,
-    JS_NULL_CLASS_SPEC,
-    {
-        nullptr,             /* outerObject    */
-        nullptr,             /* innerObject    */
-        iterator_iteratorObject,
-    }
 };
 
 /*
  * Called from the JSOP_GENERATOR case in the interpreter, with fp referring
  * to the frame by which the generator function was activated.  Create a new
  * JSGenerator object, which contains its own InterpreterFrame that we populate
  * from *fp.  We know that upon return, the JSOP_GENERATOR opcode will return
  * from the activation in fp, so we can steal away fp->callobj and fp->argsobj