diff options
45 files changed, 752 insertions, 612 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 80a62a197..349f93362 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -567,29 +567,32 @@ instructions = [ ("i31.new", "makeI31New(s)"), ("i31.get_s", "makeI31Get(s, true)"), ("i31.get_u", "makeI31Get(s, false)"), - ("ref.test_static", "makeRefTestStatic(s)"), - ("ref.cast_static", "makeRefCastStatic(s)"), - ("ref.cast_nop_static", "makeRefCastNopStatic(s)"), + ("ref.test", "makeRefTest(s)"), + ("ref.test_static", "makeRefTest(s)"), + ("ref.cast", "makeRefCast(s)"), + ("ref.cast_static", "makeRefCast(s)"), + ("ref.cast_nop", "makeRefCastNop(s)"), + ("ref.cast_nop_static", "makeRefCastNop(s)"), ("br_on_null", "makeBrOn(s, BrOnNull)"), ("br_on_non_null", "makeBrOn(s, BrOnNonNull)"), ("br_on_cast", "makeBrOn(s, BrOnCast)"), - ("br_on_cast_static", "makeBrOnStatic(s, BrOnCast)"), + ("br_on_cast_static", "makeBrOn(s, BrOnCast)"), ("br_on_cast_fail", "makeBrOn(s, BrOnCastFail)"), - ("br_on_cast_static_fail", "makeBrOnStatic(s, BrOnCastFail)"), + ("br_on_cast_static_fail", "makeBrOn(s, BrOnCastFail)"), ("br_on_func", "makeBrOn(s, BrOnFunc)"), ("br_on_non_func", "makeBrOn(s, BrOnNonFunc)"), ("br_on_data", "makeBrOn(s, BrOnData)"), ("br_on_non_data", "makeBrOn(s, BrOnNonData)"), ("br_on_i31", "makeBrOn(s, BrOnI31)"), ("br_on_non_i31", "makeBrOn(s, BrOnNonI31)"), - ("struct.new", "makeStructNewStatic(s, false)"), - ("struct.new_default", "makeStructNewStatic(s, true)"), + ("struct.new", "makeStructNew(s, false)"), + ("struct.new_default", "makeStructNew(s, true)"), ("struct.get", "makeStructGet(s)"), ("struct.get_s", "makeStructGet(s, true)"), ("struct.get_u", "makeStructGet(s, false)"), ("struct.set", "makeStructSet(s)"), - ("array.new", "makeArrayNewStatic(s, false)"), - ("array.new_default", "makeArrayNewStatic(s, true)"), + ("array.new", "makeArrayNew(s, false)"), + ("array.new_default", "makeArrayNew(s, true)"), ("array.new_data", "makeArrayNewSeg(s, NewData)"), ("array.new_elem", "makeArrayNewSeg(s, NewElem)"), ("array.init_static", "makeArrayInitStatic(s)"), diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 929634c6c..dc5dae035 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -45,7 +45,7 @@ switch (op[0]) { case 'n': { switch (op[9]) { case '\0': - if (op == "array.new"sv) { return makeArrayNewStatic(s, false); } + if (op == "array.new"sv) { return makeArrayNew(s, false); } goto parse_error; case '_': { switch (op[10]) { @@ -55,7 +55,7 @@ switch (op[0]) { if (op == "array.new_data"sv) { return makeArrayNewSeg(s, NewData); } goto parse_error; case 'e': - if (op == "array.new_default"sv) { return makeArrayNewStatic(s, true); } + if (op == "array.new_default"sv) { return makeArrayNew(s, true); } goto parse_error; default: goto parse_error; } @@ -111,10 +111,10 @@ switch (op[0]) { case 's': { switch (op[17]) { case '\0': - if (op == "br_on_cast_static"sv) { return makeBrOnStatic(s, BrOnCast); } + if (op == "br_on_cast_static"sv) { return makeBrOn(s, BrOnCast); } goto parse_error; case '_': - if (op == "br_on_cast_static_fail"sv) { return makeBrOnStatic(s, BrOnCastFail); } + if (op == "br_on_cast_static_fail"sv) { return makeBrOn(s, BrOnCastFail); } goto parse_error; default: goto parse_error; } @@ -3016,13 +3016,29 @@ switch (op[0]) { } } case 'c': { - switch (op[9]) { - case 'n': - if (op == "ref.cast_nop_static"sv) { return makeRefCastNopStatic(s); } - goto parse_error; - case 's': - if (op == "ref.cast_static"sv) { return makeRefCastStatic(s); } + switch (op[8]) { + case '\0': + if (op == "ref.cast"sv) { return makeRefCast(s); } goto parse_error; + case '_': { + switch (op[9]) { + case 'n': { + switch (op[12]) { + case '\0': + if (op == "ref.cast_nop"sv) { return makeRefCastNop(s); } + goto parse_error; + case '_': + if (op == "ref.cast_nop_static"sv) { return makeRefCastNop(s); } + goto parse_error; + default: goto parse_error; + } + } + case 's': + if (op == "ref.cast_static"sv) { return makeRefCast(s); } + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } @@ -3052,9 +3068,17 @@ switch (op[0]) { case 'n': if (op == "ref.null"sv) { return makeRefNull(s); } goto parse_error; - case 't': - if (op == "ref.test_static"sv) { return makeRefTestStatic(s); } - goto parse_error; + case 't': { + switch (op[8]) { + case '\0': + if (op == "ref.test"sv) { return makeRefTest(s); } + goto parse_error; + case '_': + if (op == "ref.test_static"sv) { return makeRefTest(s); } + goto parse_error; + default: goto parse_error; + } + } default: goto parse_error; } } @@ -3295,10 +3319,10 @@ switch (op[0]) { case 'n': { switch (op[10]) { case '\0': - if (op == "struct.new"sv) { return makeStructNewStatic(s, false); } + if (op == "struct.new"sv) { return makeStructNew(s, false); } goto parse_error; case '_': - if (op == "struct.new_default"sv) { return makeStructNewStatic(s, true); } + if (op == "struct.new_default"sv) { return makeStructNew(s, true); } goto parse_error; default: goto parse_error; } @@ -3613,7 +3637,7 @@ switch (op[0]) { switch (op[9]) { case '\0': if (op == "array.new"sv) { - auto ret = makeArrayNewStatic(ctx, pos, false); + auto ret = makeArrayNew(ctx, pos, false); CHECK_ERR(ret); return *ret; } @@ -3631,7 +3655,7 @@ switch (op[0]) { goto parse_error; case 'e': if (op == "array.new_default"sv) { - auto ret = makeArrayNewStatic(ctx, pos, true); + auto ret = makeArrayNew(ctx, pos, true); CHECK_ERR(ret); return *ret; } @@ -3723,14 +3747,14 @@ switch (op[0]) { switch (op[17]) { case '\0': if (op == "br_on_cast_static"sv) { - auto ret = makeBrOnStatic(ctx, pos, BrOnCast); + auto ret = makeBrOn(ctx, pos, BrOnCast); CHECK_ERR(ret); return *ret; } goto parse_error; case '_': if (op == "br_on_cast_static_fail"sv) { - auto ret = makeBrOnStatic(ctx, pos, BrOnCastFail); + auto ret = makeBrOn(ctx, pos, BrOnCastFail); CHECK_ERR(ret); return *ret; } @@ -8607,21 +8631,45 @@ switch (op[0]) { } } case 'c': { - switch (op[9]) { - case 'n': - if (op == "ref.cast_nop_static"sv) { - auto ret = makeRefCastNopStatic(ctx, pos); + switch (op[8]) { + case '\0': + if (op == "ref.cast"sv) { + auto ret = makeRefCast(ctx, pos); CHECK_ERR(ret); return *ret; } goto parse_error; - case 's': - if (op == "ref.cast_static"sv) { - auto ret = makeRefCastStatic(ctx, pos); - CHECK_ERR(ret); - return *ret; + case '_': { + switch (op[9]) { + case 'n': { + switch (op[12]) { + case '\0': + if (op == "ref.cast_nop"sv) { + auto ret = makeRefCastNop(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + case '_': + if (op == "ref.cast_nop_static"sv) { + auto ret = makeRefCastNop(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + default: goto parse_error; + } + } + case 's': + if (op == "ref.cast_static"sv) { + auto ret = makeRefCast(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + default: goto parse_error; } - goto parse_error; + } default: goto parse_error; } } @@ -8679,13 +8727,25 @@ switch (op[0]) { return *ret; } goto parse_error; - case 't': - if (op == "ref.test_static"sv) { - auto ret = makeRefTestStatic(ctx, pos); - CHECK_ERR(ret); - return *ret; + case 't': { + switch (op[8]) { + case '\0': + if (op == "ref.test"sv) { + auto ret = makeRefTest(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + case '_': + if (op == "ref.test_static"sv) { + auto ret = makeRefTest(ctx, pos); + CHECK_ERR(ret); + return *ret; + } + goto parse_error; + default: goto parse_error; } - goto parse_error; + } default: goto parse_error; } } @@ -9067,14 +9127,14 @@ switch (op[0]) { switch (op[10]) { case '\0': if (op == "struct.new"sv) { - auto ret = makeStructNewStatic(ctx, pos, false); + auto ret = makeStructNew(ctx, pos, false); CHECK_ERR(ret); return *ret; } goto parse_error; case '_': if (op == "struct.new_default"sv) { - auto ret = makeStructNewStatic(ctx, pos, true); + auto ret = makeStructNew(ctx, pos, true); CHECK_ERR(ret); return *ret; } diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 16b036693..d700f85f3 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2109,14 +2109,14 @@ struct PrintExpressionContents printHeapType(o, curr->target->type.getHeapType(), wasm); } void visitRefTest(RefTest* curr) { - printMedium(o, "ref.test_static "); + printMedium(o, "ref.test "); printHeapType(o, curr->intendedType, wasm); } void visitRefCast(RefCast* curr) { if (curr->safety == RefCast::Unsafe) { - printMedium(o, "ref.cast_nop_static "); + printMedium(o, "ref.cast_nop "); } else { - printMedium(o, "ref.cast_static "); + printMedium(o, "ref.cast null "); } printHeapType(o, curr->intendedType, wasm); } @@ -2130,13 +2130,13 @@ struct PrintExpressionContents printMedium(o, "br_on_non_null "); break; case BrOnCast: - printMedium(o, "br_on_cast_static "); + printMedium(o, "br_on_cast "); printName(curr->name, o); o << ' '; printHeapType(o, curr->intendedType, wasm); return; case BrOnCastFail: - printMedium(o, "br_on_cast_static_fail "); + printMedium(o, "br_on_cast_fail "); printName(curr->name, o); o << ' '; printHeapType(o, curr->intendedType, wasm); diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 1ca136f07..55370da26 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1117,11 +1117,19 @@ enum ASTNodes { I31New = 0x20, I31GetS = 0x21, I31GetU = 0x22, + RefTest = 0x40, + // TODO: RefTestNull + RefCastNull = 0x49, + // TODO: RefCastNull + BrOnCast = 0x42, + // TODO: BrOnCastNull + BrOnCastFail = 0x43, + // TODO: BrOnCastFailNull RefTestStatic = 0x44, RefCastStatic = 0x45, BrOnCastStatic = 0x46, BrOnCastStaticFail = 0x47, - RefCastNopStatic = 0x48, + RefCastNop = 0x48, RefIsFunc = 0x50, RefIsData = 0x51, RefIsI31 = 0x52, diff --git a/src/wasm-builder.h b/src/wasm-builder.h index a29867e55..ff834013d 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -1320,30 +1320,6 @@ public: } }; -// This class adds methods that first inspect the input. They may not have fully -// comprehensive error checking, when that can be left to the validator; the -// benefit of the validate* methods is that they can share code between the -// text and binary format parsers, for handling certain situations in the -// input which preclude even creating valid IR, which the validator depends -// on. -class ValidatingBuilder : public Builder { - size_t line = -1, col = -1; - -public: - ValidatingBuilder(Module& wasm, size_t line) : Builder(wasm), line(line) {} - ValidatingBuilder(Module& wasm, size_t line, size_t col) - : Builder(wasm), line(line), col(col) {} - - Expression* validateAndMakeBrOn(BrOnOp op, Name name, Expression* ref) { - if (op == BrOnNull) { - if (!ref->type.isRef() && ref->type != Type::unreachable) { - throw ParseException("Invalid ref for br_on_null", line, col); - } - } - return makeBrOn(op, name, ref); - } -}; - } // namespace wasm #endif // wasm_wasm_builder_h diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 524bc5a3c..23eed7923 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -283,16 +283,15 @@ private: Expression* makeCallRef(Element& s, bool isReturn); Expression* makeI31New(Element& s); Expression* makeI31Get(Element& s, bool signed_); - Expression* makeRefTestStatic(Element& s); - Expression* makeRefCastStatic(Element& s); - Expression* makeRefCastNopStatic(Element& s); + Expression* makeRefTest(Element& s); + Expression* makeRefCast(Element& s); + Expression* makeRefCastNop(Element& s); Expression* makeBrOn(Element& s, BrOnOp op); - Expression* makeBrOnStatic(Element& s, BrOnOp op); - Expression* makeStructNewStatic(Element& s, bool default_); + Expression* makeStructNew(Element& s, bool default_); Index getStructIndex(Element& type, Element& field); Expression* makeStructGet(Element& s, bool signed_ = false); Expression* makeStructSet(Element& s); - Expression* makeArrayNewStatic(Element& s, bool default_); + Expression* makeArrayNew(Element& s, bool default_); Expression* makeArrayNewSeg(Element& s, ArrayNewSegOp op); Expression* makeArrayInitStatic(Element& s); Expression* makeArrayGet(Element& s, bool signed_ = false); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index d7a424695..7b2922d3c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -6893,7 +6893,7 @@ bool WasmBinaryBuilder::maybeVisitI31Get(Expression*& out, uint32_t code) { } bool WasmBinaryBuilder::maybeVisitRefTest(Expression*& out, uint32_t code) { - if (code == BinaryConsts::RefTestStatic) { + if (code == BinaryConsts::RefTestStatic || code == BinaryConsts::RefTest) { auto intendedType = getIndexedHeapType(); auto* ref = popNonVoidExpression(); out = Builder(wasm).makeRefTest(ref, intendedType); @@ -6904,11 +6904,11 @@ bool WasmBinaryBuilder::maybeVisitRefTest(Expression*& out, uint32_t code) { bool WasmBinaryBuilder::maybeVisitRefCast(Expression*& out, uint32_t code) { if (code == BinaryConsts::RefCastStatic || - code == BinaryConsts::RefCastNopStatic) { + code == BinaryConsts::RefCastNull || code == BinaryConsts::RefCastNop) { auto intendedType = getIndexedHeapType(); auto* ref = popNonVoidExpression(); auto safety = - code == BinaryConsts::RefCastNopStatic ? RefCast::Unsafe : RefCast::Safe; + code == BinaryConsts::RefCastNop ? RefCast::Unsafe : RefCast::Safe; out = Builder(wasm).makeRefCast(ref, intendedType, safety); return true; } @@ -6925,9 +6925,11 @@ bool WasmBinaryBuilder::maybeVisitBrOn(Expression*& out, uint32_t code) { op = BrOnNonNull; break; case BinaryConsts::BrOnCastStatic: + case BinaryConsts::BrOnCast: op = BrOnCast; break; case BinaryConsts::BrOnCastStaticFail: + case BinaryConsts::BrOnCastFail: op = BrOnCastFail; break; case BinaryConsts::BrOnFunc: @@ -6952,15 +6954,12 @@ bool WasmBinaryBuilder::maybeVisitBrOn(Expression*& out, uint32_t code) { return false; } auto name = getBreakTarget(getU32LEB()).name; - if (code == BinaryConsts::BrOnCastStatic || - code == BinaryConsts::BrOnCastStaticFail) { - auto intendedType = getIndexedHeapType(); - auto* ref = popNonVoidExpression(); - out = Builder(wasm).makeBrOn(op, name, ref, intendedType); - return true; + HeapType intendedType; + if (op == BrOnCast || op == BrOnCastFail) { + intendedType = getIndexedHeapType(); } auto* ref = popNonVoidExpression(); - out = ValidatingBuilder(wasm, pos).validateAndMakeBrOn(op, name, ref); + out = Builder(wasm).makeBrOn(op, name, ref, intendedType); return true; } diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 7bdbc69c6..ee9fdde72 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -2775,40 +2775,42 @@ Expression* SExpressionWasmBuilder::makeI31Get(Element& s, bool signed_) { return ret; } -Expression* SExpressionWasmBuilder::makeRefTestStatic(Element& s) { +Expression* SExpressionWasmBuilder::makeRefTest(Element& s) { auto heapType = parseHeapType(*s[1]); auto* ref = parseExpression(*s[2]); return Builder(wasm).makeRefTest(ref, heapType); } -Expression* SExpressionWasmBuilder::makeRefCastStatic(Element& s) { - auto heapType = parseHeapType(*s[1]); - auto* ref = parseExpression(*s[2]); +Expression* SExpressionWasmBuilder::makeRefCast(Element& s) { + int i = 1; + if (s[0]->str().str != "ref.cast_static") { + if (s[i++]->str().str != "null") { + throw ParseException("ref.cast not yet supported. Use ref.cast null."); + } + } + auto heapType = parseHeapType(*s[i++]); + auto* ref = parseExpression(*s[i++]); return Builder(wasm).makeRefCast(ref, heapType, RefCast::Safe); } -Expression* SExpressionWasmBuilder::makeRefCastNopStatic(Element& s) { +Expression* SExpressionWasmBuilder::makeRefCastNop(Element& s) { auto heapType = parseHeapType(*s[1]); auto* ref = parseExpression(*s[2]); return Builder(wasm).makeRefCast(ref, heapType, RefCast::Unsafe); } Expression* SExpressionWasmBuilder::makeBrOn(Element& s, BrOnOp op) { - auto name = getLabel(*s[1]); - auto* ref = parseExpression(*s[2]); - return ValidatingBuilder(wasm, s.line, s.col) - .validateAndMakeBrOn(op, name, ref); -} - -Expression* SExpressionWasmBuilder::makeBrOnStatic(Element& s, BrOnOp op) { - auto name = getLabel(*s[1]); - auto heapType = parseHeapType(*s[2]); - auto* ref = parseExpression(*s[3]); + int i = 1; + auto name = getLabel(*s[i++]); + HeapType heapType; + if (op == BrOnCast || op == BrOnCastFail) { + heapType = parseHeapType(*s[i++]); + } + auto* ref = parseExpression(*s[i]); return Builder(wasm).makeBrOn(op, name, ref, heapType); } -Expression* SExpressionWasmBuilder::makeStructNewStatic(Element& s, - bool default_) { +Expression* SExpressionWasmBuilder::makeStructNew(Element& s, bool default_) { auto heapType = parseHeapType(*s[1]); auto numOperands = s.size() - 2; if (default_ && numOperands > 0) { @@ -2865,8 +2867,7 @@ Expression* SExpressionWasmBuilder::makeStructSet(Element& s) { return Builder(wasm).makeStructSet(index, ref, value); } -Expression* SExpressionWasmBuilder::makeArrayNewStatic(Element& s, - bool default_) { +Expression* SExpressionWasmBuilder::makeArrayNew(Element& s, bool default_) { auto heapType = parseHeapType(*s[1]); Expression* init = nullptr; size_t i = 2; diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index daeac60d6..1f477a10c 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2025,16 +2025,16 @@ void BinaryInstWriter::visitCallRef(CallRef* curr) { void BinaryInstWriter::visitRefTest(RefTest* curr) { o << int8_t(BinaryConsts::GCPrefix); - o << U32LEB(BinaryConsts::RefTestStatic); + o << U32LEB(BinaryConsts::RefTest); parent.writeIndexedHeapType(curr->intendedType); } void BinaryInstWriter::visitRefCast(RefCast* curr) { o << int8_t(BinaryConsts::GCPrefix); if (curr->safety == RefCast::Unsafe) { - o << U32LEB(BinaryConsts::RefCastNopStatic); + o << U32LEB(BinaryConsts::RefCastNop); } else { - o << U32LEB(BinaryConsts::RefCastStatic); + o << U32LEB(BinaryConsts::RefCastNull); } parent.writeIndexedHeapType(curr->intendedType); } @@ -2049,11 +2049,11 @@ void BinaryInstWriter::visitBrOn(BrOn* curr) { break; case BrOnCast: o << int8_t(BinaryConsts::GCPrefix); - o << U32LEB(BinaryConsts::BrOnCastStatic); + o << U32LEB(BinaryConsts::BrOnCast); break; case BrOnCastFail: o << int8_t(BinaryConsts::GCPrefix); - o << U32LEB(BinaryConsts::BrOnCastStaticFail); + o << U32LEB(BinaryConsts::BrOnCastFail); break; case BrOnFunc: o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::BrOnFunc); diff --git a/src/wasm/wat-parser.cpp b/src/wasm/wat-parser.cpp index 3f52e6fe6..c3fd2bc4b 100644 --- a/src/wasm/wat-parser.cpp +++ b/src/wasm/wat-parser.cpp @@ -2016,24 +2016,20 @@ template<typename Ctx> Result<typename Ctx::InstrT> makeI31New(Ctx&, Index); template<typename Ctx> Result<typename Ctx::InstrT> makeI31Get(Ctx&, Index, bool signed_); template<typename Ctx> Result<typename Ctx::InstrT> makeRefTest(Ctx&, Index); -template<typename Ctx> -Result<typename Ctx::InstrT> makeRefTestStatic(Ctx&, Index); +template<typename Ctx> Result<typename Ctx::InstrT> makeRefTest(Ctx&, Index); template<typename Ctx> Result<typename Ctx::InstrT> makeRefCast(Ctx&, Index); -template<typename Ctx> -Result<typename Ctx::InstrT> makeRefCastStatic(Ctx&, Index); -template<typename Ctx> -Result<typename Ctx::InstrT> makeRefCastNopStatic(Ctx&, Index); +template<typename Ctx> Result<typename Ctx::InstrT> makeRefCastNop(Ctx&, Index); template<typename Ctx> Result<typename Ctx::InstrT> makeBrOn(Ctx&, Index, BrOnOp op); template<typename Ctx> -Result<typename Ctx::InstrT> makeBrOnStatic(Ctx&, Index, BrOnOp op); +Result<typename Ctx::InstrT> makeBrOn(Ctx&, Index, BrOnOp op); template<typename Ctx> -Result<typename Ctx::InstrT> makeStructNewStatic(Ctx&, Index, bool default_); +Result<typename Ctx::InstrT> makeStructNew(Ctx&, Index, bool default_); template<typename Ctx> Result<typename Ctx::InstrT> makeStructGet(Ctx&, Index, bool signed_ = false); template<typename Ctx> Result<typename Ctx::InstrT> makeStructSet(Ctx&, Index); template<typename Ctx> -Result<typename Ctx::InstrT> makeArrayNewStatic(Ctx&, Index, bool default_); +Result<typename Ctx::InstrT> makeArrayNew(Ctx&, Index, bool default_); template<typename Ctx> Result<typename Ctx::InstrT> makeArrayNewSeg(Ctx&, Index, ArrayNewSegOp op); template<typename Ctx> @@ -2972,22 +2968,12 @@ Result<typename Ctx::InstrT> makeRefTest(Ctx& ctx, Index pos) { } template<typename Ctx> -Result<typename Ctx::InstrT> makeRefTestStatic(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); -} - -template<typename Ctx> Result<typename Ctx::InstrT> makeRefCast(Ctx& ctx, Index pos) { return ctx.in.err("unimplemented instruction"); } template<typename Ctx> -Result<typename Ctx::InstrT> makeRefCastStatic(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); -} - -template<typename Ctx> -Result<typename Ctx::InstrT> makeRefCastNopStatic(Ctx& ctx, Index pos) { +Result<typename Ctx::InstrT> makeRefCastNop(Ctx& ctx, Index pos) { return ctx.in.err("unimplemented instruction"); } @@ -2997,13 +2983,7 @@ Result<typename Ctx::InstrT> makeBrOn(Ctx& ctx, Index pos, BrOnOp op) { } template<typename Ctx> -Result<typename Ctx::InstrT> makeBrOnStatic(Ctx& ctx, Index pos, BrOnOp op) { - return ctx.in.err("unimplemented instruction"); -} - -template<typename Ctx> -Result<typename Ctx::InstrT> -makeStructNewStatic(Ctx& ctx, Index pos, bool default_) { +Result<typename Ctx::InstrT> makeStructNew(Ctx& ctx, Index pos, bool default_) { auto type = typeidx(ctx); CHECK_ERR(type); if (default_) { @@ -3031,8 +3011,7 @@ Result<typename Ctx::InstrT> makeStructSet(Ctx& ctx, Index pos) { } template<typename Ctx> -Result<typename Ctx::InstrT> -makeArrayNewStatic(Ctx& ctx, Index pos, bool default_) { +Result<typename Ctx::InstrT> makeArrayNew(Ctx& ctx, Index pos, bool default_) { return ctx.in.err("unimplemented instruction"); } diff --git a/test/ctor-eval/gc-2.wast b/test/ctor-eval/gc-2.wast index fed45abac..6a21be99e 100644 --- a/test/ctor-eval/gc-2.wast +++ b/test/ctor-eval/gc-2.wast @@ -38,7 +38,7 @@ (func "keepalive" (result i32) (select (struct.get $struct 0 - (ref.cast_static $struct + (ref.cast null $struct (global.get $global1) ) ) diff --git a/test/ctor-eval/gc-2.wast.out b/test/ctor-eval/gc-2.wast.out index c6d8931b8..a333cdf30 100644 --- a/test/ctor-eval/gc-2.wast.out +++ b/test/ctor-eval/gc-2.wast.out @@ -14,7 +14,7 @@ (func $1 (type $none_=>_i32) (result i32) (select (struct.get $struct 0 - (ref.cast_static $struct + (ref.cast null $struct (global.get $global1) ) ) diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index c4dd09168..41f96c184 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -2165,12 +2165,12 @@ BinaryenFeatureAll: 126975 ) ) (drop - (ref.test_static $[mut:i8] + (ref.test $[mut:i8] (global.get $i8Array-global) ) ) (drop - (ref.cast_static $[mut:i8] + (ref.cast null $[mut:i8] (global.get $i8Array-global) ) ) diff --git a/test/heap-types.wast b/test/heap-types.wast index b3c1b0650..9366dca01 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -323,15 +323,15 @@ (local $temp.A (ref null $struct.A)) (local $temp.B (ref null $struct.B)) (drop - (ref.test_static $struct.B (ref.null $struct.A)) + (ref.test $struct.B (ref.null $struct.A)) ) (drop - (ref.cast_static $struct.B (ref.null $struct.A)) + (ref.cast null $struct.B (ref.null $struct.A)) ) (drop (block $out-B (result (ref $struct.B)) (local.set $temp.A - (br_on_cast_static $out-B $struct.B (ref.null $struct.A)) + (br_on_cast $out-B $struct.B (ref.null $struct.A)) ) (unreachable) ) @@ -339,7 +339,7 @@ (drop (block $out-A (result (ref null $struct.A)) (local.set $temp.B - (br_on_cast_static_fail $out-A $struct.B (ref.null $struct.A)) + (br_on_cast_fail $out-A $struct.B (ref.null $struct.A)) ) (unreachable) ) diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index 3d7be5461..9f1a28d13 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -396,19 +396,19 @@ (local $temp.A (ref null $struct.A)) (local $temp.B (ref null $struct.B)) (drop - (ref.test_static $struct.B + (ref.test $struct.B (ref.null none) ) ) (drop - (ref.cast_static $struct.B + (ref.cast null $struct.B (ref.null none) ) ) (drop (block $out-B (result (ref $struct.B)) (local.set $temp.A - (br_on_cast_static $out-B $struct.B + (br_on_cast $out-B $struct.B (ref.null none) ) ) @@ -418,7 +418,7 @@ (drop (block $out-A (result (ref null $struct.A)) (local.set $temp.B - (br_on_cast_static_fail $out-A $struct.B + (br_on_cast_fail $out-A $struct.B (ref.null none) ) ) diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 7bc780796..b217ebc2e 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -349,19 +349,19 @@ (local $temp.A (ref null $struct.A)) (local $temp.B (ref null $struct.B)) (drop - (ref.test_static $struct.B + (ref.test $struct.B (ref.null none) ) ) (drop - (ref.cast_static $struct.B + (ref.cast null $struct.B (ref.null none) ) ) (drop (block $label$1 (result (ref $struct.B)) (local.set $temp.A - (br_on_cast_static $label$1 $struct.B + (br_on_cast $label$1 $struct.B (ref.null none) ) ) @@ -371,7 +371,7 @@ (drop (block $label$2 (result (ref null $struct.A)) (local.set $temp.B - (br_on_cast_static_fail $label$2 $struct.B + (br_on_cast_fail $label$2 $struct.B (ref.null none) ) ) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index 9ffc65080..89f0c676e 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -349,19 +349,19 @@ (local $0 (ref null ${i32_f32_f64})) (local $1 (ref null ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|})) (drop - (ref.test_static ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} + (ref.test ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (ref.null none) ) ) (drop - (ref.cast_static ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} + (ref.cast null ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (ref.null none) ) ) (drop (block $label$1 (result (ref ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|})) (local.set $0 - (br_on_cast_static $label$1 ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} + (br_on_cast $label$1 ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (ref.null none) ) ) @@ -371,7 +371,7 @@ (drop (block $label$2 (result (ref null ${i32_f32_f64})) (local.set $1 - (br_on_cast_static_fail $label$2 ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} + (br_on_cast_fail $label$2 ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (ref.null none) ) ) diff --git a/test/lit/binary/legacy-static-casts.test b/test/lit/binary/legacy-static-casts.test new file mode 100644 index 000000000..53218ba65 --- /dev/null +++ b/test/lit/binary/legacy-static-casts.test @@ -0,0 +1,40 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; Test that the opcodes for the deprecated *_static cast instructions still parse. + +;; RUN: wasm-opt %s.wasm -all -S -o - | filecheck %s +;; CHECK: (type ${} (struct )) + +;; CHECK: (type $none_=>_none (func)) + +;; CHECK: (func $0 (type $none_=>_none) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (ref.test ${} +;; CHECK-NEXT: (ref.null none) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (ref.cast null ${} +;; CHECK-NEXT: (ref.null none) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (ref.cast_nop ${} +;; CHECK-NEXT: (ref.null none) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (block $label$1 (result (ref null ${})) +;; CHECK-NEXT: (br_on_cast $label$1 ${} +;; CHECK-NEXT: (ref.null none) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (block $label$2 (result (ref null ${})) +;; CHECK-NEXT: (br_on_cast_fail $label$2 ${} +;; CHECK-NEXT: (ref.null none) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) diff --git a/test/lit/binary/legacy-static-casts.test.wasm b/test/lit/binary/legacy-static-casts.test.wasm Binary files differnew file mode 100644 index 000000000..2dcfc9f01 --- /dev/null +++ b/test/lit/binary/legacy-static-casts.test.wasm diff --git a/test/lit/heap-types.wast b/test/lit/heap-types.wast index dc71eb41e..83926e573 100644 --- a/test/lit/heap-types.wast +++ b/test/lit/heap-types.wast @@ -15,21 +15,21 @@ (type $struct.B (struct i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $struct.A + ;; CHECK-NEXT: (ref.test $struct.A ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $test (type $none_=>_none) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $struct.B + ;; NOMNL-NEXT: (ref.test $struct.B ;; NOMNL-NEXT: (ref.null none) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $test (drop - (ref.test_static $struct.B (ref.null $struct.A)) + (ref.test $struct.B (ref.null $struct.A)) ) ) ) @@ -41,21 +41,21 @@ (type $struct.B (struct i32)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct.A + ;; CHECK-NEXT: (ref.cast null $struct.A ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $test (type $none_=>_none) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct.B + ;; NOMNL-NEXT: (ref.cast null $struct.B ;; NOMNL-NEXT: (ref.null none) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $test (drop - (ref.cast_static $struct.B (ref.null $struct.A)) + (ref.cast null $struct.B (ref.null $struct.A)) ) ) ) diff --git a/test/lit/legacy-static-casts.wast b/test/lit/legacy-static-casts.wast new file mode 100644 index 000000000..0cbd30a2d --- /dev/null +++ b/test/lit/legacy-static-casts.wast @@ -0,0 +1,75 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; Check that the deprecated *_static instruction names are still parsed correctly. + +;; RUN: wasm-opt %s -all -S -o - | filecheck %s + +(module + ;; CHECK: (type $struct (struct )) + (type $struct (struct)) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (func $test (type $none_=>_none) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.test $struct + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.cast_nop $struct + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block $l1 (result (ref null $struct)) + ;; CHECK-NEXT: (br_on_cast $l1 $struct + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block $l2 (result (ref null $struct)) + ;; CHECK-NEXT: (br_on_cast_fail $l2 $struct + ;; CHECK-NEXT: (ref.null none) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test + (drop + (ref.test_static $struct + (ref.null none) + ) + ) + (drop + (ref.cast_static $struct + (ref.null none) + ) + ) + (drop + (ref.cast_nop_static $struct + (ref.null none) + ) + ) + (drop + (block $l1 (result (ref null $struct)) + (br_on_cast_static $l1 $struct + (ref.null none) + ) + ) + ) + (drop + (block $l2 (result (ref null $struct)) + (br_on_cast_static_fail $l2 $struct + (ref.null none) + ) + ) + ) + ) +) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index ab8e23502..f209cef88 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -1036,7 +1036,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result (ref $none_=>_none)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $parent $parent + ;; CHECK-NEXT: (br_on_cast $parent $parent ;; CHECK-NEXT: (ref.func $func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1093,7 +1093,7 @@ ;; contents in ref.cast, but not br_on_cast, so test both. (drop (struct.get $parent 0 - (ref.cast_static $parent + (ref.cast null $parent (ref.func $func) ) ) @@ -1102,7 +1102,7 @@ (struct.get $parent 0 (block $parent (result (ref $parent)) (drop - (br_on_cast_static $parent $parent + (br_on_cast $parent $parent (ref.func $func) ) ) @@ -1152,7 +1152,7 @@ ;; CHECK-NEXT: (br $block1 ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $child + ;; CHECK-NEXT: (ref.cast null $child ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1198,13 +1198,13 @@ ) ) ;; Send a less specific type, via a cast. But all nulls are identical and - ;; ref.cast passes nulls through, so this is ok, but we must be careful to + ;; ref.cast null passes nulls through, so this is ok, but we must be careful to ;; emit a ref.null $child on the outside (to not change the outer type to a ;; less refined one). (drop (block $block (result (ref null $child)) (br $block - (ref.cast_static $child + (ref.cast null $child (ref.null $parent) ) ) @@ -1710,7 +1710,7 @@ (drop (ref.as_non_null (array.get $something-child - (ref.cast_static $something-child + (ref.cast null $something-child (array.new_default $something (i32.const 10) ) @@ -2532,7 +2532,7 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (struct.new $substruct ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (i32.const 2) @@ -2540,7 +2540,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (struct.new $subsubstruct ;; CHECK-NEXT: (i32.const 3) ;; CHECK-NEXT: (i32.const 4) @@ -2550,10 +2550,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test - ;; The cast here will fail, and the ref.cast allows nothing through, so we + ;; The cast here will fail, and the ref.cast null allows nothing through, so we ;; can emit an unreachable here. (drop - (ref.cast_static $substruct + (ref.cast null $substruct (struct.new $struct (i32.const 0) ) @@ -2562,7 +2562,7 @@ ;; This cast of a type to itself can succeed (in fact, it will), so we make ;; no changes here. (drop - (ref.cast_static $substruct + (ref.cast null $substruct (struct.new $substruct (i32.const 1) (i32.const 2) @@ -2571,7 +2571,7 @@ ) ;; This cast of a subtype will also succeed. As above, we make no changes. (drop - (ref.cast_static $substruct + (ref.cast null $substruct (struct.new $subsubstruct (i32.const 3) (i32.const 4) @@ -2585,7 +2585,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $import) @@ -2600,7 +2600,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (select (result i31ref) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (i31.new @@ -2614,7 +2614,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: (struct.new $struct @@ -2629,7 +2629,7 @@ ;; Only a null can flow through the cast, which we can infer for the value ;; of the cast. (drop - (ref.cast_static $struct + (ref.cast null $struct (select (ref.null $struct) (ref.null $struct) @@ -2641,7 +2641,7 @@ ;; through (an i31 would fail the cast). Given that, we can infer a null for ;; the value of the cast. (drop - (ref.cast_static $struct + (ref.cast null $struct (select (ref.null $struct) (i31.new (i32.const 0)) @@ -2651,7 +2651,7 @@ ) ;; A null or a $struct may arrive, and so we cannot do anything here. (drop - (ref.cast_static $struct + (ref.cast null $struct (select (ref.null $struct) (struct.new $struct @@ -2665,7 +2665,7 @@ ;; CHECK: (func $test-cones (type $i32_=>_none) (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 0) @@ -2676,7 +2676,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 1) @@ -2690,7 +2690,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 4) @@ -2708,9 +2708,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $test-cones (export "test-cones") (param $x i32) - ;; The input to the ref.cast is potentially null, so we cannot infer here. + ;; The input to the ref.cast null is potentially null, so we cannot infer here. (drop - (ref.cast_static $struct + (ref.cast null $struct (select (struct.new $struct (i32.const 0) @@ -2720,10 +2720,10 @@ ) ) ) - ;; The input to the ref.cast is either $struct or $substruct, both of which + ;; The input to the ref.cast null is either $struct or $substruct, both of which ;; work, so we cannot optimize anything here away. (drop - (ref.cast_static $struct + (ref.cast null $struct (select (struct.new $struct (i32.const 1) @@ -2739,7 +2739,7 @@ ;; As above, but now we test with $substruct, so one possibility fails and ;; one succeeds. We cannot infer here either. (drop - (ref.cast_static $substruct + (ref.cast null $substruct (select (struct.new $struct (i32.const 4) @@ -2756,7 +2756,7 @@ ;; can infer an unreachable. The combination of these two is a cone from ;; $struct of depth 1, which does not overlap with $subsubstruct. (drop - (ref.cast_static $subsubstruct + (ref.cast null $subsubstruct (select (struct.new $struct (i32.const 7) @@ -2786,7 +2786,7 @@ ;; This cast will fail: we know the exact type of the reference, and it is ;; not a subtype. (drop - (ref.test_static $substruct + (ref.test $substruct (struct.new $struct (i32.const 0) ) @@ -2794,7 +2794,7 @@ ) ;; Casting a thing to itself must succeed. (drop - (ref.test_static $substruct + (ref.test $substruct (struct.new $substruct (i32.const 1) (i32.const 2) @@ -2803,7 +2803,7 @@ ) ;; Casting a thing to a supertype must succeed. (drop - (ref.test_static $substruct + (ref.test $substruct (struct.new $subsubstruct (i32.const 3) (i32.const 4) @@ -2815,7 +2815,7 @@ ;; CHECK: (func $ref.test-inexact (type $i32_=>_none) (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $struct + ;; CHECK-NEXT: (ref.test $struct ;; CHECK-NEXT: (select (result (ref null $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 0) @@ -2829,7 +2829,7 @@ ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $substruct + ;; CHECK-NEXT: (ref.test $substruct ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 4) @@ -2849,7 +2849,7 @@ (func $ref.test-inexact (export "ref.test-inexact") (param $x i32) ;; The input to the ref.test is potentially null, so we cannot infer here. (drop - (ref.test_static $struct + (ref.test $struct (select (struct.new $struct (i32.const 0) @@ -2864,7 +2864,7 @@ ;; combination of those two types is a cone on $struct of depth 1, and that ;; cone is 100% a subtype of $struct, so the test will succeed. (drop - (ref.test_static $struct + (ref.test $struct (select (struct.new $struct (i32.const 1) @@ -2880,7 +2880,7 @@ ;; As above, but now we test with $substruct, so one possibility fails and ;; one succeeds. We cannot infer here. (drop - (ref.test_static $substruct + (ref.test $substruct (select (struct.new $struct (i32.const 4) @@ -2897,7 +2897,7 @@ ;; can infer a 0. The combination of these two is a cone from $struct of ;; depth 1, which does not overlap with $subsubstruct. (drop - (ref.test_static $subsubstruct + (ref.test $subsubstruct (select (struct.new $struct (i32.const 7) @@ -3637,7 +3637,7 @@ ;; CHECK: (func $foo (type $none_=>_ref|$B|) (result (ref $B)) ;; CHECK-NEXT: (local $A (ref null $A)) - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.tee $A ;; CHECK-NEXT: (struct.new $B @@ -3653,7 +3653,7 @@ ;; Read the following from the most nested comment first. - (ref.cast_static $B ;; if we mistakenly think this contains content of + (ref.cast null $B ;; if we mistakenly think this contains content of ;; type $A, it would trap, but it should not, and we ;; have nothing to optimize here (ref.as_non_null ;; also $B, based on the child's *contents* (not type!) @@ -5310,27 +5310,27 @@ ;; An imported global has a known type, at least, which in this case is ;; enough for us to infer a result of 1. (drop - (ref.test_static $A + (ref.test $A (global.get $A) ) ) ;; Likewise, a function result. (drop - (ref.test_static $A + (ref.test $A (call $A) ) ) ;; Likewise, a parameter to this function, which is exported, but we do ;; still know the type it will be called with, and can optimize to 1. (drop - (ref.test_static $A + (ref.test $A (local.get $A) ) ) ;; Likewise, an exported mutable global can be modified by the outside, but ;; the type remains known, and we can optimize to 1. (drop - (ref.test_static $A + (ref.test $A (global.get $A) ) ) @@ -5338,22 +5338,22 @@ ;; CHECK: (func $no (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (global.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (call $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (global.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -5362,22 +5362,22 @@ ;; Identical to the above function, but now all tests are vs type $B. We ;; cannot optimize any of these, as all we know is the type is $A. (drop - (ref.test_static $B + (ref.test $B (global.get $A) ) ) (drop - (ref.test_static $B + (ref.test $B (call $A) ) ) (drop - (ref.test_static $B + (ref.test $B (local.get $A) ) ) (drop - (ref.test_static $B + (ref.test $B (global.get $A) ) ) @@ -5389,7 +5389,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $B (result (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $B $B + ;; CHECK-NEXT: (br_on_cast $B $B ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (i32.const 100) ;; CHECK-NEXT: ) @@ -5406,7 +5406,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $A (result (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $A $A + ;; CHECK-NEXT: (br_on_cast $A $A ;; CHECK-NEXT: (struct.new $A ;; CHECK-NEXT: (i32.const 200) ;; CHECK-NEXT: ) @@ -5432,7 +5432,7 @@ (drop (block $B (result (ref $B)) (drop - (br_on_cast_static $B $B + (br_on_cast $B $B (struct.new $A (i32.const 100) ) @@ -5444,10 +5444,10 @@ ;; But casting to $A will succeed, so the block is reachable, and also the ;; cast will return 1. (drop - (ref.test_static $A + (ref.test $A (block $A (result (ref $A)) (drop - (br_on_cast_static $A $A + (br_on_cast $A $A (struct.new $A (i32.const 200) ) diff --git a/test/lit/passes/gufa-vs-cfp.wast b/test/lit/passes/gufa-vs-cfp.wast index 359f0a83b..1cd0a7212 100644 --- a/test/lit/passes/gufa-vs-cfp.wast +++ b/test/lit/passes/gufa-vs-cfp.wast @@ -529,7 +529,7 @@ ;; As the get must trap, we can optimize to an unreachable here. (drop (struct.get $substruct 0 - (ref.cast_static $substruct + (ref.cast null $substruct (call $create) ) ) @@ -588,7 +588,7 @@ (func $get (drop (struct.get $substruct 0 - (ref.cast_static $substruct + (ref.cast null $substruct (call $create) ) ) @@ -642,7 +642,7 @@ ;; to $struct. But no null is possible since the local gets written a ;; non-null value before we get here, so we can optimize this to an ;; unreachable. - (ref.cast_static $substruct + (ref.cast null $substruct (local.get $ref) ) ) @@ -802,7 +802,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (select (result (ref $struct)) ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 10) @@ -823,7 +823,7 @@ (drop (struct.get $struct 0 ;; This cast is added, ensuring only a $substruct can reach the get. - (ref.cast_static $substruct + (ref.cast null $substruct (select (struct.new $struct (i32.const 10) @@ -875,7 +875,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $substruct 0 - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -903,7 +903,7 @@ ) (drop (struct.get $substruct 0 - (ref.cast_static $substruct + (ref.cast null $substruct (local.get $ref) ) ) @@ -949,7 +949,7 @@ ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $substruct 0 - ;; CHECK-NEXT: (ref.cast_static $substruct + ;; CHECK-NEXT: (ref.cast null $substruct ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -980,7 +980,7 @@ ) (drop (struct.get $substruct 0 - (ref.cast_static $substruct + (ref.cast null $substruct (local.get $ref) ) ) @@ -2041,7 +2041,7 @@ ) ;; CHECK: (func $set (type $none_=>_none) ;; CHECK-NEXT: (struct.set $A 0 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (call $create-C) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 20) @@ -2052,7 +2052,7 @@ ;; the type is $A, which should not confuse us: this set does alias the data ;; in $C, which means we cannot optimize in the function $get below. (struct.set $A 0 - (ref.cast_static $A + (ref.cast null $A (call $create-C) ) (i32.const 20) ;; different value than in $create diff --git a/test/lit/passes/inlining-optimizing.wast b/test/lit/passes/inlining-optimizing.wast index c72d6a88b..4bc2dd573 100644 --- a/test/lit/passes/inlining-optimizing.wast +++ b/test/lit/passes/inlining-optimizing.wast @@ -33,7 +33,7 @@ (call $0) (drop (call_ref $none_=>_i32 - (ref.cast_static $none_=>_i32 + (ref.cast null $none_=>_i32 (ref.func $0) ) ) diff --git a/test/lit/passes/inlining_vacuum_optimize-instructions.wast b/test/lit/passes/inlining_vacuum_optimize-instructions.wast index 11e51b203..42b354fee 100644 --- a/test/lit/passes/inlining_vacuum_optimize-instructions.wast +++ b/test/lit/passes/inlining_vacuum_optimize-instructions.wast @@ -19,7 +19,7 @@ ;; CHECK: (func $target (type $ref?|$A|_=>_none) (param $0 (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -27,7 +27,7 @@ ;; CHECK-NEXT: ) (func $target (param $0 (ref null $A)) (drop - (ref.cast_static $B + (ref.cast null $B (struct.get $A 0 (call $get-null) ) diff --git a/test/lit/passes/monomorphize.wast b/test/lit/passes/monomorphize.wast index 1f0eb0f87..6c4acce2d 100644 --- a/test/lit/passes/monomorphize.wast +++ b/test/lit/passes/monomorphize.wast @@ -405,7 +405,7 @@ ;; ALWAYS: (func $refinable (type $ref|$A|_=>_none) (param $ref (ref $A)) ;; ALWAYS-NEXT: (local $x (ref $A)) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast_static $B + ;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -417,17 +417,17 @@ ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast_static $B + ;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast_static $B + ;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import - ;; ALWAYS-NEXT: (ref.cast_static $B + ;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -435,12 +435,12 @@ ;; CAREFUL: (func $refinable (type $ref|$A|_=>_none) (param $0 (ref $A)) ;; CAREFUL-NEXT: (local $1 (ref $A)) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast_static $B + ;; CAREFUL-NEXT: (ref.cast null $B ;; CAREFUL-NEXT: (local.get $0) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast_static $B + ;; CAREFUL-NEXT: (ref.cast null $B ;; CAREFUL-NEXT: (local.tee $1 ;; CAREFUL-NEXT: (select (result (ref $A)) ;; CAREFUL-NEXT: (local.get $0) @@ -451,12 +451,12 @@ ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast_static $B + ;; CAREFUL-NEXT: (ref.cast null $B ;; CAREFUL-NEXT: (local.get $1) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: (call $import - ;; CAREFUL-NEXT: (ref.cast_static $B + ;; CAREFUL-NEXT: (ref.cast null $B ;; CAREFUL-NEXT: (local.get $0) ;; CAREFUL-NEXT: ) ;; CAREFUL-NEXT: ) @@ -470,7 +470,7 @@ ;; cast will remain since we monomorphize without bothering to optimize and ;; see if there is any benefit.) (call $import - (ref.cast_static $B + (ref.cast null $B (local.get $ref) ) ) @@ -485,18 +485,18 @@ ) ) (call $import - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) (call $import - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) ;; Another use of $ref, also to avoid opts merging $x and $ref. (call $import - (ref.cast_static $B + (ref.cast null $B (local.get $ref) ) ) @@ -506,7 +506,7 @@ ;; ALWAYS: (func $refinable_0 (type $ref|$B|_=>_none) (param $ref (ref $B)) ;; ALWAYS-NEXT: (local $x (ref $A)) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast_static $B +;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) @@ -518,17 +518,17 @@ ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast_static $B +;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast_static $B +;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $x) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: (call $import -;; ALWAYS-NEXT: (ref.cast_static $B +;; ALWAYS-NEXT: (ref.cast null $B ;; ALWAYS-NEXT: (local.get $ref) ;; ALWAYS-NEXT: ) ;; ALWAYS-NEXT: ) diff --git a/test/lit/passes/optimize-casts.wast b/test/lit/passes/optimize-casts.wast index c75efd48f..3d18e281f 100644 --- a/test/lit/passes/optimize-casts.wast +++ b/test/lit/passes/optimize-casts.wast @@ -96,7 +96,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -112,7 +112,7 @@ ;; As $ref.as but with ref.casts: we should use the cast value after it has ;; been computed, in both gets. (drop - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -128,7 +128,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -145,7 +145,7 @@ ;; CHECK-NEXT: ) (func $not-past-set (param $x (ref struct)) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -166,7 +166,7 @@ ;; CHECK-NEXT: (local $2 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -176,7 +176,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $2 - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -187,7 +187,7 @@ ;; CHECK-NEXT: ) (func $best (param $x (ref struct)) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -196,7 +196,7 @@ (local.get $x) ) (drop - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) @@ -210,7 +210,7 @@ ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -219,7 +219,7 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -231,7 +231,7 @@ ;; As above, but with the casts reversed. Now we should use $B in both ;; gets. (drop - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) @@ -239,7 +239,7 @@ (local.get $x) ) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -252,7 +252,7 @@ ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (block (result (ref data)) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -265,7 +265,7 @@ ;; CHECK-NEXT: ) (func $fallthrough (param $x (ref struct)) (drop - (ref.cast_static $A + (ref.cast null $A ;; We look through the block, and optimize. (block (result (ref struct)) (local.get $x) @@ -279,7 +279,7 @@ ;; CHECK: (func $past-basic-block (type $ref|data|_=>_none) (param $x (ref data)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -293,7 +293,7 @@ ;; CHECK-NEXT: ) (func $past-basic-block (param $x (ref struct)) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -321,14 +321,14 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $4 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $5 - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -360,12 +360,12 @@ (local.get $y) ) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $a) ) ) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $b) ) ) diff --git a/test/lit/passes/optimize-instructions-call_ref.wast b/test/lit/passes/optimize-instructions-call_ref.wast index a0da2e9e5..2b648df3b 100644 --- a/test/lit/passes/optimize-instructions-call_ref.wast +++ b/test/lit/passes/optimize-instructions-call_ref.wast @@ -175,7 +175,7 @@ ;; call_ref that returns nothing with a call that returns an i32. In fact, we ;; end up optimizing the cast into an unreachable. (call_ref $none_=>_i32 - (ref.cast_static $none_=>_i32 + (ref.cast null $none_=>_i32 (ref.func $return-nothing) ) ) diff --git a/test/lit/passes/optimize-instructions-gc-iit.wast b/test/lit/passes/optimize-instructions-gc-iit.wast index ce93b5d04..904925940 100644 --- a/test/lit/passes/optimize-instructions-gc-iit.wast +++ b/test/lit/passes/optimize-instructions-gc-iit.wast @@ -41,7 +41,7 @@ ;; CHECK-NEXT: (local.get $child) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $child + ;; CHECK-NEXT: (ref.cast null $child ;; CHECK-NEXT: (local.get $parent) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -62,7 +62,7 @@ ;; NOMNL-NEXT: (local.get $child) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $child + ;; NOMNL-NEXT: (ref.cast null $child ;; NOMNL-NEXT: (local.get $parent) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -83,7 +83,7 @@ ;; NOMNL-TNH-NEXT: (local.get $child) ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (ref.cast_static $child + ;; NOMNL-TNH-NEXT: (ref.cast null $child ;; NOMNL-TNH-NEXT: (local.get $parent) ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: ) @@ -104,13 +104,13 @@ ;; a cast of parent to parent. We can optimize this as the new type will be ;; valid. (drop - (ref.cast_static $parent + (ref.cast null $parent (local.get $parent) ) ) ;; a cast of child to a supertype: again, we replace with a valid type. (drop - (ref.cast_static $parent + (ref.cast null $parent (local.get $child) ) ) @@ -118,13 +118,13 @@ ;; $child with one that is not equal or more specific, like $parent, so we ;; cannot optimize here. (drop - (ref.cast_static $child + (ref.cast null $child (local.get $parent) ) ) ;; a cast of child to an unrelated type: it will trap anyhow (drop - (ref.cast_static $other + (ref.cast null $other (local.get $child) ) ) @@ -138,7 +138,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $parent + ;; CHECK-NEXT: (ref.cast null $parent ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -151,7 +151,7 @@ ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $parent + ;; NOMNL-NEXT: (ref.cast null $parent ;; NOMNL-NEXT: (unreachable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -164,7 +164,7 @@ ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: (drop - ;; NOMNL-TNH-NEXT: (ref.cast_static $parent + ;; NOMNL-TNH-NEXT: (ref.cast null $parent ;; NOMNL-TNH-NEXT: (unreachable) ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: ) @@ -174,7 +174,7 @@ ;; optimizing this cast away requires reordering. (drop - (ref.cast_static $parent + (ref.cast null $parent (block (result (ref $parent)) (call $foo) (local.get $parent) @@ -184,7 +184,7 @@ ;; ignore unreachability (drop - (ref.cast_static $parent + (ref.cast null $parent (unreachable) ) ) @@ -206,11 +206,11 @@ ;; NOMNL-TNH-NEXT: ) ;; NOMNL-TNH-NEXT: ) (func $ref-eq-ref-cast (param $x eqref) - ;; we can look through a ref.cast if we ignore traps + ;; we can look through a ref.cast null if we ignore traps (drop (ref.eq (local.get $x) - (ref.cast_static $parent + (ref.cast null $parent (local.get $x) ) ) @@ -280,7 +280,7 @@ ;; NOMNL-TNH-NEXT: ) (func $test (param $C (ref $C)) (result anyref) (struct.get $B 0 - (ref.cast_static $B ;; Try to cast a $C to its parent, $B. That always + (ref.cast null $B ;; Try to cast a $C to its parent, $B. That always ;; works, so the cast can be removed. ;; Then once the cast is removed, the outer struct.get ;; will have a reference with a different type, diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 1e38ec8c7..2d3e25b9b 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -16,7 +16,7 @@ ;; NO_TNH: (func $ref.eq (type $eqref_eqref_=>_i32) (param $a eqref) (param $b eqref) (result i32) ;; NO_TNH-NEXT: (ref.eq ;; NO_TNH-NEXT: (ref.as_non_null - ;; NO_TNH-NEXT: (ref.cast_static $struct + ;; NO_TNH-NEXT: (ref.cast null $struct ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -31,7 +31,7 @@ (ref.eq (ref.as_data (ref.as_non_null - (ref.cast_static $struct + (ref.cast null $struct (local.get $a) ) ) @@ -78,7 +78,7 @@ ;; something that does not validate (as ref.eq inputs must be eqrefs). (drop (ref.eq - (ref.cast_static $struct + (ref.cast null $struct (ref.func $ref.eq-no) ;; *Not* an eqref! ) (ref.as_non_null @@ -94,7 +94,7 @@ ;; TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; TNH-NEXT: (drop - ;; TNH-NEXT: (ref.cast_static $struct + ;; TNH-NEXT: (ref.cast null $struct ;; TNH-NEXT: (ref.as_data ;; TNH-NEXT: (local.get $a) ;; TNH-NEXT: ) @@ -104,7 +104,7 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.is (type $eqref_=>_i32) (param $a eqref) (result i32) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.cast_static $struct + ;; NO_TNH-NEXT: (ref.cast null $struct ;; NO_TNH-NEXT: (ref.as_data ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) @@ -116,7 +116,7 @@ ;; In this case non-nullability is enough to tell that the ref.is will ;; return 0. TNH does not help here. (ref.is_null - (ref.cast_static $struct + (ref.cast null $struct (ref.as_non_null (ref.as_data (local.get $a) @@ -133,7 +133,7 @@ ;; TNH-NEXT: ) ;; NO_TNH: (func $ref.is_b (type $eqref_=>_i32) (param $a eqref) (result i32) ;; NO_TNH-NEXT: (ref.is_null - ;; NO_TNH-NEXT: (ref.cast_static $struct + ;; NO_TNH-NEXT: (ref.cast null $struct ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -143,7 +143,7 @@ ;; to be non-nullable. That means we cannot remove the ref.is, but we can ;; remove the cast in TNH. (ref.is_null - (ref.cast_static $struct + (ref.cast null $struct (local.get $a) ) ) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index 5d53374d1..61b558868 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -954,7 +954,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -964,7 +964,7 @@ ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.eq ;; NOMNL-NEXT: (local.get $x) - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -976,7 +976,7 @@ (drop (ref.eq (local.get $x) - (ref.cast_static $struct + (ref.cast null $struct (local.get $x) ) ) @@ -986,27 +986,27 @@ ;; CHECK: (func $flip-cast-of-as-non-null (type $anyref_=>_none) (param $x anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get_u $struct $i8 - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (ref.as_func ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (ref.as_i31 ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -1016,27 +1016,27 @@ ;; NOMNL: (func $flip-cast-of-as-non-null (type $anyref_=>_none) (param $x anyref) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (struct.get_u $struct $i8 - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (ref.as_func ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (ref.as_i31 ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) @@ -1045,8 +1045,8 @@ ;; NOMNL-NEXT: ) (func $flip-cast-of-as-non-null (param $x anyref) (drop - (ref.cast_static $struct - ;; this can be moved through the ref.cast outward. + (ref.cast null $struct + ;; this can be moved through the ref.cast null outward. (ref.as_non_null (local.get $x) ) @@ -1055,8 +1055,8 @@ (drop ;; an example of how this helps: the struct.get will trap on null anyhow (struct.get_u $struct 0 - (ref.cast_static $struct - ;; this can be moved through the ref.cast outward. + (ref.cast null $struct + ;; this can be moved through the ref.cast null outward. (ref.as_non_null (local.get $x) ) @@ -1065,14 +1065,14 @@ ) ;; other ref.as* operations are ignored for now (drop - (ref.cast_static $struct + (ref.cast null $struct (ref.as_func (local.get $x) ) ) ) (drop - (ref.cast_static $struct + (ref.cast null $struct (ref.as_i31 (local.get $x) ) @@ -1285,14 +1285,14 @@ ;; CHECK: (func $ref-cast-squared (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-squared (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1300,8 +1300,8 @@ (func $ref-cast-squared (param $x eqref) ;; Identical ref.casts can be folded together. (drop - (ref.cast_static $struct - (ref.cast_static $struct + (ref.cast null $struct + (ref.cast null $struct (local.get $x) ) ) @@ -1309,9 +1309,9 @@ ) ;; CHECK: (func $ref-cast-squared-fallthrough (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.tee $x - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1320,9 +1320,9 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-squared-fallthrough (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.tee $x - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1332,9 +1332,9 @@ (func $ref-cast-squared-fallthrough (param $x eqref) ;; A fallthrough in the middle does not prevent this optimization. (drop - (ref.cast_static $struct + (ref.cast null $struct (local.tee $x - (ref.cast_static $struct + (ref.cast null $struct (local.get $x) ) ) @@ -1343,14 +1343,14 @@ ) ;; CHECK: (func $ref-cast-cubed (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-cubed (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1358,9 +1358,9 @@ (func $ref-cast-cubed (param $x eqref) ;; Three and more also work. (drop - (ref.cast_static $struct - (ref.cast_static $struct - (ref.cast_static $struct + (ref.cast null $struct + (ref.cast null $struct + (ref.cast null $struct (local.get $x) ) ) @@ -1369,8 +1369,8 @@ ) ;; CHECK: (func $ref-cast-squared-different (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct - ;; CHECK-NEXT: (ref.cast_static $empty + ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast null $empty ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1378,8 +1378,8 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-squared-different (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct - ;; NOMNL-NEXT: (ref.cast_static $empty + ;; NOMNL-NEXT: (ref.cast null $struct + ;; NOMNL-NEXT: (ref.cast null $empty ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1388,8 +1388,8 @@ (func $ref-cast-squared-different (param $x eqref) ;; Different casts cannot be folded. (drop - (ref.cast_static $struct - (ref.cast_static $empty + (ref.cast null $struct + (ref.cast null $empty (local.get $x) ) ) @@ -1455,10 +1455,10 @@ ;; CHECK: (func $ref-eq-possible (type $eqref_eqref_=>_none) (param $x eqref) (param $y eqref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1467,10 +1467,10 @@ ;; NOMNL: (func $ref-eq-possible (type $eqref_eqref_=>_none) (param $x eqref) (param $y eqref) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.eq - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1481,10 +1481,10 @@ ;; they are both null, so we cannot optimize here. (drop (ref.eq - (ref.cast_static $struct + (ref.cast null $struct (local.get $x) ) - (ref.cast_static $array + (ref.cast null $array (local.get $y) ) ) @@ -1496,13 +1496,13 @@ ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1512,13 +1512,13 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1530,14 +1530,14 @@ ;; CHECK-NEXT: (block (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1551,13 +1551,13 @@ ;; NOMNL-NEXT: (block (result i32) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1567,13 +1567,13 @@ ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (block (result i32) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1585,14 +1585,14 @@ ;; NOMNL-NEXT: (block (result i32) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1606,12 +1606,12 @@ ;; equal, and the result must be 0. (drop (ref.eq - (ref.cast_static $struct + (ref.cast null $struct (ref.as_non_null (local.get $x) ) ) - (ref.cast_static $array + (ref.cast null $array (local.get $y) ) ) @@ -1619,10 +1619,10 @@ ;; As above but the cast is on the other one. (drop (ref.eq - (ref.cast_static $struct + (ref.cast null $struct (local.get $x) ) - (ref.cast_static $array + (ref.cast null $array (ref.as_non_null (local.get $y) ) @@ -1632,12 +1632,12 @@ ;; As above but the cast is both. (drop (ref.eq - (ref.cast_static $struct + (ref.cast null $struct (ref.as_non_null (local.get $x) ) ) - (ref.cast_static $array + (ref.cast null $array (ref.as_non_null (local.get $y) ) @@ -1650,12 +1650,12 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1664,12 +1664,12 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.eq ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $y) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1680,12 +1680,12 @@ ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.eq ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $A + ;; NOMNL-NEXT: (ref.cast null $A ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1694,12 +1694,12 @@ ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.eq ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $A + ;; NOMNL-NEXT: (ref.cast null $A ;; NOMNL-NEXT: (local.get $y) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1711,12 +1711,12 @@ ;; subtype of A, so we cannot optimize. (drop (ref.eq - (ref.cast_static $A + (ref.cast null $A (ref.as_non_null (local.get $x) ) ) - (ref.cast_static $B + (ref.cast null $B (ref.as_non_null (local.get $y) ) @@ -1726,12 +1726,12 @@ ;; As above but flipped. (drop (ref.eq - (ref.cast_static $B + (ref.cast null $B (ref.as_non_null (local.get $x) ) ) - (ref.cast_static $A + (ref.cast null $A (ref.as_non_null (local.get $y) ) @@ -1804,7 +1804,7 @@ ;; NOMNL-NEXT: ) (func $incompatible-cast-of-non-null (param $struct (ref $struct)) (drop - (ref.cast_static $array + (ref.cast null $array (local.get $struct) ) ) @@ -1856,12 +1856,12 @@ ;; NOMNL-NEXT: ) (func $incompatible-cast-of-null (drop - (ref.cast_static $array + (ref.cast null $array (ref.null $struct) ) ) (drop - (ref.cast_static $array + (ref.cast null $array ;; The fallthrough is null, but the node's child's type is non-nullable, ;; so we must add a ref.as_non_null on the outside to keep the type ;; identical. @@ -1874,21 +1874,21 @@ ;; CHECK: (func $incompatible-cast-of-unknown (type $ref?|$struct|_=>_none) (param $struct (ref null $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $incompatible-cast-of-unknown (type $ref?|$struct|_=>_none) (param $struct (ref null $struct)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $struct) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $incompatible-cast-of-unknown (param $struct (ref null $struct)) (drop - (ref.cast_static $array + (ref.cast null $array (local.get $struct) ) ) @@ -1917,7 +1917,7 @@ (func $incompatible-test (param $struct (ref null $struct)) (drop ;; This test will definitely fail, so we can turn it into 0. - (ref.test_static $array + (ref.test $array (local.get $struct) ) ) @@ -1925,24 +1925,24 @@ ;; CHECK: (func $subtype-compatible (type $ref?|$A|_ref?|$B|_=>_none) (param $A (ref null $A)) (param $B (ref null $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $A + ;; CHECK-NEXT: (ref.test $A ;; CHECK-NEXT: (local.get $B) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $subtype-compatible (type $ref?|$A|_ref?|$B|_=>_none) (param $A (ref null $A)) (param $B (ref null $B)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $B + ;; NOMNL-NEXT: (ref.test $B ;; NOMNL-NEXT: (local.get $A) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $A + ;; NOMNL-NEXT: (ref.test $A ;; NOMNL-NEXT: (local.get $B) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1950,27 +1950,27 @@ (func $subtype-compatible (param $A (ref null $A)) (param $B (ref null $B)) (drop ;; B is a subtype of A, so this can work. - (ref.test_static $B + (ref.test $B (local.get $A) ) ) (drop ;; The other direction works too. - (ref.test_static $A + (ref.test $A (local.get $B) ) ) ) ;; CHECK: (func $ref.test-unreachable (type $ref?|$A|_=>_none) (param $A (ref null $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $A + ;; CHECK-NEXT: (ref.test $A ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref.test-unreachable (type $ref?|$A|_=>_none) (param $A (ref null $A)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $A + ;; NOMNL-NEXT: (ref.test $A ;; NOMNL-NEXT: (unreachable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1979,7 +1979,7 @@ (drop ;; We should ignore unreachable ref.tests and not try to compare their ;; HeapTypes. - (ref.test_static $A + (ref.test $A (unreachable) ) ) @@ -1987,7 +1987,7 @@ ;; CHECK: (func $consecutive-opts-with-unreachable (type $funcref_=>_none) (param $func funcref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (block (result (ref i31)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $func) @@ -1999,7 +1999,7 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $consecutive-opts-with-unreachable (type $funcref_=>_none) (param $func funcref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (block (result (ref i31)) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (local.get $func) @@ -2011,10 +2011,10 @@ ;; NOMNL-NEXT: ) (func $consecutive-opts-with-unreachable (param $func funcref) (drop - (ref.cast_static $struct + (ref.cast null $struct ;; Casting a funcref to i31 will definitely fail, so this will be ;; replaced with an unreachable. But it should be enclosed in a block of - ;; the previous type, so that the outside ref.cast is not confused. This + ;; the previous type, so that the outside ref.cast null is not confused. This ;; is a regression test for a bug where we replace this node with an ;; unreachable one, but we left refinalize til the end of all the other ;; opts - and that meant that we got to our parent, the ref.cast, with @@ -2106,23 +2106,23 @@ (local $a (ref null $A)) ;; Casting nulls results in a null. (drop - (ref.cast_static $A + (ref.cast null $A (ref.null $A) ) ) (drop - (ref.cast_static $A + (ref.cast null $A (ref.null $B) ) ) (drop - (ref.cast_static $B + (ref.cast null $B (ref.null $A) ) ) ;; A fallthrough works too. (drop - (ref.cast_static $A + (ref.cast null $A (local.tee $a (ref.null $A) ) @@ -2153,7 +2153,7 @@ (func $ref-cast-static-impossible (param $func (ref func)) ;; A func cannot be cast to a struct, so this will trap. (drop - (ref.cast_static $struct + (ref.cast null $struct (local.get $func) ) ) @@ -2167,7 +2167,7 @@ ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2185,7 +2185,7 @@ ;; NOMNL-NEXT: (local.get $b) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $a) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2199,24 +2199,24 @@ ;; In the general case, a static cast of something simply succeeds if the ;; type is a subtype. (drop - (ref.cast_static $A + (ref.cast null $A (local.get $a) ) ) (drop - (ref.cast_static $A + (ref.cast null $A (local.get $b) ) ) ;; This is the only one that we cannot know for sure will succeed. (drop - (ref.cast_static $B + (ref.cast null $B (local.get $a) ) ) ;; A fallthrough works too. (drop - (ref.cast_static $A + (ref.cast null $A (local.tee $a (local.get $a) ) @@ -2226,34 +2226,34 @@ ;; CHECK: (func $ref-cast-static-squared (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-squared (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $A + ;; NOMNL-NEXT: (ref.cast null $A ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2261,23 +2261,23 @@ (func $ref-cast-static-squared (param $x eqref) ;; Identical ref.casts can be folded together. (drop - (ref.cast_static $A - (ref.cast_static $A + (ref.cast null $A + (ref.cast null $A (local.get $x) ) ) ) ;; When subtypes exist, we only need the stricter one. (drop - (ref.cast_static $A - (ref.cast_static $B + (ref.cast null $A + (ref.cast null $B (local.get $x) ) ) ) (drop - (ref.cast_static $B - (ref.cast_static $A + (ref.cast null $B + (ref.cast null $A (local.get $x) ) ) @@ -2286,64 +2286,64 @@ ;; CHECK: (func $ref-cast-static-many (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-many (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2352,54 +2352,54 @@ ;; We should optimize a long sequence of static casts when we can. All six ;; orderings of these casts should collapse into the strictest one. (drop - (ref.cast_static $A - (ref.cast_static $B - (ref.cast_static $B-child + (ref.cast null $A + (ref.cast null $B + (ref.cast null $B-child (local.get $x) ) ) ) ) (drop - (ref.cast_static $A - (ref.cast_static $B-child - (ref.cast_static $B + (ref.cast null $A + (ref.cast null $B-child + (ref.cast null $B (local.get $x) ) ) ) ) (drop - (ref.cast_static $B - (ref.cast_static $A - (ref.cast_static $B-child + (ref.cast null $B + (ref.cast null $A + (ref.cast null $B-child (local.get $x) ) ) ) ) (drop - (ref.cast_static $B - (ref.cast_static $B-child - (ref.cast_static $A + (ref.cast null $B + (ref.cast null $B-child + (ref.cast null $A (local.get $x) ) ) ) ) (drop - (ref.cast_static $B-child - (ref.cast_static $A - (ref.cast_static $B + (ref.cast null $B-child + (ref.cast null $A + (ref.cast null $B (local.get $x) ) ) ) ) (drop - (ref.cast_static $B-child - (ref.cast_static $B - (ref.cast_static $A + (ref.cast null $B-child + (ref.cast null $B + (ref.cast null $A (local.get $x) ) ) @@ -2409,14 +2409,14 @@ ;; CHECK: (func $ref-cast-static-very-many (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B-child + ;; CHECK-NEXT: (ref.cast null $B-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-very-many (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B-child + ;; NOMNL-NEXT: (ref.cast null $B-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2424,18 +2424,18 @@ (func $ref-cast-static-very-many (param $x eqref) ;; We should optimize an arbitrarily-long long sequence of static casts. (drop - (ref.cast_static $A - (ref.cast_static $B - (ref.cast_static $B-child - (ref.cast_static $A - (ref.cast_static $A - (ref.cast_static $B-child - (ref.cast_static $B-child - (ref.cast_static $B - (ref.cast_static $B - (ref.cast_static $B - (ref.cast_static $B-child - (ref.cast_static $A + (ref.cast null $A + (ref.cast null $B + (ref.cast null $B-child + (ref.cast null $A + (ref.cast null $A + (ref.cast null $B-child + (ref.cast null $B-child + (ref.cast null $B + (ref.cast null $B + (ref.cast null $B + (ref.cast null $B-child + (ref.cast null $A (local.get $x) ) ) @@ -2458,7 +2458,7 @@ ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2470,7 +2470,7 @@ ;; NOMNL-NEXT: (call $ref-cast-static-fallthrough-remaining ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2478,7 +2478,7 @@ ;; NOMNL-NEXT: ) (func $ref-cast-static-fallthrough-remaining (param $x eqref) (drop - (ref.cast_static $A + (ref.cast null $A (block (result (ref null $B)) ;; Additional contents in between redundant casts must be preserved. ;; That is, when we see that the casts are redundant, by seeing that @@ -2491,7 +2491,7 @@ (call $ref-cast-static-fallthrough-remaining (local.get $x) ) - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) @@ -2501,12 +2501,12 @@ ;; CHECK: (func $ref-cast-static-fallthrough-remaining-child (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (block (result eqref) ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining-child ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2515,12 +2515,12 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-fallthrough-remaining-child (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (block (result eqref) ;; NOMNL-NEXT: (call $ref-cast-static-fallthrough-remaining-child ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (ref.cast_static $A + ;; NOMNL-NEXT: (ref.cast null $A ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2532,12 +2532,12 @@ ;; As above, but with $A and $B flipped. Now the inner cast is not needed. ;; However, we do not remove it, as it may be necessary for validation, ;; and we hope other opts help out here. - (ref.cast_static $B + (ref.cast null $B (block (result (eqref)) (call $ref-cast-static-fallthrough-remaining-child (local.get $x) ) - (ref.cast_static $A + (ref.cast null $A (local.get $x) ) ) @@ -2553,7 +2553,7 @@ ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining-impossible ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2570,7 +2570,7 @@ ;; NOMNL-NEXT: (call $ref-cast-static-fallthrough-remaining-impossible ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (ref.cast_static $struct + ;; NOMNL-NEXT: (ref.cast null $struct ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2584,12 +2584,12 @@ ;; As above, but with an impossible cast of an array to a struct. The ;; block with the side effects and the inner cast must be kept around and ;; dropped, and then we replace the outer cast with an unreachable. - (ref.cast_static $array + (ref.cast null $array (block (result (ref eq)) (call $ref-cast-static-fallthrough-remaining-impossible (local.get $x) ) - (ref.cast_static $struct + (ref.cast null $struct (local.get $x) ) ) @@ -2599,12 +2599,12 @@ ;; CHECK: (func $ref-cast-static-fallthrough-remaining-nonnull (type $ref|eq|_=>_none) (param $x (ref eq)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (block (result (ref eq)) ;; CHECK-NEXT: (call $ref-cast-static-fallthrough-remaining ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2613,12 +2613,12 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-fallthrough-remaining-nonnull (type $ref|eq|_=>_none) (param $x (ref eq)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $A + ;; NOMNL-NEXT: (ref.cast null $A ;; NOMNL-NEXT: (block (result (ref eq)) ;; NOMNL-NEXT: (call $ref-cast-static-fallthrough-remaining ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2632,12 +2632,12 @@ ;; the middle block prevents us from seeing that (after other opts run, ;; however, we would). (drop - (ref.cast_static $A + (ref.cast null $A (block (result (ref eq)) (call $ref-cast-static-fallthrough-remaining (local.get $x) ) - (ref.cast_static $B + (ref.cast null $B (local.get $x) ) ) @@ -2647,8 +2647,8 @@ ;; CHECK: (func $ref-cast-static-squared-impossible (type $eqref_=>_none) (param $x eqref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $struct + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2657,7 +2657,7 @@ ;; CHECK-NEXT: (block (result (ref $struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (ref.cast_static $array + ;; CHECK-NEXT: (ref.cast null $array ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2668,8 +2668,8 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-cast-static-squared-impossible (type $eqref_=>_none) (param $x eqref) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.cast_static $struct - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $struct + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2678,7 +2678,7 @@ ;; NOMNL-NEXT: (block (result (ref $struct)) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (ref.as_non_null - ;; NOMNL-NEXT: (ref.cast_static $array + ;; NOMNL-NEXT: (ref.cast null $array ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2690,15 +2690,15 @@ (func $ref-cast-static-squared-impossible (param $x eqref) ;; Impossible casts will trap unless the input is null. (drop - (ref.cast_static $struct - (ref.cast_static $array + (ref.cast null $struct + (ref.cast null $array (local.get $x) ) ) ) (drop - (ref.cast_static $struct - (ref.cast_static $array + (ref.cast null $struct + (ref.cast null $array (ref.as_non_null (local.get $x)) ) ) @@ -2707,7 +2707,7 @@ ;; CHECK: (func $ref-test-static-same-type (type $ref?|$A|_ref|$A|_=>_none) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $A + ;; CHECK-NEXT: (ref.test $A ;; CHECK-NEXT: (local.get $nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2722,7 +2722,7 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-test-static-same-type (type $ref?|$A|_ref|$A|_=>_none) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $A + ;; NOMNL-NEXT: (ref.test $A ;; NOMNL-NEXT: (local.get $nullable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2739,13 +2739,13 @@ ;; A nullable value cannot be optimized here even though it is the same ;; type. (drop - (ref.test_static $A + (ref.test $A (local.get $nullable) ) ) ;; But if it is non-nullable, it must succeed. (drop - (ref.test_static $A + (ref.test $A (local.get $non-nullable) ) ) @@ -2753,7 +2753,7 @@ ;; CHECK: (func $ref-test-static-subtype (type $ref?|$B|_ref|$B|_=>_none) (param $nullable (ref null $B)) (param $non-nullable (ref $B)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $A + ;; CHECK-NEXT: (ref.test $A ;; CHECK-NEXT: (local.get $nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2768,7 +2768,7 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-test-static-subtype (type $ref?|$B|_ref|$B|_=>_none) (param $nullable (ref null $B)) (param $non-nullable (ref $B)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $A + ;; NOMNL-NEXT: (ref.test $A ;; NOMNL-NEXT: (local.get $nullable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2784,12 +2784,12 @@ (func $ref-test-static-subtype (param $nullable (ref null $B)) (param $non-nullable (ref $B)) ;; As above, but the input is a subtype, so the same things happen. (drop - (ref.test_static $A + (ref.test $A (local.get $nullable) ) ) (drop - (ref.test_static $A + (ref.test $A (local.get $non-nullable) ) ) @@ -2797,24 +2797,24 @@ ;; CHECK: (func $ref-test-static-supertype (type $ref?|$A|_ref|$A|_=>_none) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (local.get $nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $B + ;; CHECK-NEXT: (ref.test $B ;; CHECK-NEXT: (local.get $non-nullable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $ref-test-static-supertype (type $ref?|$A|_ref|$A|_=>_none) (param $nullable (ref null $A)) (param $non-nullable (ref $A)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $B + ;; NOMNL-NEXT: (ref.test $B ;; NOMNL-NEXT: (local.get $nullable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $B + ;; NOMNL-NEXT: (ref.test $B ;; NOMNL-NEXT: (local.get $non-nullable) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2823,12 +2823,12 @@ ;; As above, but the input is a supertype. We can't know at compile time ;; what to do here. (drop - (ref.test_static $B + (ref.test $B (local.get $nullable) ) ) (drop - (ref.test_static $B + (ref.test $B (local.get $non-nullable) ) ) @@ -2873,12 +2873,12 @@ (func $ref-test-static-impossible (param $nullable (ref null $array)) (param $non-nullable (ref $array)) ;; Testing an impossible cast will definitely fail. (drop - (ref.test_static $struct + (ref.test $struct (local.get $nullable) ) ) (drop - (ref.test_static $struct + (ref.test $struct (local.get $non-nullable) ) ) @@ -2897,7 +2897,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.test_static $A + ;; CHECK-NEXT: (ref.test $A ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -2915,7 +2915,7 @@ ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (ref.test_static $A + ;; NOMNL-NEXT: (ref.test $A ;; NOMNL-NEXT: (local.get $x) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -2942,7 +2942,7 @@ ) (drop (i32.and - (ref.test_static $A + (ref.test $A (local.get $x) ) (i32.const 1) diff --git a/test/lit/passes/optimize-instructions-iit-eh.wast b/test/lit/passes/optimize-instructions-iit-eh.wast index 6d8a8fe39..cf69e4b90 100644 --- a/test/lit/passes/optimize-instructions-iit-eh.wast +++ b/test/lit/passes/optimize-instructions-iit-eh.wast @@ -25,13 +25,13 @@ (do) (catch $e (throw $e - ;; Because --ignore-implicit-traps is given, this ref.cast_static is - ;; assumed not to throw so this ref.cast can be statically removed. + ;; Because --ignore-implicit-traps is given, this ref.cast null is + ;; assumed not to throw so this ref.cast null can be statically removed. ;; But that creates a block around this, making 'pop' nested into it, ;; which is invalid. We fix this up at the end up OptimizeInstruction, ;; assigning the 'pop' to a local at the start of this 'catch' body ;; and later using 'local.get' to get it. - (ref.cast_static $struct.A + (ref.cast null $struct.A (pop (ref null $struct.A)) ) ) diff --git a/test/lit/passes/precompute-gc-immutable.wast b/test/lit/passes/precompute-gc-immutable.wast index 2420a139c..5b0d4dffd 100644 --- a/test/lit/passes/precompute-gc-immutable.wast +++ b/test/lit/passes/precompute-gc-immutable.wast @@ -794,7 +794,7 @@ ;; We can precompute all these operations away into the final constants. (call $helper (struct.get $vtable-0 0 - (ref.cast_static $vtable-0 + (ref.cast null $vtable-0 (array.get $itable (struct.get $object 0 (local.get $ref) @@ -806,7 +806,7 @@ ) (call $helper (struct.get $vtable-1 0 - (ref.cast_static $vtable-1 + (ref.cast null $vtable-1 (array.get $itable (struct.get $object 0 (local.get $ref) diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast index 7c4292ea2..26f22fa6a 100644 --- a/test/lit/passes/precompute-gc.wast +++ b/test/lit/passes/precompute-gc.wast @@ -1084,10 +1084,10 @@ (local $temp (ref null $B)) ;; Try to cast a null of A to B. While the types are incompatible, ref.cast ;; returns a null when given a null (and the null must have the type that the - ;; ref.cast instruction has, that is, the value is a null of type $B). So this + ;; ref.cast null instruction has, that is, the value is a null of type $B). So this ;; is an odd cast that "works". (local.set $temp - (ref.cast_static $B + (ref.cast null $B (ref.null $A) ) ) @@ -1139,7 +1139,7 @@ ;; As above, but with a tuple. (local.set $temp (tuple.make - (ref.cast_static $B + (ref.cast null $B (ref.null $A) ) (i32.const 10) @@ -1166,7 +1166,7 @@ ;; CHECK: (func $odd-cast-and-get-non-null (type $ref|$func-return-i32|_=>_none) (param $temp (ref $func-return-i32)) ;; CHECK-NEXT: (local.set $temp - ;; CHECK-NEXT: (ref.cast_static $func-return-i32 + ;; CHECK-NEXT: (ref.cast null $func-return-i32 ;; CHECK-NEXT: (ref.func $receive-f64) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1178,7 +1178,7 @@ ;; CHECK-NEXT: ) ;; NOMNL: (func $odd-cast-and-get-non-null (type $ref|$func-return-i32|_=>_none) (param $temp (ref $func-return-i32)) ;; NOMNL-NEXT: (local.set $temp - ;; NOMNL-NEXT: (ref.cast_static $func-return-i32 + ;; NOMNL-NEXT: (ref.cast null $func-return-i32 ;; NOMNL-NEXT: (ref.func $receive-f64) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1191,7 +1191,7 @@ (func $odd-cast-and-get-non-null (param $temp (ref $func-return-i32)) ;; Try to cast a function to an incompatible type. (local.set $temp - (ref.cast_static $func-return-i32 + (ref.cast null $func-return-i32 (ref.func $receive-f64) ) ) @@ -1238,7 +1238,7 @@ ;; CHECK: (func $br_on_cast-on-creation (type $none_=>_ref|$empty|) (result (ref $empty)) ;; CHECK-NEXT: (block $label (result (ref $empty)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $label $empty + ;; CHECK-NEXT: (br_on_cast $label $empty ;; CHECK-NEXT: (struct.new_default $empty) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -1248,7 +1248,7 @@ ;; NOMNL: (func $br_on_cast-on-creation (type $none_=>_ref|$empty|) (result (ref $empty)) ;; NOMNL-NEXT: (block $label (result (ref $empty)) ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (br_on_cast_static $label $empty + ;; NOMNL-NEXT: (br_on_cast $label $empty ;; NOMNL-NEXT: (struct.new_default $empty) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -1258,7 +1258,7 @@ (func $br_on_cast-on-creation (result (ref $empty)) (block $label (result (ref $empty)) (drop - (br_on_cast_static $label $empty + (br_on_cast $label $empty (struct.new_default $empty) ) ) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 3de48c441..c448a47c2 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -116,7 +116,7 @@ ) ) - ;; CHECK: (func $br_on_cast_static (type $none_=>_ref|$struct|) (result (ref $struct)) + ;; CHECK: (func $br_on_cast (type $none_=>_ref|$struct|) (result (ref $struct)) ;; CHECK-NEXT: (local $temp (ref null $struct)) ;; CHECK-NEXT: (block $block (result (ref $struct)) ;; CHECK-NEXT: (drop @@ -127,13 +127,13 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_static (result (ref $struct)) + (func $br_on_cast (result (ref $struct)) (local $temp (ref null $struct)) (block $block (result (ref $struct)) (drop ;; This static cast can be computed at compile time: it will definitely be ;; taken, so we can turn it into a normal br. - (br_on_cast_static $block $struct + (br_on_cast $block $struct (struct.new $struct) ) ) @@ -141,22 +141,22 @@ ) ) - ;; CHECK: (func $br_on_cast_static_no (type $none_=>_ref|$struct|) (result (ref $struct)) + ;; CHECK: (func $br_on_cast_no (type $none_=>_ref|$struct|) (result (ref $struct)) ;; CHECK-NEXT: (local $temp (ref null $struct)) ;; CHECK-NEXT: (block $block (result (ref $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $block $struct + ;; CHECK-NEXT: (br_on_cast $block $struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_static_no (result (ref $struct)) + (func $br_on_cast_no (result (ref $struct)) (local $temp (ref null $struct)) (block $block (result (ref $struct)) (drop - (br_on_cast_static $block $struct + (br_on_cast $block $struct ;; As above, but now the type is nullable, so we cannot infer anything. (ref.null $struct) ) @@ -165,7 +165,7 @@ ) ) - ;; CHECK: (func $br_on_cast_fail_static (type $none_=>_ref|$struct|) (result (ref $struct)) + ;; CHECK: (func $br_on_cast_fail (type $none_=>_ref|$struct|) (result (ref $struct)) ;; CHECK-NEXT: (local $temp (ref null $struct)) ;; CHECK-NEXT: (block $block ;; CHECK-NEXT: (drop @@ -174,13 +174,13 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_fail_static (result (ref $struct)) + (func $br_on_cast_fail (result (ref $struct)) (local $temp (ref null $struct)) (block $block (result (ref $struct)) (drop - ;; As $br_on_cast_static, but this checks for a failing cast, so we know it will + ;; As $br_on_cast, but this checks for a failing cast, so we know it will ;; *not* be taken. - (br_on_cast_static_fail $block $struct + (br_on_cast_fail $block $struct (struct.new $struct) ) ) @@ -192,7 +192,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (ref.test_static $struct + ;; CHECK-NEXT: (ref.test $struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 0) @@ -202,7 +202,7 @@ ;; CHECK-NEXT: (if (result anyref) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (ref.null none) - ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (ref.cast null $struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -212,7 +212,7 @@ ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: (block $something (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_static $something $struct + ;; CHECK-NEXT: (br_on_cast $something $struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -245,7 +245,7 @@ (drop (if (result i32) (local.get $x) - (ref.test_static $struct + (ref.test $struct (ref.null any) ) (i32.const 0) @@ -255,7 +255,7 @@ (if (result anyref) (local.get $x) (ref.null any) - (ref.cast_static $struct + (ref.cast null $struct (ref.null any) ) ) @@ -266,7 +266,7 @@ (block (result anyref) (block $something (result anyref) (drop - (br_on_cast_static $something $struct + (br_on_cast $something $struct (ref.null $struct) ) ) diff --git a/test/lit/passes/rse-gc.wast b/test/lit/passes/rse-gc.wast index 231c4107a..935006680 100644 --- a/test/lit/passes/rse-gc.wast +++ b/test/lit/passes/rse-gc.wast @@ -52,7 +52,7 @@ ;; CHECK: (func $pick-refined (type $ref?|$A|_i32_=>_none) (param $A (ref null $A)) (param $x i32) ;; CHECK-NEXT: (local $B (ref null $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -81,7 +81,7 @@ (func $pick-refined (param $A (ref null $A)) (param $x i32) (local $B (ref null $B)) (local.set $B - (ref.cast_static $B + (ref.cast null $B (local.get $A) ) ) @@ -113,7 +113,7 @@ ;; CHECK: (func $pick-refined-nn (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (local $B (ref $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -129,7 +129,7 @@ ;; As above, but now the types are both non-nullable. We should still switch ;; to $B. (local.set $B - (ref.cast_static $B + (ref.cast null $B (local.get $A) ) ) @@ -144,7 +144,7 @@ ;; CHECK: (func $avoid-unrefined (type $ref|$A|_=>_none) (param $A (ref $A)) ;; CHECK-NEXT: (local $B (ref null $B)) ;; CHECK-NEXT: (local.set $B - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -161,7 +161,7 @@ ;; nullable, that means neither is a subtype of the other, and we will make ;; no changes. (local.set $B - (ref.cast_static $B + (ref.cast null $B (local.get $A) ) ) diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index 7d1a0d197..01aebe3bb 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -793,7 +793,7 @@ (type $A (struct)) ;; CHECK: (func $0 (type $none_=>_none) ;; CHECK-NEXT: (local $0 f32) - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -804,7 +804,7 @@ ;; we do need to handle it in the optimization as well as print it (note how ;; type $A is declared in the output here - it would be a bug if it were ;; not, which this is a regression test for). - (ref.cast_static $A + (ref.cast null $A (unreachable) ) ) diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index b71da529c..d97d206a1 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -604,7 +604,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $B 0 ;; CHECK-NEXT: (local.tee $B - ;; CHECK-NEXT: (ref.cast_static $B + ;; CHECK-NEXT: (ref.cast null $B ;; CHECK-NEXT: (local.get $A) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -632,7 +632,7 @@ ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (struct.get $B 0 ;; NOMNL-NEXT: (local.tee $B - ;; NOMNL-NEXT: (ref.cast_static $B + ;; NOMNL-NEXT: (ref.cast null $B ;; NOMNL-NEXT: (local.get $A) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) @@ -655,7 +655,7 @@ ;; nullability but not the heap type. (local $B (ref null $B)) (local.set $B - (ref.cast_static $B + (ref.cast null $B (local.get $A) ) ) diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast index f28cf0e1d..56e339777 100644 --- a/test/lit/passes/type-merging.wast +++ b/test/lit/passes/type-merging.wast @@ -19,12 +19,12 @@ ;; CHECK-NEXT: (local $c (ref null $C)) ;; CHECK-NEXT: (local $d (ref null $D)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $A + ;; CHECK-NEXT: (ref.cast null $A ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $D + ;; CHECK-NEXT: (ref.cast null $D ;; CHECK-NEXT: (local.get $a) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -41,13 +41,13 @@ ;; A cast of $A has no effect. (drop - (ref.cast_static $A + (ref.cast null $A (local.get $a) ) ) ;; A cast of $D prevents it from being merged. (drop - (ref.cast_static $D + (ref.cast null $D (local.get $a) ) ) diff --git a/test/lit/passes/type-ssa.wast b/test/lit/passes/type-ssa.wast index 790c6488a..abc47901f 100644 --- a/test/lit/passes/type-ssa.wast +++ b/test/lit/passes/type-ssa.wast @@ -374,7 +374,7 @@ ) ) - ;; CHECK: (func $array.init (type $ref|i31|_anyref_=>_none) (param $refined (ref i31)) (param $null-any anyref) + ;; CHECK: (func $array.init_static (type $ref|i31|_anyref_=>_none) (param $refined (ref i31)) (param $null-any anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (array.init_static $array$5 ;; CHECK-NEXT: (ref.null none) @@ -397,7 +397,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $array.init (type $ref|i31|_anyref_=>_none) (param $refined (ref i31)) (param $null-any anyref) + ;; NOMNL: (func $array.init_static (type $ref|i31|_anyref_=>_none) (param $refined (ref i31)) (param $null-any anyref) ;; NOMNL-NEXT: (drop ;; NOMNL-NEXT: (array.init_static $array$5 ;; NOMNL-NEXT: (ref.null none) @@ -420,7 +420,7 @@ ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) - (func $array.init (param $refined (ref i31)) (param $null-any (ref null any)) + (func $array.init_static (param $refined (ref i31)) (param $null-any (ref null any)) ;; Null, interesting, so we get a new type. (drop (array.init_static $array diff --git a/test/lit/ref-cast-nop.wast b/test/lit/ref-cast-nop.wast index 51df10947..060005f4d 100644 --- a/test/lit/ref-cast-nop.wast +++ b/test/lit/ref-cast-nop.wast @@ -5,13 +5,13 @@ (module ;; CHECK: (type $struct (struct (field i32))) (type $struct (struct i32)) - ;; CHECK: (func $ref.cast_nop_static (type $ref|any|_=>_ref|$struct|) (param $x (ref any)) (result (ref $struct)) - ;; CHECK-NEXT: (ref.cast_nop_static $struct + ;; CHECK: (func $ref.cast_nop (type $ref|any|_=>_ref|$struct|) (param $x (ref any)) (result (ref $struct)) + ;; CHECK-NEXT: (ref.cast_nop $struct ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref.cast_nop_static (param $x (ref any)) (result (ref $struct)) - (ref.cast_nop_static $struct + (func $ref.cast_nop (param $x (ref any)) (result (ref $struct)) + (ref.cast_nop $struct (local.get $x) ) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index 1d2fe7ed5..afeae72f0 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -42,11 +42,11 @@ [LoggingExternalInterface logging 99] [LoggingExternalInterface logging 0] [LoggingExternalInterface logging 10] -[fuzz-exec] calling array.init +[fuzz-exec] calling array.init_static [LoggingExternalInterface logging 2] [LoggingExternalInterface logging 42] [LoggingExternalInterface logging 50] -[fuzz-exec] calling array.init-packed +[fuzz-exec] calling array.init_static-packed [LoggingExternalInterface logging 8] [fuzz-exec] calling static-casts [LoggingExternalInterface logging 1] @@ -82,8 +82,8 @@ (export "init-array-packed" (func $14)) (export "cast-func-to-struct" (func $9)) (export "array-copy" (func $17)) - (export "array.init" (func $18)) - (export "array.init-packed" (func $19)) + (export "array.init_static" (func $18)) + (export "array.init_static-packed" (func $19)) (export "static-casts" (func $20)) (export "static-br_on_cast" (func $2)) (export "static-br_on_cast_fail" (func $22)) @@ -162,7 +162,7 @@ (i32.const 1) ) (drop - (br_on_cast_static_fail $any $extendedstruct + (br_on_cast_fail $any $extendedstruct (local.get $0) ) ) @@ -384,11 +384,11 @@ [LoggingExternalInterface logging 99] [LoggingExternalInterface logging 0] [LoggingExternalInterface logging 10] -[fuzz-exec] calling array.init +[fuzz-exec] calling array.init_static [LoggingExternalInterface logging 2] [LoggingExternalInterface logging 42] [LoggingExternalInterface logging 50] -[fuzz-exec] calling array.init-packed +[fuzz-exec] calling array.init_static-packed [LoggingExternalInterface logging 8] [fuzz-exec] calling static-casts [LoggingExternalInterface logging 1] diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 3d86b9f99..203fc60fe 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -84,9 +84,9 @@ (block $extendedblock (result (ref $extendedstruct)) (drop ;; second, try to cast our simple $struct to what it is, which will work - (br_on_cast_static $block $struct + (br_on_cast $block $struct ;; first, try to cast our simple $struct to an extended, which will fail - (br_on_cast_static $extendedblock $extendedstruct + (br_on_cast $extendedblock $extendedstruct (local.get $any) ) ) @@ -113,7 +113,7 @@ (drop ;; try to cast our simple $struct to an extended, which will fail, and ;; so we will branch, skipping the next logging. - (br_on_cast_static_fail $any $extendedstruct + (br_on_cast_fail $any $extendedstruct (local.get $any) ) ) @@ -134,7 +134,7 @@ (drop ;; try to cast our simple $struct to an extended, which will succeed, and ;; so we will continue to the next logging. - (br_on_cast_static_fail $any $extendedstruct + (br_on_cast_fail $any $extendedstruct (local.get $any) ) ) @@ -148,7 +148,7 @@ ;; array or a struct, so our casting code should not assume it is. it is ok ;; to try to cast it, and the result should be 0. (call $log - (ref.test_static $struct + (ref.test $struct (ref.null any) ) ) @@ -199,12 +199,12 @@ (call $log (i32.const 0)) ;; a valid cast (call_ref $void_func - (ref.cast_static $void_func (ref.func $a-void-func)) + (ref.cast null $void_func (ref.func $a-void-func)) ) (call $log (i32.const 1)) ;; an invalid cast (drop (call_ref $int_func - (ref.cast_static $int_func (ref.func $a-void-func)) + (ref.cast null $int_func (ref.func $a-void-func)) )) ;; will never be reached (call $log (i32.const 2)) @@ -236,7 +236,7 @@ (func "cast-func-to-struct" (drop ;; An impossible cast of a function to a struct, which should fail. - (ref.cast_static $struct + (ref.cast null $struct (ref.func $call-target) ) ) @@ -287,7 +287,7 @@ (array.get_u $bytes (local.get $x) (i32.const 12)) ) ) - (func "array.init" + (func "array.init_static" (local $x (ref null $bytes)) (local.set $x (array.init_static $bytes @@ -308,7 +308,7 @@ (array.get_u $bytes (local.get $x) (i32.const 1)) ) ) - (func "array.init-packed" + (func "array.init_static-packed" (local $x (ref null $bytes)) (local.set $x (array.init_static $bytes @@ -323,15 +323,15 @@ (func "static-casts" ;; Casting null returns null. (call $log (ref.is_null - (ref.cast_static $struct (ref.null $struct)) + (ref.cast null $struct (ref.null $struct)) )) ;; Testing null returns 0. (call $log - (ref.test_static $struct (ref.null $struct)) + (ref.test $struct (ref.null $struct)) ) ;; Testing something completely wrong (struct vs array) returns 0. (call $log - (ref.test_static $struct + (ref.test $struct (array.new $bytes (i32.const 20) (i32.const 10) @@ -340,19 +340,19 @@ ) ;; Testing a thing with the same type returns 1. (call $log - (ref.test_static $struct + (ref.test $struct (struct.new_default $struct) ) ) ;; A bad downcast returns 0: we create a struct, which is not a extendedstruct. (call $log - (ref.test_static $extendedstruct + (ref.test $extendedstruct (struct.new_default $struct) ) ) ;; Casting to a supertype works. (call $log - (ref.test_static $struct + (ref.test $struct (struct.new_default $extendedstruct) ) ) @@ -369,9 +369,9 @@ (block $extendedblock (result (ref $extendedstruct)) (drop ;; second, try to cast our simple $struct to what it is, which will work - (br_on_cast_static $block $struct + (br_on_cast $block $struct ;; first, try to cast our simple $struct to an extended, which will fail - (br_on_cast_static $extendedblock $extendedstruct + (br_on_cast $extendedblock $extendedstruct (local.get $any) ) ) @@ -396,7 +396,7 @@ (block $failblock (result anyref) (drop ;; try to cast our simple $struct to an extended, which will fail - (br_on_cast_static_fail $failblock $extendedstruct + (br_on_cast_fail $failblock $extendedstruct (local.get $any) ) ) diff --git a/test/spec/array-new-elem.wast b/test/spec/array-new-elem.wast index d20d8109b..9e1ac9116 100644 --- a/test/spec/array-new-elem.wast +++ b/test/spec/array-new-elem.wast @@ -16,7 +16,7 @@ ) (func $get (param $i i32) (param $v (ref $vec)) (result i32) - (call_ref $f (ref.cast_static $f (array.get $vec (local.get $v) (local.get $i)))) + (call_ref $f (ref.cast null $f (array.get $vec (local.get $v) (local.get $i)))) ) (func (export "get") (param $i i32) (result i32) (call $get (local.get $i) (call $new)) @@ -24,7 +24,7 @@ (func $set_get (param $i i32) (param $v (ref $mvec)) (param $y i32) (result i32) (array.set $mvec (local.get $v) (local.get $i) (array.get $mvec (local.get $v) (local.get $y))) - (call_ref $f (ref.cast_static $f (array.get $mvec (local.get $v) (local.get $i)))) + (call_ref $f (ref.cast null $f (array.get $mvec (local.get $v) (local.get $i)))) ) (func (export "set_get") (param $i i32) (param $y i32) (result i32) (call $set_get diff --git a/test/spec/ref_cast.wast b/test/spec/ref_cast.wast index 86f958b80..53ca9227c 100644 --- a/test/spec/ref_cast.wast +++ b/test/spec/ref_cast.wast @@ -29,37 +29,37 @@ (func (export "test-sub") (call $init) - (drop (ref.cast_static $t0 (ref.null data))) - (drop (ref.cast_static $t0 (global.get $tab.0))) - (drop (ref.cast_static $t0 (global.get $tab.1))) - (drop (ref.cast_static $t0 (global.get $tab.2))) - (drop (ref.cast_static $t0 (global.get $tab.3))) - (drop (ref.cast_static $t0 (global.get $tab.4))) + (drop (ref.cast null $t0 (ref.null data))) + (drop (ref.cast null $t0 (global.get $tab.0))) + (drop (ref.cast null $t0 (global.get $tab.1))) + (drop (ref.cast null $t0 (global.get $tab.2))) + (drop (ref.cast null $t0 (global.get $tab.3))) + (drop (ref.cast null $t0 (global.get $tab.4))) - (drop (ref.cast_static $t0 (ref.null data))) - (drop (ref.cast_static $t1 (global.get $tab.1))) - (drop (ref.cast_static $t1 (global.get $tab.2))) + (drop (ref.cast null $t0 (ref.null data))) + (drop (ref.cast null $t1 (global.get $tab.1))) + (drop (ref.cast null $t1 (global.get $tab.2))) - (drop (ref.cast_static $t0 (ref.null data))) - (drop (ref.cast_static $t2 (global.get $tab.2))) + (drop (ref.cast null $t0 (ref.null data))) + (drop (ref.cast null $t2 (global.get $tab.2))) - (drop (ref.cast_static $t0 (ref.null data))) - (drop (ref.cast_static $t3 (global.get $tab.3))) + (drop (ref.cast null $t0 (ref.null data))) + (drop (ref.cast null $t3 (global.get $tab.3))) - (drop (ref.cast_static $t0 (ref.null data))) + (drop (ref.cast null $t0 (ref.null data))) ) (func (export "test-canon") (call $init) - (drop (ref.cast_static $t0 (global.get $tab.10))) - (drop (ref.cast_static $t0 (global.get $tab.11))) - (drop (ref.cast_static $t0 (global.get $tab.12))) + (drop (ref.cast null $t0 (global.get $tab.10))) + (drop (ref.cast null $t0 (global.get $tab.11))) + (drop (ref.cast null $t0 (global.get $tab.12))) - (drop (ref.cast_static $t1 (global.get $tab.11))) - (drop (ref.cast_static $t1 (global.get $tab.12))) + (drop (ref.cast null $t1 (global.get $tab.11))) + (drop (ref.cast null $t1 (global.get $tab.12))) - (drop (ref.cast_static $t2 (global.get $tab.12))) + (drop (ref.cast null $t2 (global.get $tab.12))) ) ) |