April 10 2014 Meeting Notes
jason.orendorff at gmail.com
Thu Apr 24 11:54:20 PDT 2014
On Tue, Apr 15, 2014 at 10:24 AM, Andreas Rossberg <rossberg at google.com> wrote:
>> AWB: We _could_ add a `return()` method.
>> ... It's a bigger change, but we could make for-of invoke `return()` on exit
>> or completion
> This would be a _significant_ cost. One reason we got rid of the
> StopIteration protocol was the performance cost incurred by having to
> wrap all loops into implicit try-statements, which are costly. This
> proposal asks for re-introducing the same cost.
I think the concern was more about the implicit throw than the
implicit try-catch. That is, the StopIteration protocol required not
only being prepared to catch an exception, but *actually throwing and
catching an exception* at the end of every for-of loop.
In SpiderMonkey, at least, throwing an exception is a performance
cliff. It can involve re-compiling code in a less optimized
mode---that kind of thing.
A try-catch is not so bad. Some optimizations like phi elimination are
less aggressive, which we think probably doesn't matter much. Also, a
function that contains a try-catch can't be inlined at the moment--but
that could be fixed, and it's even less likely to matter here.
More information about the es-discuss