summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-02-01 22:44:40 +0000
committerGitHub <noreply@github.com>2021-02-01 14:44:40 -0800
commiteafb0a4ef25cd82317ac8fa84a9d7e58f9382fcc (patch)
tree7284b2c93d1416dd898f297792fc00a11dac0ed7 /src/wasm-interpreter.h
parent02f8c56aad18a2715904d1d5e0951b25bf7749c3 (diff)
downloadbinaryen-eafb0a4ef25cd82317ac8fa84a9d7e58f9382fcc.tar.gz
binaryen-eafb0a4ef25cd82317ac8fa84a9d7e58f9382fcc.tar.bz2
binaryen-eafb0a4ef25cd82317ac8fa84a9d7e58f9382fcc.zip
[GC] br_on_null (#3528)
This is only partial support, as br_on_null also has an extra optional value in the spec. Implementing that is cumbersome in binaryen, and there is ongoing spec discussions about it (see https://github.com/WebAssembly/function-references/issues/45 ), so for now we only support the simple case without the default value. Also fix prefixed opcodes to be LEBs in RefAs, which was noticed here as the change here made it noticeable whether the values were int8 or LEBs.
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 26c86efe6..ac64a30c0 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1490,6 +1490,15 @@ public:
}
const auto& value = flow.getSingleValue();
NOTE_EVAL1(value);
+ if (curr->op == BrOnNull) {
+ // Unlike the others, BrOnNull does not propagate the value if it takes
+ // the branch.
+ if (value.isNull()) {
+ return Flow(curr->name);
+ }
+ // If the branch is not taken, we return the non-null value.
+ return {value};
+ }
if (value.isNull()) {
return {value};
}