summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-10-09 10:42:07 -0700
committerGitHub <noreply@github.com>2020-10-09 10:42:07 -0700
commit13351616886ad7d31528c6349ea397dbc6100778 (patch)
tree8eaabb3d4387bb6facdc370ce9742f6ee6b90440 /src
parent9d50c1f4a7fb81ead03a2b8445655f157553fa1b (diff)
downloadbinaryen-13351616886ad7d31528c6349ea397dbc6100778.tar.gz
binaryen-13351616886ad7d31528c6349ea397dbc6100778.tar.bz2
binaryen-13351616886ad7d31528c6349ea397dbc6100778.zip
Add a little code to prepare exception handling support in fuzzer (#3207)
fixLabels() in the fuzzer looks for invalid labels and fixes them up, after doing some random changes to existing wasm (which checks for types while doing so, but it may invalidate labels if we remove the target of a branch, for example). This adds trivial support for BrOnExn and Try there.
Diffstat (limited to 'src')
-rw-r--r--src/tools/fuzzing.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index 088aa3c96..475747056 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -729,6 +729,8 @@ private:
void visitBreak(Break* curr) { replaceIfInvalid(curr->name); }
+ void visitBrOnExn(BrOnExn* curr) { replaceIfInvalid(curr->name); }
+
bool replaceIfInvalid(Name target) {
if (!hasBreakTarget(target)) {
// There is no valid parent, replace with something trivially safe.
@@ -747,17 +749,17 @@ private:
Index i = controlFlowStack.size() - 1;
while (1) {
auto* curr = controlFlowStack[i];
- if (Block* block = curr->dynCast<Block>()) {
+ if (auto* block = curr->dynCast<Block>()) {
if (name == block->name) {
return true;
}
- } else if (Loop* loop = curr->dynCast<Loop>()) {
+ } else if (auto* loop = curr->dynCast<Loop>()) {
if (name == loop->name) {
return true;
}
} else {
- // an if, ignorable
- assert(curr->is<If>());
+ // an if or a try, ignorable
+ assert(curr->is<If>() || curr->is<Try>());
}
if (i == 0) {
return false;