Skip to content

[Parser] Parse throw_ref #6238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/parser/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{}; }
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/wasm-ir-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class IRBuilder : public UnifiedExpressionVisitor<IRBuilder, Result<>> {
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);
Expand Down
1 change: 1 addition & 0 deletions src/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,7 @@ class Rethrow : public SpecificExpression<Expression::RethrowId> {
// 'throw_ref' from the new EH proposal
class ThrowRef : public SpecificExpression<Expression::ThrowRefId> {
public:
ThrowRef() = default;
ThrowRef(MixedArena& allocator) {}

Expression* exnref;
Expand Down
7 changes: 6 additions & 1 deletion src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading