summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2020-05-15 13:29:40 -0700
committerGitHub <noreply@github.com>2020-05-15 13:29:40 -0700
commitbe61c69e3921d969fdb4743d31b289429aa280c0 (patch)
tree9460cc126f08105a069d48a837c84adf00ef5e5b /src/wasm-interpreter.h
parent954acedd317817708ad4a20a29bd6b879086396a (diff)
downloadbinaryen-be61c69e3921d969fdb4743d31b289429aa280c0.tar.gz
binaryen-be61c69e3921d969fdb4743d31b289429aa280c0.tar.bz2
binaryen-be61c69e3921d969fdb4743d31b289429aa280c0.zip
Fix br_on_exn handling in ReFinalize (#2854)
In `ReFinalize`'s branch handling, `updateBreakValueType` is supposed to be executed only when the branch itself is not replaced with its argument (because it is guaranteed not to be taken). Also this moves `visitBrOnExn` from `RuntimeExpressionRunner` to its base class `ExpressionRunner`, because it does not depend on anything on the runtime instance to work. This is effectively NFC for now because `visitTry` is still only implemented only in `RuntimeExpressionRunner` because it relies on multivalue handling of it, and without it we cannot create a valid exception `Literal`.
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 257a0670f..b0118231e 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1270,7 +1270,24 @@ public:
throwException(flow.getSingleValue());
WASM_UNREACHABLE("rethrow");
}
- Flow visitBrOnExn(BrOnExn* curr) { WASM_UNREACHABLE("unimp"); }
+ Flow visitBrOnExn(BrOnExn* curr) {
+ NOTE_ENTER("BrOnExn");
+ Flow flow = this->visit(curr->exnref);
+ if (flow.breaking()) {
+ return flow;
+ }
+ if (flow.getType() == Type::nullref) {
+ trap("br_on_exn: argument is null");
+ }
+ const ExceptionPackage& ex = flow.getSingleValue().getExceptionPackage();
+ if (curr->event != ex.event) { // Not taken
+ return flow;
+ }
+ // Taken
+ flow.values = ex.values;
+ flow.breakTo = curr->name;
+ return flow;
+ }
virtual void trap(const char* why) { WASM_UNREACHABLE("unimp"); }
@@ -1514,10 +1531,6 @@ public:
NOTE_ENTER("Try");
return Flow(NONCONSTANT_FLOW);
}
- Flow visitBrOnExn(BrOnExn* curr) {
- NOTE_ENTER("BrOnExn");
- return Flow(NONCONSTANT_FLOW);
- }
void trap(const char* why) override { throw NonconstantException(); }
@@ -2410,24 +2423,6 @@ private:
return this->visit(curr->catchBody);
}
}
- Flow visitBrOnExn(BrOnExn* curr) {
- NOTE_ENTER("BrOnExn");
- Flow flow = this->visit(curr->exnref);
- if (flow.breaking()) {
- return flow;
- }
- if (flow.getType() == Type::nullref) {
- trap("br_on_exn: argument is null");
- }
- const ExceptionPackage& ex = flow.getSingleValue().getExceptionPackage();
- if (curr->event != ex.event) { // Not taken
- return flow;
- }
- // Taken
- flow.values = ex.values;
- flow.breakTo = curr->name;
- return flow;
- }
Flow visitPush(Push* curr) {
NOTE_ENTER("Push");
Flow value = this->visit(curr->value);