summaryrefslogtreecommitdiff
path: root/src/parser/parsers.h
diff options
context:
space:
mode:
authorFrank Emrich <git@emrich.io>2024-03-19 17:53:08 +0000
committerGitHub <noreply@github.com>2024-03-19 10:53:08 -0700
commit84cc9fa123e58c5ff236145a24157c098daede64 (patch)
tree9ed80b7ba904073e8b80e47e5e1105ef9b6966b0 /src/parser/parsers.h
parent63db13bf0f0f5dcc76c45a22ff43c424fa54a011 (diff)
downloadbinaryen-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/parser/parsers.h')
-rw-r--r--src/parser/parsers.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 0150af811..51b5d8f9e 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -309,6 +309,8 @@ template<typename Ctx>
Result<> makeContNew(Ctx*, Index, const std::vector<Annotation>&);
template<typename Ctx>
Result<> makeResume(Ctx&, Index, const std::vector<Annotation>&);
+template<typename Ctx>
+Result<> makeSuspend(Ctx&, Index, const std::vector<Annotation>&);
// Modules
template<typename Ctx> MaybeResult<Index> maybeTypeidx(Ctx& ctx);
@@ -2498,6 +2500,15 @@ makeResume(Ctx& ctx, Index pos, const std::vector<Annotation>& annotations) {
return ctx.makeResume(pos, annotations, *type, tagLabels);
}
+template<typename Ctx>
+Result<>
+makeSuspend(Ctx& ctx, Index pos, const std::vector<Annotation>& annotations) {
+ auto tag = tagidx(ctx);
+ CHECK_ERR(tag);
+
+ return ctx.makeSuspend(pos, annotations, *tag);
+}
+
// =======
// Modules
// =======