Skip to content

[dart2wasm] Support try/catch/finally in sync* functions #51343

Closed
@askeksa-google

Description

@askeksa-google

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

To implement these via the sync* CFG, each try block needs to be split into individual Wasm try blocks covering each of the sync* CFG blocks that are covered by the original try.

The catch blocks need not be duplicated. They can be separate CFG blocks targeted by the try blocks.

Also, finally blocks can probably be reused between the various control flow chains (normal completion, exception thrown, return from function) rather than being duplicated as in the normal implementation. One local for each finally block could contain the target index of where the execution needs to go after the execution of the finally block completes. Care must be taken to make this interact properly with normal finally blocks (those not containing any yield or yield* and therefore translated by the normal code generator). Either the CFG-based finally statements must properly maintain the stack of finalizers for the normal code generator, such that it properly duplicates these finalizers on return or exceptions, or all try/finally statements in a sync* functions must be translated via the CFG, even if they do not contain any yield or yield*.

Metadata

Metadata

Assignees

Labels

area-dart2wasmIssues for the dart2wasm compiler.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions