summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-01-25 13:00:43 -0800
committerGitHub <noreply@github.com>2024-01-25 13:00:43 -0800
commit976bd6da4a54505ffc65f18913fbb9aff652e72d (patch)
treea29031de8dcc8a4d100dce500660b40035ae269a /src
parent482f3aaf90167cb187ccbc6f1e32dcdb574e3f73 (diff)
downloadbinaryen-976bd6da4a54505ffc65f18913fbb9aff652e72d.tar.gz
binaryen-976bd6da4a54505ffc65f18913fbb9aff652e72d.tar.bz2
binaryen-976bd6da4a54505ffc65f18913fbb9aff652e72d.zip
[Parser] Parse throw_ref (#6238)
Diffstat (limited to 'src')
-rw-r--r--src/parser/contexts.h5
-rw-r--r--src/parser/parsers.h2
-rw-r--r--src/wasm-ir-builder.h2
-rw-r--r--src/wasm.h1
-rw-r--r--src/wasm/wasm-ir-builder.cpp7
5 files changed, 14 insertions, 3 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h
index 8f74502ad..fb9218cbc 100644
--- a/src/parser/contexts.h
+++ b/src/parser/contexts.h
@@ -453,6 +453,7 @@ struct NullInstrParserCtx {
Result<> makeTableCopy(Index, TableIdxT*, TableIdxT*) { return Ok{}; }
Result<> makeThrow(Index, TagIdxT) { return Ok{}; }
Result<> makeRethrow(Index, LabelIdxT) { return Ok{}; }
+ Result<> makeThrowRef(Index) { return Ok{}; }
Result<> makeTupleMake(Index, uint32_t) { return Ok{}; }
Result<> makeTupleExtract(Index, uint32_t, uint32_t) { return Ok{}; }
Result<> makeTupleDrop(Index, uint32_t) { return Ok{}; }
@@ -1721,6 +1722,10 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
return withLoc(pos, irBuilder.makeRethrow(label));
}
+ Result<> makeThrowRef(Index pos) {
+ return withLoc(pos, irBuilder.makeThrowRef());
+ }
+
Result<> makeTupleMake(Index pos, uint32_t arity) {
return withLoc(pos, irBuilder.makeTupleMake(arity));
}
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 73a7d0035..0c7c5550f 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -1646,7 +1646,7 @@ template<typename Ctx> Result<> makeRethrow(Ctx& ctx, Index pos) {
}
template<typename Ctx> Result<> makeThrowRef(Ctx& ctx, Index pos) {
- return ctx.in.err("unimplemented instruction");
+ return ctx.makeThrowRef(pos);
}
template<typename Ctx> Result<> makeTupleMake(Ctx& ctx, Index pos) {
diff --git a/src/wasm-ir-builder.h b/src/wasm-ir-builder.h
index 343ef998e..77ad2490e 100644
--- a/src/wasm-ir-builder.h
+++ b/src/wasm-ir-builder.h
@@ -164,7 +164,7 @@ public:
const std::vector<bool>& isRefs);
[[nodiscard]] Result<> makeThrow(Name tag);
[[nodiscard]] Result<> makeRethrow(Index label);
- // [[nodiscard]] Result<> makeThrowRef();
+ [[nodiscard]] Result<> makeThrowRef();
[[nodiscard]] Result<> makeTupleMake(uint32_t arity);
[[nodiscard]] Result<> makeTupleExtract(uint32_t arity, uint32_t index);
[[nodiscard]] Result<> makeTupleDrop(uint32_t arity);
diff --git a/src/wasm.h b/src/wasm.h
index 451039d45..366aa7302 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1522,6 +1522,7 @@ public:
// 'throw_ref' from the new EH proposal
class ThrowRef : public SpecificExpression<Expression::ThrowRefId> {
public:
+ ThrowRef() = default;
ThrowRef(MixedArena& allocator) {}
Expression* exnref;
diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp
index 14b9046ef..aace2b1ac 100644
--- a/src/wasm/wasm-ir-builder.cpp
+++ b/src/wasm/wasm-ir-builder.cpp
@@ -1390,7 +1390,12 @@ Result<> IRBuilder::makeRethrow(Index label) {
return Ok{};
}
-// Result<> IRBuilder::makeThrowRef() {}
+Result<> IRBuilder::makeThrowRef() {
+ ThrowRef curr;
+ CHECK_ERR(visitThrowRef(&curr));
+ push(builder.makeThrowRef(curr.exnref));
+ return Ok{};
+}
Result<> IRBuilder::makeTupleMake(uint32_t arity) {
TupleMake curr(wasm.allocator);