summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-01-22 19:26:17 -0800
committerGitHub <noreply@github.com>2024-01-22 19:26:17 -0800
commitc23253fa9fb8ab49bc922cf35448ebd3cf0b6789 (patch)
tree0175bf6e0a969da4d6034b70ab7d43cea84c84eb /src/wasm
parente06e17e60cfff8a17d00202e208c11c483bedee8 (diff)
downloadbinaryen-c23253fa9fb8ab49bc922cf35448ebd3cf0b6789.tar.gz
binaryen-c23253fa9fb8ab49bc922cf35448ebd3cf0b6789.tar.bz2
binaryen-c23253fa9fb8ab49bc922cf35448ebd3cf0b6789.zip
[EH] Support Stack IR for try_table (#6231)
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-stack.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 6a2fd8468..12ce68324 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -16,6 +16,7 @@
#include "wasm-stack.h"
#include "ir/find_all.h"
+#include "ir/properties.h"
#include "wasm-binary.h"
#include "wasm-debug.h"
@@ -2680,6 +2681,8 @@ void StackIRGenerator::emit(Expression* curr) {
stackInst = makeStackInst(StackInst::LoopBegin, curr);
} else if (curr->is<Try>()) {
stackInst = makeStackInst(StackInst::TryBegin, curr);
+ } else if (curr->is<TryTable>()) {
+ stackInst = makeStackInst(StackInst::TryTableBegin, curr);
} else {
stackInst = makeStackInst(curr);
}
@@ -2696,6 +2699,8 @@ void StackIRGenerator::emitScopeEnd(Expression* curr) {
stackInst = makeStackInst(StackInst::LoopEnd, curr);
} else if (curr->is<Try>()) {
stackInst = makeStackInst(StackInst::TryEnd, curr);
+ } else if (curr->is<TryTable>()) {
+ stackInst = makeStackInst(StackInst::TryTableEnd, curr);
} else {
WASM_UNREACHABLE("unexpected expr type");
}
@@ -2708,15 +2713,15 @@ StackInst* StackIRGenerator::makeStackInst(StackInst::Op op,
ret->op = op;
ret->origin = origin;
auto stackType = origin->type;
- if (origin->is<Block>() || origin->is<Loop>() || origin->is<If>() ||
- origin->is<Try>()) {
+ if (Properties::isControlFlowStructure(origin)) {
if (stackType == Type::unreachable) {
- // There are no unreachable blocks, loops, or ifs. we emit extra
- // unreachables to fix that up, so that they are valid as having none
- // type.
+ // There are no unreachable blocks, loops, ifs, trys, or try_tables. we
+ // emit extra unreachables to fix that up, so that they are valid as
+ // having none type.
stackType = Type::none;
} else if (op != StackInst::BlockEnd && op != StackInst::IfEnd &&
- op != StackInst::LoopEnd && op != StackInst::TryEnd) {
+ op != StackInst::LoopEnd && op != StackInst::TryEnd &&
+ op != StackInst::TryTableEnd) {
// If a concrete type is returned, we mark the end of the construct has
// having that type (as it is pushed to the value stack at that point),
// other parts are marked as none).
@@ -2742,7 +2747,8 @@ void StackIRToBinaryWriter::write() {
case StackInst::Basic:
case StackInst::BlockBegin:
case StackInst::IfBegin:
- case StackInst::LoopBegin: {
+ case StackInst::LoopBegin:
+ case StackInst::TryTableBegin: {
writer.visit(inst->origin);
break;
}
@@ -2751,7 +2757,8 @@ void StackIRToBinaryWriter::write() {
[[fallthrough]];
case StackInst::BlockEnd:
case StackInst::IfEnd:
- case StackInst::LoopEnd: {
+ case StackInst::LoopEnd:
+ case StackInst::TryTableEnd: {
writer.emitScopeEnd(inst->origin);
break;
}