Skip to content

[dart2wasm] Support switch in sync* functions #51342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
askeksa-google opened this issue Feb 9, 2023 · 3 comments
Closed

[dart2wasm] Support switch in sync* functions #51342

askeksa-google opened this issue Feb 9, 2023 · 3 comments
Assignees
Labels
area-dart2wasm Issues for the dart2wasm compiler.

Comments

@askeksa-google
Copy link

The sync* implementation in dart2wasm currently does not support switch statements.

To implement these via the sync* CFG, each case needs a target label that the switch can jump to and which can also be jumped to by continue statements. The implementations does not need the workarounds for backwards continue that the normal switch implementation has, since this workaround is essentially already there in the form of the switch-in-loop implementation of the sync* CFG.

@askeksa-google askeksa-google added the area-dart2wasm Issues for the dart2wasm compiler. label Feb 9, 2023
@osa1 osa1 self-assigned this Apr 3, 2023
@osa1
Copy link
Member

osa1 commented Apr 3, 2023

@osa1
Copy link
Member

osa1 commented Jul 6, 2023

Just to update: we implemented switch handling in async functions using most of the same code in the CL linked above. We should find a way to either reuse the code, or in the worst case copy-paste-modify the switch handling in AsyncCodeGenerator to SyncStarCodeGenerator.

@osa1
Copy link
Member

osa1 commented May 16, 2024

I'm fixing the remaining sync* missing features and issues in https://dart-review.googlesource.com/c/sdk/+/366663.

osa1 added a commit to osa1/sdk that referenced this issue May 17, 2024
…x sync*

This is the last part of the series of patches to implement missing
sync* features and fix bugs.

Move common code generation functions between async and sync* code
generators to the state_machine library, with the name
`StateMachineCodeGenerator`.

This class allows overriding parts that differ between the async and
sync* code generators.

Fixes tests:

- co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_sync_t05
- language/sync_star/generator3_test/test1
- language/sync_star/generator3_test/test2
- language/sync_star/sync_star_exception_iterator_test
- language/sync_star/sync_star_exception_nested_test
- language/sync_star/sync_star_exception_test
- language/sync_star/sync_star_exception_current_test

Fixes dart-lang#51343.
Fixes dart-lang#51342.
osa1 added a commit to osa1/sdk that referenced this issue May 17, 2024
…x sync*

This is the last part of the series of patches to implement missing
sync* features and fix bugs.

Move common code generation functions between async and sync* code
generators to the state_machine library, with the name
`StateMachineCodeGenerator`.

This class allows overriding parts that differ between the async and
sync* code generators.

Fixes tests:

- co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_sync_t05
- language/sync_star/generator3_test/test1
- language/sync_star/generator3_test/test2
- language/sync_star/sync_star_exception_iterator_test
- language/sync_star/sync_star_exception_nested_test
- language/sync_star/sync_star_exception_test
- language/sync_star/sync_star_exception_current_test

Fixes dart-lang#51343.
Fixes dart-lang#51342.

Change-Id: Ife6eab43b2721b003ebf9bc0f03796748fd5df46
copybara-service bot pushed a commit that referenced this issue May 29, 2024
This cherry-picks commits:

6de879e - [dart2wasm] Fix exception handling in async functions
7e237a1 - [dart2wasm] Small refactoring in async code generator
eabb2b3 - [dart2wasm] Catch JS exceptions in async functions
e44bc22 - [dart2wasm] Fix bug in restoration of `this` in async functions.
350954a - [dart2wasm] Fix `this` restoration code in sync* handling.
8ccb412 - [dart2wasm] Move type parameter bounds checks & parameter type check logic together with logic setting up variables
e7dde83 - [dart2wasm] Port VM fix for #52083 (sync*)
3863e78 - [dart2wasm] Move yield finder to a shared library
829261e - [dart2wasm] Move async compiler utilities to state_machine library
fab56db - [dart2wasm] Move common code generation routines to state_machine, fix sync*

Bugs: #55347, #55457, #51343, #51342
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/368300
Cherry-pick-request: #55847
Change-Id: I0a4186533fbdf4c5727911295ad48696a90f715f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368300
Commit-Queue: Ömer Ağacan <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart2wasm Issues for the dart2wasm compiler.
Projects
None yet
Development

No branches or pull requests

2 participants