Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upShould yield* preserve iteration result identity? #1058
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gskachkov
commented
Jan 4, 2018
•
|
In JSC we have a issue to fix this behaviour. cc @Constellation |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
@gskachkov Link to the issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gskachkov
commented
Jan 4, 2018
|
Should be that one https://bugs.webkit.org/show_bug.cgi?id=174756 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
caitp
Jan 4, 2018
Contributor
I’m not sure we should fix it unless there’s a good reason to with real code depending on the identity preserving behaviour.
|
I’m not sure we should fix it unless there’s a good reason to with real code depending on the identity preserving behaviour. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
littledan
Jan 4, 2018
Member
I think there's value in all implementations being on the same page about which value is returned where.
|
I think there's value in all implementations being on the same page about which value is returned where. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
littledan commentedJan 4, 2018
The runtime semantics for
yield*seem to forward out the exact iteration result that was provided in the inner iterator. See step 6.a.iv. At the bottom of this post is a quick test I wrote to expose the semantics; the spec's semantics are implemented by 3/4 of the engines I tested.In this V8 bug, some optimizations to generators are discussed. It seems that, if generators always output a new iteration result, it would be possible to move the iteration result allocation to the caller side, enabling unboxing even if the generator can't be inlined. @caitp prototyped this optimization and got a significant speedup. However, current
yield*semantics don't permit this optimization, and @bmeurer judges it to be infeasible to make this work otherwise.Alternate semantics are implemented by JSC (cc @kmiller68 @msaboff), where
yield*always creates a new iteration result. For a naive implementation, the current specification may be slightly faster by avoiding the allocation in theyield*case, but in a more advanced implementation, JSC's semantics could enable a much greater level of avoiding allocations.Does anyone have information about how the current
yield*semantics were chosen?cc @dherman @allenwb