is an iterator allowed to reuse the same "state" object?

Andreas Rossberg rossberg at
Wed Apr 29 22:41:20 UTC 2015

On 29 April 2015 at 18:37, Brendan Eich <brendan at> wrote:

> Andreas Rossberg wrote:
>> On 29 April 2015 at 02:21, John Lenz <concavelenz at <mailto:
>> concavelenz at>> wrote:
>>     I missed it, thanks.    I know things will improve in time but I'm
>>     just coming from a discussion with folks complaining about the
>>     performance of generators and GC overhead in real code with Chrome
>>     and Firefox relative to simple hand written loops.
>> Note that there is a huge difference between optimising iterators (in
>> particular, for-of), and optimising generators. I expect that VMs will
>> start getting better on the former relatively soon, for iterators that are
>> not generators. Making generators fast is a much more complicated problem.
> But in either case, escape analysis and object allocation elimination can
> avoid the flood of eden objects John cited, right?

Yes, together with inlining.

I'm inferring your comment about generator optimization hardship has to do
> with a function that yields -- whose CFG has multiple entry points and
> whose activation record must live in the heap.

Yes, the biggest challenge perhaps is not even generator CFGs per se, but
getting inlining to work with them, which is necessary to take advantage of
escape analysis.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list