summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-01-28 00:18:43 +0000
committerGitHub <noreply@github.com>2021-01-27 16:18:43 -0800
commit53c471a445ef26eac7befc3f3a5e0a53870df8cb (patch)
tree419fb53072864affda454f942528416c258136c8 /src/wasm/wasm-s-parser.cpp
parenta5aa66c52e0b92597a3b90cf34ccc3b7dee775d0 (diff)
downloadbinaryen-53c471a445ef26eac7befc3f3a5e0a53870df8cb.tar.gz
binaryen-53c471a445ef26eac7befc3f3a5e0a53870df8cb.tar.bz2
binaryen-53c471a445ef26eac7befc3f3a5e0a53870df8cb.zip
[GC] Update br_on_cast: the text format also no longer has a heap type (#3523)
As a result, we cannot handle a br_on_cast with an unreachable RTT. The binary format solves the problem by ignoring unreachable code, and this makes the text format do the same. A nice benefit of this is that we can remove the castType extra field.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 5dec22eb3..9cf2f3be9 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -2132,11 +2132,16 @@ Expression* SExpressionWasmBuilder::makeRefCast(Element& s) {
Expression* SExpressionWasmBuilder::makeBrOnCast(Element& s) {
auto name = getLabel(*s[1]);
- auto heapType = parseHeapType(*s[2]);
- auto* ref = parseExpression(*s[3]);
- auto* rtt = parseExpression(*s[4]);
- validateHeapTypeUsingChild(rtt, heapType, s);
- return Builder(wasm).makeBrOnCast(name, heapType, ref, rtt);
+ auto* ref = parseExpression(*s[2]);
+ auto* rtt = parseExpression(*s[3]);
+ Builder builder(wasm);
+ if (rtt->type == Type::unreachable) {
+ // An unreachable rtt is not supported: the text format does not provide the
+ // type, so if it's unreachable we should not even create a br_on_cast in
+ // such a case, as we'd have no idea what it casts to.
+ return builder.makeSequence(builder.makeDrop(ref), rtt);
+ }
+ return builder.makeBrOnCast(name, ref, rtt);
}
Expression* SExpressionWasmBuilder::makeRttCanon(Element& s) {