summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorFrank Emrich <git@emrich.io>2024-02-22 20:07:07 +0000
committerGitHub <noreply@github.com>2024-02-22 12:07:07 -0800
commite2420f0d5d82982cd94a6400da812cf7c9818d97 (patch)
tree4b8dfc0edfd268fe308d2bf97603ca239b7768aa /src/wasm/wasm-validator.cpp
parent2ceff4d2b3f0e3cc1565adc57e537ee3475b0da9 (diff)
downloadbinaryen-e2420f0d5d82982cd94a6400da812cf7c9818d97.tar.gz
binaryen-e2420f0d5d82982cd94a6400da812cf7c9818d97.tar.bz2
binaryen-e2420f0d5d82982cd94a6400da812cf7c9818d97.zip
Typed continuations: cont.new instructions (#6308)
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 `cont.new` instruction for creating continuations, documented [here(https://github.com/wasmfx/specfx/blob/main/proposals/continuations/Overview.md#instructions). In short, these instructions are of the form `(cont.new $ct)` where `$ct` must be a continuation type. The instruction takes a single (nullable) function reference as its argument, which means that the folded representation of the instruction is of the form `(cont.new $ct (foo ...))`. 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.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 3fbcb0bfb..d745585e5 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -487,6 +487,7 @@ public:
void visitStringIterMove(StringIterMove* curr);
void visitStringSliceWTF(StringSliceWTF* curr);
void visitStringSliceIter(StringSliceIter* curr);
+ void visitContNew(ContNew* curr);
void visitResume(Resume* curr);
void visitFunction(Function* curr);
@@ -3294,6 +3295,19 @@ void FunctionValidator::visitStringSliceIter(StringSliceIter* curr) {
"string operations require reference-types [--enable-strings]");
}
+void FunctionValidator::visitContNew(ContNew* curr) {
+ // TODO implement actual type-checking
+ shouldBeTrue(
+ !getModule() || getModule()->features.hasTypedContinuations(),
+ curr,
+ "cont.new requires typed-continuatons [--enable-typed-continuations]");
+
+ shouldBeTrue((curr->contType.isContinuation() &&
+ curr->contType.getContinuation().type.isSignature()),
+ curr,
+ "invalid type in ContNew expression");
+}
+
void FunctionValidator::visitResume(Resume* curr) {
// TODO implement actual type-checking
shouldBeTrue(