diff options
author | Heejin Ahn <aheejin@gmail.com> | 2024-01-02 17:30:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 17:30:55 -0800 |
commit | 260fdfcdaaeba3f4a47ef057db28c61203c8d3b1 (patch) | |
tree | 18f30c1331e88d43b07acbf89a9aa79295b25844 /src | |
parent | 4acd47676c0eb91550a448920395ce45bd86ec50 (diff) | |
download | binaryen-260fdfcdaaeba3f4a47ef057db28c61203c8d3b1.tar.gz binaryen-260fdfcdaaeba3f4a47ef057db28c61203c8d3b1.tar.bz2 binaryen-260fdfcdaaeba3f4a47ef057db28c61203c8d3b1.zip |
[EH] Misc. fixes for EH (#6195)
- Deletes a stray whitespace after `throw_ref`
- Adds missing `makeThrowRef` to `wasm-builder.h`
- Adds a case for `TryTable` in `ControlFlowWalker`
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/Print.cpp | 2 | ||||
-rw-r--r-- | src/wasm-builder.h | 6 | ||||
-rw-r--r-- | src/wasm-traversal.h | 14 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 5ea62c9f2..5e290ebca 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2018,7 +2018,7 @@ struct PrintExpressionContents printMedium(o, "rethrow "); printName(curr->target, o); } - void visitThrowRef(ThrowRef* curr) { printMedium(o, "throw_ref "); } + void visitThrowRef(ThrowRef* curr) { printMedium(o, "throw_ref"); } void visitNop(Nop* curr) { printMinor(o, "nop"); } void visitUnreachable(Unreachable* curr) { printMinor(o, "unreachable"); } void visitPop(Pop* curr) { diff --git a/src/wasm-builder.h b/src/wasm-builder.h index dd5b498be..a873a7309 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -836,6 +836,12 @@ public: ret->finalize(); return ret; } + ThrowRef* makeThrowRef(Expression* exnref) { + auto* ret = wasm.allocator.alloc<ThrowRef>(); + ret->exnref = exnref; + ret->finalize(); + return ret; + } Unreachable* makeUnreachable() { return wasm.allocator.alloc<Unreachable>(); } Pop* makePop(Type type) { auto* ret = wasm.allocator.alloc<Pop>(); diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 1a458bdf7..f5f25dd1f 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -403,7 +403,8 @@ using ExpressionStack = SmallVector<Expression*, 10>; template<typename SubType, typename VisitorType = Visitor<SubType>> struct ControlFlowWalker : public PostWalker<SubType, VisitorType> { - ExpressionStack controlFlowStack; // contains blocks, loops, and ifs + // contains blocks, loops, ifs, trys, and try_tables + ExpressionStack controlFlowStack; // Uses the control flow stack to find the target of a break to a name Expression* findBreakTarget(Name name) { @@ -420,8 +421,9 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> { return curr; } } else { - // an if or try, ignorable - assert(curr->template is<If>() || curr->template is<Try>()); + // an if, try, or try_table, ignorable + assert(curr->template is<If>() || curr->template is<Try>() || + curr->template is<TryTable>()); } if (i == 0) { return nullptr; @@ -447,7 +449,8 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> { case Expression::Id::BlockId: case Expression::Id::IfId: case Expression::Id::LoopId: - case Expression::Id::TryId: { + case Expression::Id::TryId: + case Expression::Id::TryTableId: { self->pushTask(SubType::doPostVisitControlFlow, currp); break; } @@ -461,7 +464,8 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> { case Expression::Id::BlockId: case Expression::Id::IfId: case Expression::Id::LoopId: - case Expression::Id::TryId: { + case Expression::Id::TryId: + case Expression::Id::TryTableId: { self->pushTask(SubType::doPreVisitControlFlow, currp); break; } |