summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/branch-utils.h2
-rw-r--r--src/wasm-binary.h4
-rw-r--r--src/wasm-s-parser.h2
-rw-r--r--src/wasm.h2
-rw-r--r--src/wasm/wasm-binary.cpp27
-rw-r--r--src/wasm/wasm-s-parser.cpp2
-rw-r--r--src/wasm/wasm-validator.cpp16
7 files changed, 28 insertions, 27 deletions
diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h
index 8a4f02a58..826483b09 100644
--- a/src/ir/branch-utils.h
+++ b/src/ir/branch-utils.h
@@ -136,7 +136,7 @@ inline bool replacePossibleTarget(Expression* branch, Name from, Name to) {
}
// Replace all delegate targets within the given AST.
-inline void replaceDelegateTargets(Expression* ast, Name from, Name to) {
+inline void replaceExceptionTargets(Expression* ast, Name from, Name to) {
struct Replacer
: public PostWalker<Replacer, UnifiedExpressionVisitor<Replacer>> {
Name from, to;
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index c2a771a7d..811524d2d 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1419,7 +1419,7 @@ public:
// or not.
std::unordered_set<Name> breakTargetNames;
// the names that delegates target.
- std::unordered_set<Name> delegateTargetNames;
+ std::unordered_set<Name> exceptionTargetNames;
std::vector<Expression*> expressionStack;
@@ -1524,7 +1524,7 @@ public:
Expression* getBlockOrSingleton(Type type);
BreakTarget getBreakTarget(int32_t offset);
- Name getDelegateTargetName(int32_t offset);
+ Name getExceptionTargetName(int32_t offset);
void readMemoryAccess(Address& alignment, Address& offset);
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 92bc55d0a..bb436bbc4 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -242,7 +242,7 @@ private:
i++;
}
}
- enum class LabelType { Break, Delegate };
+ enum class LabelType { Break, Exception };
Name getLabel(Element& s, LabelType labelType = LabelType::Break);
Expression* makeBreak(Element& s);
Expression* makeBreakTable(Element& s);
diff --git a/src/wasm.h b/src/wasm.h
index 876a9bfa7..c2df1616e 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1945,4 +1945,4 @@ std::ostream& operator<<(std::ostream& o, wasm::StackIR& ir);
} // namespace std
-#endif // wasm_wasm_h \ No newline at end of file
+#endif // wasm_wasm_h
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 878293caa..c6ed1dcfb 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1920,7 +1920,7 @@ void WasmBinaryBuilder::readFunctions() {
// process body
assert(breakStack.empty());
assert(breakTargetNames.empty());
- assert(delegateTargetNames.empty());
+ assert(exceptionTargetNames.empty());
assert(breakStack.empty());
assert(expressionStack.empty());
assert(controlFlowStack.empty());
@@ -1930,7 +1930,7 @@ void WasmBinaryBuilder::readFunctions() {
assert(depth == 0);
assert(breakStack.empty());
assert(breakTargetNames.empty());
- assert(delegateTargetNames.empty());
+ assert(exceptionTargetNames.empty());
if (!expressionStack.empty()) {
throwError("stack not empty on function exit");
}
@@ -3389,7 +3389,7 @@ Expression* WasmBinaryBuilder::getBlockOrSingleton(Type type) {
block->finalize(type);
// maybe we don't need a block here?
if (breakTargetNames.find(block->name) == breakTargetNames.end() &&
- delegateTargetNames.find(block->name) == delegateTargetNames.end()) {
+ exceptionTargetNames.find(block->name) == exceptionTargetNames.end()) {
block->name = Name();
if (block->list.size() == 1) {
return block->list[0];
@@ -3465,8 +3465,8 @@ WasmBinaryBuilder::getBreakTarget(int32_t offset) {
return ret;
}
-Name WasmBinaryBuilder::getDelegateTargetName(int32_t offset) {
- BYN_TRACE("getDelegateTarget " << offset << std::endl);
+Name WasmBinaryBuilder::getExceptionTargetName(int32_t offset) {
+ BYN_TRACE("getExceptionTarget " << offset << std::endl);
// We always start parsing a function by creating a block label and pushing it
// in breakStack in getBlockOrSingleton, so if a 'delegate''s target is that
// block, it does not mean it targets that block; it throws to the caller.
@@ -3482,7 +3482,7 @@ Name WasmBinaryBuilder::getDelegateTargetName(int32_t offset) {
// if the delegate is in literally unreachable code, then we will not emit it
// anyhow, so do not note that the target has delegate to it
if (!willBeIgnored) {
- delegateTargetNames.insert(ret.name);
+ exceptionTargetNames.insert(ret.name);
}
return ret.name;
}
@@ -5832,7 +5832,7 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
breakStack.pop_back();
if (lastSeparator == BinaryConsts::Delegate) {
- curr->delegateTarget = getDelegateTargetName(getU32LEB());
+ curr->delegateTarget = getExceptionTargetName(getU32LEB());
}
// For simplicity, we make try's labels only can be targeted by delegates, and
@@ -5843,9 +5843,10 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
curr->name = getNextLabel();
if (auto* block = curr->body->dynCast<Block>()) {
if (block->name.is()) {
- if (delegateTargetNames.find(block->name) != delegateTargetNames.end()) {
- BranchUtils::replaceDelegateTargets(block, block->name, curr->name);
- delegateTargetNames.erase(block->name);
+ if (exceptionTargetNames.find(block->name) !=
+ exceptionTargetNames.end()) {
+ BranchUtils::replaceExceptionTargets(block, block->name, curr->name);
+ exceptionTargetNames.erase(block->name);
}
// maybe we don't need a block here?
if (block->list.size() == 1) {
@@ -5853,11 +5854,11 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
}
}
}
- if (delegateTargetNames.find(catchLabel) != delegateTargetNames.end()) {
+ if (exceptionTargetNames.find(catchLabel) != exceptionTargetNames.end()) {
for (auto* catchBody : curr->catchBodies) {
- BranchUtils::replaceDelegateTargets(catchBody, catchLabel, curr->name);
+ BranchUtils::replaceExceptionTargets(catchBody, catchLabel, curr->name);
}
- delegateTargetNames.erase(catchLabel);
+ exceptionTargetNames.erase(catchLabel);
}
curr->finalize(curr->type);
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index d2b24fbed..0ff4bfb9f 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2048,7 +2048,7 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) {
if (inner.size() != 2) {
throw ParseException("invalid delegate", inner.line, inner.col);
}
- ret->delegateTarget = getLabel(*inner[1], LabelType::Delegate);
+ ret->delegateTarget = getLabel(*inner[1], LabelType::Exception);
}
if (i != s.size()) {
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index beb994390..736d669fb 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -236,7 +236,7 @@ struct FunctionValidator : public WalkerPass<PostWalker<FunctionValidator>> {
};
std::unordered_map<Name, BreakInfo> breakInfos;
- std::unordered_set<Name> delegateTargetNames;
+ std::unordered_set<Name> exceptionTargetNames;
std::set<Type> returnTypes; // types used in returns
@@ -280,7 +280,7 @@ public:
static void visitPreTry(FunctionValidator* self, Expression** currp) {
auto* curr = (*currp)->cast<Try>();
if (curr->name.is()) {
- self->delegateTargetNames.insert(curr->name);
+ self->exceptionTargetNames.insert(curr->name);
}
}
@@ -300,7 +300,7 @@ public:
static void visitPreCatch(FunctionValidator* self, Expression** currp) {
auto* curr = (*currp)->cast<Try>();
if (curr->name.is()) {
- self->delegateTargetNames.erase(curr->name);
+ self->exceptionTargetNames.erase(curr->name);
}
}
@@ -376,7 +376,7 @@ public:
void visitRefIs(RefIs* curr);
void visitRefFunc(RefFunc* curr);
void visitRefEq(RefEq* curr);
- void noteDelegate(Name name, Expression* curr);
+ void noteException(Name name, Expression* curr);
void visitTry(Try* curr);
void visitThrow(Throw* curr);
void visitRethrow(Rethrow* curr);
@@ -2073,9 +2073,9 @@ void FunctionValidator::visitRefEq(RefEq* curr) {
"ref.eq's right argument should be a subtype of eqref");
}
-void FunctionValidator::noteDelegate(Name name, Expression* curr) {
+void FunctionValidator::noteException(Name name, Expression* curr) {
if (name != DELEGATE_CALLER_TARGET) {
- shouldBeTrue(delegateTargetNames.find(name) != delegateTargetNames.end(),
+ shouldBeTrue(exceptionTargetNames.find(name) != exceptionTargetNames.end(),
curr,
"all delegate targets must be valid");
}
@@ -2122,7 +2122,7 @@ void FunctionValidator::visitTry(Try* curr) {
"try should have either catches or a delegate");
if (curr->isDelegate()) {
- noteDelegate(curr->delegateTarget, curr);
+ noteException(curr->delegateTarget, curr);
}
}
@@ -2533,7 +2533,7 @@ void FunctionValidator::visitFunction(Function* curr) {
shouldBeTrue(
breakInfos.empty(), curr->body, "all named break targets must exist");
- shouldBeTrue(delegateTargetNames.empty(),
+ shouldBeTrue(exceptionTargetNames.empty(),
curr->body,
"all named delegate targets must exist");
returnTypes.clear();