summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp6
-rw-r--r--src/passes/StackIR.cpp9
-rw-r--r--src/wasm-stack.h30
-rw-r--r--src/wasm/wasm-stack.cpp23
4 files changed, 41 insertions, 27 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 948e8d239..ecdfe16eb 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -3550,7 +3550,8 @@ static std::ostream& printStackIR(StackIR* ir, PrintSExpression& printer) {
[[fallthrough]];
case StackInst::BlockBegin:
case StackInst::IfBegin:
- case StackInst::LoopBegin: {
+ case StackInst::LoopBegin:
+ case StackInst::TryTableBegin: {
controlFlowDepth++;
doIndent();
PrintExpressionContents(printer).visit(inst->origin);
@@ -3562,7 +3563,8 @@ static std::ostream& printStackIR(StackIR* ir, PrintSExpression& printer) {
[[fallthrough]];
case StackInst::BlockEnd:
case StackInst::IfEnd:
- case StackInst::LoopEnd: {
+ case StackInst::LoopEnd:
+ case StackInst::TryTableEnd: {
controlFlowDepth--;
indent--;
doIndent();
diff --git a/src/passes/StackIR.cpp b/src/passes/StackIR.cpp
index c57bea83f..24b4fcbe8 100644
--- a/src/passes/StackIR.cpp
+++ b/src/passes/StackIR.cpp
@@ -292,7 +292,8 @@ private:
case StackInst::Catch:
case StackInst::CatchAll:
case StackInst::Delegate:
- case StackInst::TryEnd: {
+ case StackInst::TryEnd:
+ case StackInst::TryTableEnd: {
return true;
}
default: { return false; }
@@ -305,7 +306,8 @@ private:
case StackInst::BlockBegin:
case StackInst::IfBegin:
case StackInst::LoopBegin:
- case StackInst::TryBegin: {
+ case StackInst::TryBegin:
+ case StackInst::TryTableBegin: {
return true;
}
default: { return false; }
@@ -319,7 +321,8 @@ private:
case StackInst::IfEnd:
case StackInst::LoopEnd:
case StackInst::TryEnd:
- case StackInst::Delegate: {
+ case StackInst::Delegate:
+ case StackInst::TryTableEnd: {
return true;
}
default: { return false; }
diff --git a/src/wasm-stack.h b/src/wasm-stack.h
index a195f1a84..de8fd8b03 100644
--- a/src/wasm-stack.h
+++ b/src/wasm-stack.h
@@ -60,20 +60,22 @@ public:
StackInst(MixedArena&) {}
enum Op {
- Basic, // an instruction directly corresponding to a non-control-flow
- // Binaryen IR node
- BlockBegin, // the beginning of a block
- BlockEnd, // the ending of a block
- IfBegin, // the beginning of a if
- IfElse, // the else of a if
- IfEnd, // the ending of a if
- LoopBegin, // the beginning of a loop
- LoopEnd, // the ending of a loop
- TryBegin, // the beginning of a try
- Catch, // the catch within a try
- CatchAll, // the catch_all within a try
- Delegate, // the delegate within a try
- TryEnd // the ending of a try
+ Basic, // an instruction directly corresponding to a
+ // non-control-flow Binaryen IR node
+ BlockBegin, // the beginning of a block
+ BlockEnd, // the ending of a block
+ IfBegin, // the beginning of a if
+ IfElse, // the else of a if
+ IfEnd, // the ending of a if
+ LoopBegin, // the beginning of a loop
+ LoopEnd, // the ending of a loop
+ TryBegin, // the beginning of a try
+ Catch, // the catch within a try
+ CatchAll, // the catch_all within a try
+ Delegate, // the delegate within a try
+ TryEnd, // the ending of a try
+ TryTableBegin, // the beginning of a try_table
+ TryTableEnd // the ending of a try_table
} op;
Expression* origin; // the expression this originates from
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;
}