From e2420f0d5d82982cd94a6400da812cf7c9818d97 Mon Sep 17 00:00:00 2001 From: Frank Emrich Date: Thu, 22 Feb 2024 20:07:07 +0000 Subject: 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. --- src/wasm/wasm-ir-builder.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/wasm/wasm-ir-builder.cpp') diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index bd3a3ad11..6676d1cb4 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -1783,6 +1783,17 @@ Result<> IRBuilder::makeStringSliceIter() { return Ok{}; } +Result<> IRBuilder::makeContNew(HeapType ct) { + if (!ct.isContinuation()) { + return Err{"expected continuation type"}; + } + ContNew curr; + CHECK_ERR(visitContNew(&curr)); + + push(builder.makeContNew(ct, curr.func)); + return Ok{}; +} + Result<> IRBuilder::makeResume(HeapType ct, const std::vector& tags, const std::vector& labels) { -- cgit v1.2.3