diff options
author | Frank Emrich <git@emrich.io> | 2024-03-19 17:53:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 10:53:08 -0700 |
commit | 84cc9fa123e58c5ff236145a24157c098daede64 (patch) | |
tree | 9ed80b7ba904073e8b80e47e5e1105ef9b6966b0 /src/wasm/wasm-validator.cpp | |
parent | 63db13bf0f0f5dcc76c45a22ff43c424fa54a011 (diff) | |
download | binaryen-84cc9fa123e58c5ff236145a24157c098daede64.tar.gz binaryen-84cc9fa123e58c5ff236145a24157c098daede64.tar.bz2 binaryen-84cc9fa123e58c5ff236145a24157c098daede64.zip |
Typed continuations: suspend instructions (#6393)
This PR is part of a series that adds basic support for the [typed
continuations/wasmfx proposal](https://github.com/wasmfx/specfx).
This particular PR adds support for the `suspend` instruction for suspending
with a given tag, documented
[here](https://github.com/wasmfx/specfx/blob/main/proposals/continuations/Overview.md#instructions).
These instructions are of the form `(suspend $tag)`. Assuming that `$tag` is
defined with _n_ `param` types `t_1` to `t_n`, the instruction consumes _n_
arguments of types `t_1` to `t_n`. Its result type is the same as the `result`
type of the tag. Thus, the folded textual representation looks like
`(suspend $tag arg1 ... argn)`.
Support for the instruction is implemented in both the old and the new wat
parser.
Note that this PR does not implement validation of the new instruction.
This PR also fixes finalization of `cont.new`, `cont.bind` and `resume` nodes in
those cases where any of their children are unreachable.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 4bb556160..0b60aed5c 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -490,6 +490,7 @@ public: void visitContBind(ContBind* curr); void visitContNew(ContNew* curr); void visitResume(Resume* curr); + void visitSuspend(Suspend* curr); void visitFunction(Function* curr); @@ -3345,6 +3346,14 @@ void FunctionValidator::visitResume(Resume* curr) { "invalid type in Resume expression"); } +void FunctionValidator::visitSuspend(Suspend* curr) { + // TODO implement actual type-checking + shouldBeTrue( + !getModule() || getModule()->features.hasTypedContinuations(), + curr, + "suspend requires typed-continuations [--enable-typed-continuations]"); +} + void FunctionValidator::visitFunction(Function* curr) { FeatureSet features; // Check for things like having a rec group with GC enabled. The type we're |