From e16cf5818de5a6e37ffcbce0bcde320290d9f9f1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 11 Dec 2020 08:27:43 -0800 Subject: [GC] Add ref.test and ref.cast (#3439) This adds enough to read and write them and test that, but leaves interpreter support for later. --- src/wasm/wasm-s-parser.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index b9f321b14..85bc2aba9 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2093,17 +2093,19 @@ Expression* SExpressionWasmBuilder::makeI31Get(Element& s, bool signed_) { } Expression* SExpressionWasmBuilder::makeRefTest(Element& s) { - auto ret = allocator.alloc(); - WASM_UNREACHABLE("TODO (gc): ref.test"); - ret->finalize(); - return ret; + auto heapType = parseHeapType(*s[1]); + auto* ref = parseExpression(*s[2]); + auto* rtt = parseExpression(*s[3]); + validateHeapTypeUsingChild(rtt, heapType, s); + return Builder(wasm).makeRefTest(ref, rtt); } Expression* SExpressionWasmBuilder::makeRefCast(Element& s) { - auto ret = allocator.alloc(); - WASM_UNREACHABLE("TODO (gc): ref.cast"); - ret->finalize(); - return ret; + auto heapType = parseHeapType(*s[1]); + auto* ref = parseExpression(*s[2]); + auto* rtt = parseExpression(*s[3]); + validateHeapTypeUsingChild(rtt, heapType, s); + return Builder(wasm).makeRefCast(ref, rtt); } Expression* SExpressionWasmBuilder::makeBrOnCast(Element& s) { -- cgit v1.2.3