diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index e44a46c5f39..2e6a77d53c4 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -618,14 +618,17 @@ ("i31.get_u", "makeI31Get(false)"), ("ref.test", "makeRefTest()"), ("ref.cast", "makeRefCast(false)"), - ("ref.cast_desc", "makeRefCast(true)"), + ("ref.cast_desc", "makeRefCast(true)"), # Deprecated + ("ref.cast_desc_eq", "makeRefCast(true)"), ("ref.get_desc", "makeRefGetDesc()"), ("br_on_null", "makeBrOnNull()"), ("br_on_non_null", "makeBrOnNull(true)"), ("br_on_cast", "makeBrOnCast(BrOnCast)"), ("br_on_cast_fail", "makeBrOnCast(BrOnCastFail)"), - ("br_on_cast_desc", "makeBrOnCast(BrOnCastDesc)"), - ("br_on_cast_desc_fail", "makeBrOnCast(BrOnCastDescFail)"), + ("br_on_cast_desc", "makeBrOnCast(BrOnCastDescEq)"), # Deprecated + ("br_on_cast_desc_fail", "makeBrOnCast(BrOnCastDescEqFail)"), # Deprecated + ("br_on_cast_desc_eq", "makeBrOnCast(BrOnCastDescEq)"), + ("br_on_cast_desc_eq_fail", "makeBrOnCast(BrOnCastDescEqFail)"), ("struct.new", "makeStructNew(false, false)"), ("struct.new_default", "makeStructNew(true, false)"), ("struct.new_desc", "makeStructNew(false, true)"), diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 081b92199b8..0472d5a3dea 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -276,16 +276,38 @@ switch (buf[0]) { switch (buf[15]) { case '\0': if (op == "br_on_cast_desc"sv) { - CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDesc)); + CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEq)); return Ok{}; } goto parse_error; - case '_': - if (op == "br_on_cast_desc_fail"sv) { - CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescFail)); - return Ok{}; + case '_': { + switch (buf[16]) { + case 'e': { + switch (buf[18]) { + case '\0': + if (op == "br_on_cast_desc_eq"sv) { + CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEq)); + return Ok{}; + } + goto parse_error; + case '_': + if (op == "br_on_cast_desc_eq_fail"sv) { + CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEqFail)); + return Ok{}; + } + goto parse_error; + default: goto parse_error; + } + } + case 'f': + if (op == "br_on_cast_desc_fail"sv) { + CHECK_ERR(makeBrOnCast(ctx, pos, annotations, BrOnCastDescEqFail)); + return Ok{}; + } + goto parse_error; + default: goto parse_error; } - goto parse_error; + } default: goto parse_error; } } @@ -4894,12 +4916,23 @@ switch (buf[0]) { return Ok{}; } goto parse_error; - case '_': - if (op == "ref.cast_desc"sv) { - CHECK_ERR(makeRefCast(ctx, pos, annotations, true)); - return Ok{}; + case '_': { + switch (buf[13]) { + case '\0': + if (op == "ref.cast_desc"sv) { + CHECK_ERR(makeRefCast(ctx, pos, annotations, true)); + return Ok{}; + } + goto parse_error; + case '_': + if (op == "ref.cast_desc_eq"sv) { + CHECK_ERR(makeRefCast(ctx, pos, annotations, true)); + return Ok{}; + } + goto parse_error; + default: goto parse_error; } - goto parse_error; + } default: goto parse_error; } } diff --git a/src/ir/child-typer.h b/src/ir/child-typer.h index d93c9c05f0f..a6f87543814 100644 --- a/src/ir/child-typer.h +++ b/src/ir/child-typer.h @@ -911,15 +911,15 @@ template struct ChildTyper : OverriddenVisitor { return; case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: { + case BrOnCastDescEq: + case BrOnCastDescEqFail: { if (!target) { assert(curr->castType.isRef()); target = curr->castType; } auto top = target->getHeapType().getTop(); note(&curr->ref, Type(top, Nullable)); - if (curr->op == BrOnCastDesc || curr->op == BrOnCastDescFail) { + if (curr->op == BrOnCastDescEq || curr->op == BrOnCastDescEqFail) { auto desc = target->getHeapType().getDescriptorType(); assert(desc); note(&curr->desc, Type(*desc, Nullable)); diff --git a/src/ir/cost.h b/src/ir/cost.h index 41477af6e62..853040a3f19 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -692,8 +692,8 @@ struct CostAnalyzer : public OverriddenVisitor { case BrOnCast: case BrOnCastFail: return CastCost + visit(curr->ref); - case BrOnCastDesc: - case BrOnCastDescFail: + case BrOnCastDescEq: + case BrOnCastDescEqFail: // These are not as expensive as full casts, since they just do a // identity check on the descriptor. return 2 + visit(curr->ref) + visit(curr->desc); diff --git a/src/ir/struct-utils.h b/src/ir/struct-utils.h index dda054dd813..979c7c628f8 100644 --- a/src/ir/struct-utils.h +++ b/src/ir/struct-utils.h @@ -300,7 +300,7 @@ struct StructScanner void visitBrOn(BrOn* curr) { if (curr->desc && - (curr->op == BrOnCastDesc || curr->op == BrOnCastDescFail)) { + (curr->op == BrOnCastDescEq || curr->op == BrOnCastDescEqFail)) { handleDescRead(curr->getCastType()); } } diff --git a/src/ir/subtype-exprs.h b/src/ir/subtype-exprs.h index a3937ad88ba..a6f049c831e 100644 --- a/src/ir/subtype-exprs.h +++ b/src/ir/subtype-exprs.h @@ -329,8 +329,8 @@ struct SubtypingDiscoverer : public OverriddenVisitor { break; case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: + case BrOnCastDescEq: + case BrOnCastDescEqFail: self()->noteCast(curr->ref, curr->castType); break; } diff --git a/src/passes/AbstractTypeRefining.cpp b/src/passes/AbstractTypeRefining.cpp index d29cfb893c7..dae66c2ccc6 100644 --- a/src/passes/AbstractTypeRefining.cpp +++ b/src/passes/AbstractTypeRefining.cpp @@ -345,7 +345,7 @@ struct AbstractTypeRefining : public Pass { // We may have casts like this: // - // (ref.cast_desc (ref null $optimized-to-bottom) + // (ref.cast_desc_eq (ref null $optimized-to-bottom) // (some struct...) // (some desc...) // ) @@ -435,7 +435,7 @@ struct AbstractTypeRefining : public Pass { } // Optimize the same way we optimize ref.cast*. Builder builder(*getModule()); - bool isFail = curr->op == BrOnCastDescFail; + bool isFail = curr->op == BrOnCastDescEqFail; if (curr->castType.isExact() || (curr->desc && optimized->isBottom())) { if (curr->desc) { if (curr->desc->type.isNullable() && diff --git a/src/passes/GlobalStructInference.cpp b/src/passes/GlobalStructInference.cpp index 453783dbc94..26e6f38cee6 100644 --- a/src/passes/GlobalStructInference.cpp +++ b/src/passes/GlobalStructInference.cpp @@ -92,9 +92,9 @@ struct GlobalStructInference : public Pass { // type-based inference, and this remains empty. std::unordered_map> typeGlobals; - // Whether to optimize ref.cast to ref.cast_desc. This increases code size, so - // it may not always be beneficial (perhaps running it late in the pipeline, - // and before type-merging, could make sense). + // Whether to optimize ref.cast to ref.cast_desc_eq. This increases code size, + // so it may not always be beneficial (perhaps running it late in the + // pipeline, and before type-merging, could make sense). bool optimizeToDescCasts; std::unique_ptr subTypes; @@ -515,10 +515,11 @@ struct GlobalStructInference : public Pass { void visitRefCast(RefCast* curr) { // When we see (ref.cast $T), and the type has a descriptor, and that - // descriptor only has a single global, then we can do (ref.cast_desc) - // using the descriptor. Descriptor casts are usually more efficient - // than normal ones (and even more so if we get lucky and are in a loop, - // where the global.get of the descriptor can be hoisted). + // descriptor only has a single global, then we can do + // (ref.cast_desc_eq) using the descriptor. Descriptor casts are usually + // more efficient than normal ones (and even more so if we get lucky and + // are in a loop, where the global.get of the descriptor can be + // hoisted). // TODO: only do this when shrinkLevel == 0? if (!parent.optimizeToDescCasts) { return; @@ -535,8 +536,8 @@ struct GlobalStructInference : public Pass { return; } - // Check if the type has no (relevant) subtypes, as a ref.cast_desc will - // find precisely that type and nothing else. + // Check if the type has no (relevant) subtypes, as a ref.cast_desc_eq + // will find precisely that type and nothing else. if (!type.isExact() && !parent.subTypes->getStrictSubTypes(heapType).empty()) { return; diff --git a/src/passes/Heap2Local.cpp b/src/passes/Heap2Local.cpp index 093c52ac701..a0853a24c53 100644 --- a/src/passes/Heap2Local.cpp +++ b/src/passes/Heap2Local.cpp @@ -402,10 +402,10 @@ struct EscapeAnalyzer { } } else { // Either the child is the descriptor, in which case we consume it, or - // we have already optimized this ref.cast_desc for an allocation that - // flowed through as its `ref`. In the latter case the current child - // must have originally been the descriptor, so we can still say it's - // fully consumed, but we cannot assert that curr->desc == child. + // we have already optimized this ref.cast_desc_eq for an allocation + // that flowed through as its `ref`. In the latter case the current + // child must have originally been the descriptor, so we can still say + // it's fully consumed, but we cannot assert that curr->desc == child. fullyConsumes = true; } } @@ -869,7 +869,7 @@ struct Struct2Local : PostWalker { builder.makeUnreachable())); }; - // If we are doing a ref.cast_desc of the optimized allocation, but the + // If we are doing a ref.cast_desc_eq of the optimized allocation, but the // allocation does not have a descriptor, then we know the cast must fail. // We also know the cast must fail (except for nulls it might let through) // if the optimized allocation flows in as the descriptor, since it cannot @@ -877,15 +877,15 @@ struct Struct2Local : PostWalker { // having been considered to escape. bool allocIsCastRef = analyzer.getInteraction(curr->ref) == ParentChildInteraction::Flows; - bool allocIsCastDesc = + bool allocIsCastDescEq = analyzer.getInteraction(curr->desc) == ParentChildInteraction::Flows; - if (!allocation->desc || allocIsCastDesc) { + if (!allocation->desc || allocIsCastDescEq) { // It would seem convenient to use ChildLocalizer here, but we cannot. // ChildLocalizer would create a local.set for a desc operand with // side effects, but that local.set would not be reflected in the parent // map, so it would not be updated if the allocation flowing through // that desc operand were later optimized. - if (allocIsCastDesc && !allocIsCastRef && curr->type.isNullable()) { + if (allocIsCastDescEq && !allocIsCastRef && curr->type.isNullable()) { // There might be a null value to let through. Reuse curr as a cast to // null. Use a scratch local to move the reference value past the desc // value. diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index e54d3eebdff..8b8fd6987b1 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2223,7 +2223,7 @@ struct PrintExpressionContents } void visitRefCast(RefCast* curr) { if (curr->desc) { - printMedium(o, "ref.cast_desc "); + printMedium(o, "ref.cast_desc_eq "); } else { printMedium(o, "ref.cast "); } @@ -2257,9 +2257,9 @@ struct PrintExpressionContents curr->name.print(o); return; case BrOnCast: - case BrOnCastDesc: + case BrOnCastDescEq: case BrOnCastFail: - case BrOnCastDescFail: + case BrOnCastDescEqFail: switch (curr->op) { case BrOnCast: printMedium(o, "br_on_cast"); @@ -2267,11 +2267,11 @@ struct PrintExpressionContents case BrOnCastFail: printMedium(o, "br_on_cast_fail"); break; - case BrOnCastDesc: - printMedium(o, "br_on_cast_desc"); + case BrOnCastDescEq: + printMedium(o, "br_on_cast_desc_eq"); break; - case BrOnCastDescFail: - printMedium(o, "br_on_cast_desc_fail"); + case BrOnCastDescEqFail: + printMedium(o, "br_on_cast_desc_eq_fail"); break; default: WASM_UNREACHABLE("unexpected op"); @@ -2292,7 +2292,7 @@ struct PrintExpressionContents return; printMedium(o, curr->op == BrOnCastFail ? "br_on_cast_fail " - : "br_on_cast_desc_fail "); + : "br_on_cast_desc_eq_fail "); curr->name.print(o); o << ' '; if (curr->ref->type == Type::unreachable) { diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 455092ccb13..1a6d355ff5e 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -945,12 +945,12 @@ struct RemoveUnusedBrs : public WalkerPass> { return; case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: { + case BrOnCastDescEq: + case BrOnCastDescEqFail: { bool onFail = - curr->op == BrOnCastFail || curr->op == BrOnCastDescFail; + curr->op == BrOnCastFail || curr->op == BrOnCastDescEqFail; bool isDesc = - curr->op == BrOnCastDesc || curr->op == BrOnCastDescFail; + curr->op == BrOnCastDescEq || curr->op == BrOnCastDescEqFail; // Improve the cast target type as much as possible given what we // know about the input. Unlike in BrOn::finalize(), we consider diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 23667aeecbf..196baf80ff4 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -192,9 +192,10 @@ void PassRegistry::registerPasses() { "global-refining", "refine the types of globals", createGlobalRefiningPass); registerPass( "gsi", "globally optimize struct values", createGlobalStructInferencePass); - registerPass("gsi-desc-cast", - "globally optimize struct values, also emitting ref.cast_desc", - createGlobalStructInferenceDescCastPass); + registerPass( + "gsi-desc-cast", + "globally optimize struct values, also emitting ref.cast_desc_eq", + createGlobalStructInferenceDescCastPass); registerPass( "gto", "globally optimize GC types", createGlobalTypeOptimizationPass); registerPass("gufa", diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 5a1f618da3d..e2281d30850 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1183,12 +1183,12 @@ enum ASTNodes { RefTestNull = 0x15, RefCast = 0x16, RefCastNull = 0x17, - RefCastDesc = 0x23, - RefCastDescNull = 0x24, + RefCastDescEq = 0x23, + RefCastDescEqNull = 0x24, BrOnCast = 0x18, BrOnCastFail = 0x19, - BrOnCastDesc = 0x25, - BrOnCastDescFail = 0x26, + BrOnCastDescEq = 0x25, + BrOnCastDescEqFail = 0x26, AnyConvertExtern = 0x1a, ExternConvertAny = 0x1b, RefI31 = 0x1c, diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 104b8385ed9..649a6cb1806 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -957,8 +957,8 @@ class Builder { Expression* ref, Type castType = Type::none, Expression* desc = nullptr) { - assert((desc && (op == BrOnCastDesc || op == BrOnCastDescFail)) || - (!desc && op != BrOnCastDesc && op != BrOnCastDescFail)); + assert((desc && (op == BrOnCastDescEq || op == BrOnCastDescEqFail)) || + (!desc && op != BrOnCastDescEq && op != BrOnCastDescEqFail)); auto* ret = wasm.allocator.alloc(); ret->op = op; ret->name = name; diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 89b767af2aa..5340973fe0b 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -2098,13 +2098,13 @@ class ExpressionRunner : public OverriddenVisitor { switch (curr->op) { case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: { + case BrOnCastDescEq: + case BrOnCastDescEqFail: { auto cast = curr->desc ? doDescCast(curr) : doCast(curr); if (auto* breaking = cast.getBreaking()) { return *breaking; } else if (auto* original = cast.getFailure()) { - if (curr->op == BrOnCast || curr->op == BrOnCastDesc) { + if (curr->op == BrOnCast || curr->op == BrOnCastDescEq) { return *original; } else { return Flow(curr->name, *original); @@ -2112,7 +2112,7 @@ class ExpressionRunner : public OverriddenVisitor { } else { auto* result = cast.getSuccess(); assert(result); - if (curr->op == BrOnCast || curr->op == BrOnCastDesc) { + if (curr->op == BrOnCast || curr->op == BrOnCastDescEq) { return Flow(curr->name, *result); } else { return *result; diff --git a/src/wasm.h b/src/wasm.h index ab6323b5f35..5dd3e11e87e 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -609,8 +609,8 @@ enum BrOnOp { BrOnNonNull, BrOnCast, BrOnCastFail, - BrOnCastDesc, - BrOnCastDescFail, + BrOnCastDescEq, + BrOnCastDescEqFail, }; enum StringNewOp { @@ -1644,7 +1644,7 @@ class RefCast : public SpecificExpression { Expression* ref; - // Used only for ref.cast_desc. + // Used only for ref.cast_desc_eq. Expression* desc; void finalize(); @@ -1671,7 +1671,7 @@ class BrOn : public SpecificExpression { Name name; Expression* ref; - // Only used for br_on_cast_desc{,_fail} + // Only used for br_on_cast_desc_eq{,_fail} Expression* desc; // Only used for br_on_cast{,_desc}{,_fail} diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 96fd205f908..d780b62227e 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -4588,12 +4588,12 @@ Result<> WasmBinaryReader::readInst() { return builder.makeRefCast(Type(heapType, Nullable, exactness), false); } - case BinaryConsts::RefCastDesc: { + case BinaryConsts::RefCastDescEq: { auto [heapType, exactness] = getHeapType(); return builder.makeRefCast(Type(heapType, NonNullable, exactness), true); } - case BinaryConsts::RefCastDescNull: { + case BinaryConsts::RefCastDescEqNull: { auto [heapType, exactness] = getHeapType(); return builder.makeRefCast(Type(heapType, Nullable, exactness), true); } @@ -4603,8 +4603,8 @@ Result<> WasmBinaryReader::readInst() { } case BinaryConsts::BrOnCast: case BinaryConsts::BrOnCastFail: - case BinaryConsts::BrOnCastDesc: - case BinaryConsts::BrOnCastDescFail: { + case BinaryConsts::BrOnCastDescEq: + case BinaryConsts::BrOnCastDescEqFail: { auto flags = getInt8(); auto srcNull = (flags & BinaryConsts::BrOnCastFlag::InputNullable) ? Nullable @@ -4617,10 +4617,10 @@ Result<> WasmBinaryReader::readInst() { auto [dstType, dstExact] = getHeapType(); auto in = Type(srcType, srcNull, srcExact); auto cast = Type(dstType, dstNull, dstExact); - auto kind = op == BinaryConsts::BrOnCast ? BrOnCast - : op == BinaryConsts::BrOnCastFail ? BrOnCastFail - : op == BinaryConsts::BrOnCastDesc ? BrOnCastDesc - : BrOnCastDescFail; + auto kind = op == BinaryConsts::BrOnCast ? BrOnCast + : op == BinaryConsts::BrOnCastFail ? BrOnCastFail + : op == BinaryConsts::BrOnCastDescEq ? BrOnCastDescEq + : BrOnCastDescEqFail; return builder.makeBrOn(label, kind, in, cast); } case BinaryConsts::StructNew: diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index 57a2469dce0..1a4106adb73 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -1952,7 +1952,7 @@ Result<> IRBuilder::makeRefCast(Type type, bool isDesc) { RefCast curr; curr.type = type; - // Placeholder value to differentiate ref.cast_desc. + // Placeholder value to differentiate ref.cast_desc_eq. curr.desc = isDesc ? &curr : nullptr; CHECK_ERR(visitRefCast(&curr)); @@ -1979,7 +1979,7 @@ Result<> IRBuilder::makeRefGetDesc(HeapType type) { Result<> IRBuilder::makeBrOn( Index label, BrOnOp op, Type in, Type out, std::optional likely) { std::optional descriptor; - if (op == BrOnCastDesc || op == BrOnCastDescFail) { + if (op == BrOnCastDescEq || op == BrOnCastDescEqFail) { assert(out.isRef()); descriptor = out.getHeapType().getDescriptorType(); if (!descriptor) { @@ -1998,8 +1998,8 @@ Result<> IRBuilder::makeBrOn( case BrOnNull: case BrOnNonNull: break; - case BrOnCastDesc: - case BrOnCastDescFail: { + case BrOnCastDescEq: + case BrOnCastDescEqFail: { CHECK_ERR(validateTypeAnnotation(out.with(*descriptor).with(Nullable), curr.desc)); } @@ -2021,8 +2021,8 @@ Result<> IRBuilder::makeBrOn( case BrOnNonNull: case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: + case BrOnCastDescEq: + case BrOnCastDescEqFail: // Modeled as sending one value. if (extraArity == 0) { return Err{"br_on target does not expect a value"}; @@ -2042,8 +2042,8 @@ Result<> IRBuilder::makeBrOn( break; case BrOnCast: case BrOnCastFail: - case BrOnCastDesc: - case BrOnCastDescFail: + case BrOnCastDescEq: + case BrOnCastDescEqFail: testType = in; break; } @@ -2102,7 +2102,7 @@ Result<> IRBuilder::makeBrOn( case BrOnNonNull: WASM_UNREACHABLE("unexpected op"); case BrOnCast: - case BrOnCastDesc: + case BrOnCastDescEq: if (out.isNullable()) { resultType = Type(in.getHeapType(), NonNullable); } else { @@ -2110,7 +2110,7 @@ Result<> IRBuilder::makeBrOn( } break; case BrOnCastFail: - case BrOnCastDescFail: + case BrOnCastDescEqFail: if (in.isNonNullable()) { resultType = Type(out.getHeapType(), NonNullable); } else { diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index ce2d6c737fd..ac24040bdb5 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2348,13 +2348,13 @@ void BinaryInstWriter::visitRefCast(RefCast* curr) { o << int8_t(BinaryConsts::GCPrefix); if (curr->type.isNullable()) { if (curr->desc) { - o << U32LEB(BinaryConsts::RefCastDescNull); + o << U32LEB(BinaryConsts::RefCastDescEqNull); } else { o << U32LEB(BinaryConsts::RefCastNull); } } else { if (curr->desc) { - o << U32LEB(BinaryConsts::RefCastDesc); + o << U32LEB(BinaryConsts::RefCastDescEq); } else { o << U32LEB(BinaryConsts::RefCast); } @@ -2372,7 +2372,7 @@ void BinaryInstWriter::visitRefGetDesc(RefGetDesc* curr) { } void BinaryInstWriter::visitBrOn(BrOn* curr) { - bool hasDesc = curr->op == BrOnCastDesc || curr->op == BrOnCastDescFail; + bool hasDesc = curr->op == BrOnCastDescEq || curr->op == BrOnCastDescEqFail; if (hasDesc && curr->desc->type.isNull()) { emitUnreachable(); return; @@ -2392,12 +2392,13 @@ void BinaryInstWriter::visitBrOn(BrOn* curr) { case BrOnCastFail: o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::BrOnCastFail); break; - case BrOnCastDesc: - o << int8_t(BinaryConsts::GCPrefix) << U32LEB(BinaryConsts::BrOnCastDesc); + case BrOnCastDescEq: + o << int8_t(BinaryConsts::GCPrefix) + << U32LEB(BinaryConsts::BrOnCastDescEq); break; - case BrOnCastDescFail: + case BrOnCastDescEqFail: o << int8_t(BinaryConsts::GCPrefix) - << U32LEB(BinaryConsts::BrOnCastDescFail); + << U32LEB(BinaryConsts::BrOnCastDescEqFail); break; } assert(curr->ref->type.isRef()); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 4e79976579f..00e5b336bf2 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2976,7 +2976,7 @@ void FunctionValidator::visitRefCast(RefCast* curr) { descType.isRef() && descType.getHeapType().getDescribedType(); shouldBeTrue(isNull || isDescriptor, curr, - "ref.cast_desc descriptor must be a descriptor reference"); + "ref.cast_desc_eq descriptor must be a descriptor reference"); } if (curr->type == Type::unreachable) { @@ -3033,11 +3033,11 @@ void FunctionValidator::visitRefCast(RefCast* curr) { shouldBeTrue(getModule()->features.hasCustomDescriptors(), curr, - "ref.cast_desc requires custom descriptors " + "ref.cast_desc_eq requires custom descriptors " "[--enable-custom-descriptors]"); if (!shouldBeTrue(curr->desc && curr->desc->type.isRef(), curr, - "ref.cast_desc descriptor must have ref type")) { + "ref.cast_desc_eq descriptor must have ref type")) { return; } auto descriptor = curr->desc->type.getHeapType(); @@ -3050,12 +3050,12 @@ void FunctionValidator::visitRefCast(RefCast* curr) { shouldBeEqual(*described, curr->type.getHeapType(), curr, - "ref.cast_desc cast type should be described by descriptor"); + "ref.cast_desc_eq cast type should be described by descriptor"); shouldBeEqual( curr->type.getExactness(), curr->desc->type.getExactness(), curr, - "ref.cast_desc cast exactness should match descriptor exactness"); + "ref.cast_desc_eq cast exactness should match descriptor exactness"); } void FunctionValidator::visitRefGetDesc(RefGetDesc* curr) { @@ -3096,15 +3096,15 @@ void FunctionValidator::visitBrOn(BrOn* curr) { curr, "non-cast br_on* must not set castType field"); break; - case BrOnCastDesc: - case BrOnCastDescFail: { + case BrOnCastDescEq: + case BrOnCastDescEqFail: { shouldBeTrue(getModule()->features.hasCustomDescriptors(), curr, - "br_on_cast_desc* requires custom descriptors " + "br_on_cast_desc_eq* requires custom descriptors " "[--enable-custom-descriptors]"); if (!shouldBeTrue(curr->desc && curr->desc->type.isRef(), curr, - "br_on_cast_desc* descriptor must have ref type")) { + "br_on_cast_desc_eq* descriptor must have ref type")) { return; } auto descriptor = curr->desc->type.getHeapType(); @@ -3113,23 +3113,23 @@ void FunctionValidator::visitBrOn(BrOn* curr) { if (!shouldBeTrue( bool(described), curr, - "br_on_cast_desc* descriptor should have a described type")) { + "br_on_cast_desc_eq* descriptor should have a described type")) { return; } shouldBeEqual( *described, curr->castType.getHeapType(), curr, - "br_on_cast_desc* cast type should be described by descriptor"); - shouldBeEqual( - curr->castType.getExactness(), - curr->desc->type.getExactness(), - curr, - "br_on_cast_desc* cast exactness should match descriptor exactness"); + "br_on_cast_desc_eq* cast type should be described by descriptor"); + shouldBeEqual(curr->castType.getExactness(), + curr->desc->type.getExactness(), + curr, + "br_on_cast_desc_eq* cast exactness should match " + "descriptor exactness"); shouldBeTrue(curr->ref->type.isNullable() || curr->castType.isNonNullable(), curr, - "br_on_cast_desc* with non-nullable ref should have " + "br_on_cast_desc_eq* with non-nullable ref should have " "non-nullable cast type"); } break; diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 447847c18d7..ca20231aabd 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1128,7 +1128,7 @@ void BrOn::finalize() { // Descriptors that the cast type is a subtype of the input type. castType = Type::getGreatestLowerBound(castType, ref->type); assert(castType.isRef()); - } else if (op == BrOnCastDesc || op == BrOnCastDescFail) { + } else if (op == BrOnCastDescEq || op == BrOnCastDescEqFail) { if (desc->type.isNull()) { // Cast will never be executed and the instruction will not be emitted. // Model this with an uninhabitable cast type. @@ -1157,7 +1157,7 @@ void BrOn::finalize() { type = Type::none; return; case BrOnCast: - case BrOnCastDesc: + case BrOnCastDescEq: if (castType.isNullable()) { // Nulls take the branch, so the result is non-nullable. type = ref->type.with(NonNullable); @@ -1168,7 +1168,7 @@ void BrOn::finalize() { } return; case BrOnCastFail: - case BrOnCastDescFail: + case BrOnCastDescEqFail: if (castType.isNullable()) { // Nulls do not take the branch, so the result is non-nullable only if // the input is. @@ -1196,7 +1196,7 @@ Type BrOn::getSentType() { // BrOnNonNull sends the non-nullable type on the branch. return ref->type.with(NonNullable); case BrOnCast: - case BrOnCastDesc: + case BrOnCastDescEq: // The same as the result type of br_on_cast_fail. if (castType.isNullable()) { return castType.with(ref->type.getNullability()); @@ -1204,7 +1204,7 @@ Type BrOn::getSentType() { return castType; } case BrOnCastFail: - case BrOnCastDescFail: + case BrOnCastDescEqFail: // The same as the result type of br_on_cast (if reachable). if (ref->type == Type::unreachable) { return Type::unreachable; diff --git a/test/gtest/validator.cpp b/test/gtest/validator.cpp index ec7caa295d1..e984945226c 100644 --- a/test/gtest/validator.cpp +++ b/test/gtest/validator.cpp @@ -67,10 +67,10 @@ TEST(ValidatorTest, ReturnUnreachable) { EXPECT_FALSE(WasmValidator{}.validate(func.get(), module, flags)); } -TEST(ValidatorTest, UnreachableCastDesc) { - // The parser will error trying to parse a ref.cast_desc with a non-matching - // descriptor type, so we must construct the IR directly to test the - // validator. +TEST(ValidatorTest, UnreachableCastDescEq) { + // The parser will error trying to parse a ref.cast_desc_eq with a + // non-matching descriptor type, so we must construct the IR directly to test + // the validator. Module module; module.features = FeatureSet::All; Builder builder(module); diff --git a/test/lit/basic/custom-descriptors.wast b/test/lit/basic/custom-descriptors.wast index bead48f6920..c9eb8cd01e5 100644 --- a/test/lit/basic/custom-descriptors.wast +++ b/test/lit/basic/custom-descriptors.wast @@ -175,11 +175,11 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc (type $7) (param $any anyref) (param $descriptor (ref null $describing)) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq (type $7) (param $any anyref) (param $descriptor (ref null $describing)) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result (ref null $middle)) ;; CHECK-TEXT-NEXT: (drop - ;; CHECK-TEXT-NEXT: (br_on_cast_desc $l anyref (ref null $middle) + ;; CHECK-TEXT-NEXT: (br_on_cast_desc_eq $l anyref (ref null $middle) ;; CHECK-TEXT-NEXT: (local.get $any) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) @@ -188,11 +188,11 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc (type $7) (param $any anyref) (param $descriptor (ref null $describing)) + ;; CHECK-BIN: (func $br-on-cast-desc-eq (type $7) (param $any anyref) (param $descriptor (ref null $describing)) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block $block (result (ref null $middle)) ;; CHECK-BIN-NEXT: (drop - ;; CHECK-BIN-NEXT: (br_on_cast_desc $block anyref (ref null $middle) + ;; CHECK-BIN-NEXT: (br_on_cast_desc_eq $block anyref (ref null $middle) ;; CHECK-BIN-NEXT: (local.get $any) ;; CHECK-BIN-NEXT: (local.get $descriptor) ;; CHECK-BIN-NEXT: ) @@ -201,10 +201,10 @@ ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc (param $any anyref) (param $descriptor (ref null $describing)) + (func $br-on-cast-desc-eq (param $any anyref) (param $descriptor (ref null $describing)) (drop (block $l (result (ref null $middle)) - (br_on_cast_desc $l anyref (ref null $middle) + (br_on_cast_desc_eq $l anyref (ref null $middle) (local.get $any) (local.get $descriptor) ) @@ -213,30 +213,30 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-fail (type $7) (param $any anyref) (param $descriptor (ref null $describing)) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-fail (type $7) (param $any anyref) (param $descriptor (ref null $describing)) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result anyref) - ;; CHECK-TEXT-NEXT: (br_on_cast_desc_fail $l anyref (ref null $middle) + ;; CHECK-TEXT-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref null $middle) ;; CHECK-TEXT-NEXT: (local.get $any) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-fail (type $7) (param $any anyref) (param $descriptor (ref null $describing)) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-fail (type $7) (param $any anyref) (param $descriptor (ref null $describing)) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block $block (result anyref) - ;; CHECK-BIN-NEXT: (br_on_cast_desc_fail $block anyref (ref null $middle) + ;; CHECK-BIN-NEXT: (br_on_cast_desc_eq_fail $block anyref (ref null $middle) ;; CHECK-BIN-NEXT: (local.get $any) ;; CHECK-BIN-NEXT: (local.get $descriptor) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-fail (param $any anyref) (param $descriptor (ref null $describing)) + (func $br-on-cast-desc-eq-fail (param $any anyref) (param $descriptor (ref null $describing)) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $middle) + (br_on_cast_desc_eq_fail $l anyref (ref null $middle) (local.get $any) (local.get $descriptor) ) @@ -244,7 +244,7 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-unreachable (type $6) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-unreachable (type $6) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result (ref null $middle)) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable BrOn we can't emit) @@ -260,17 +260,17 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-unreachable (type $6) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-unreachable (type $6) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block (result (ref null $middle)) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-unreachable + (func $br-on-cast-desc-eq-unreachable (drop (block $l (result (ref null $middle)) - (br_on_cast_desc $l anyref (ref null $middle) + (br_on_cast_desc_eq $l anyref (ref null $middle) (unreachable) ) (unreachable) @@ -278,7 +278,7 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-fail-unreachable (type $6) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-fail-unreachable (type $6) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result (ref null $middle)) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable BrOn we can't emit) @@ -294,17 +294,17 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-fail-unreachable (type $6) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-fail-unreachable (type $6) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block (result (ref null $middle)) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-fail-unreachable + (func $br-on-cast-desc-eq-fail-unreachable (drop (block $l (result (ref null $middle)) - (br_on_cast_desc_fail $l anyref (ref null $middle) + (br_on_cast_desc_eq_fail $l anyref (ref null $middle) (unreachable) ) (unreachable) @@ -312,10 +312,10 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-unreachable-desc (type $8) (param $descriptor (ref null $describing)) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-unreachable-desc (type $8) (param $descriptor (ref null $describing)) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result (ref null $middle)) - ;; CHECK-TEXT-NEXT: (br_on_cast_desc $l (ref null $middle) (ref null $middle) + ;; CHECK-TEXT-NEXT: (br_on_cast_desc_eq $l (ref null $middle) (ref null $middle) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) @@ -323,17 +323,17 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-unreachable-desc (type $8) (param $descriptor (ref null $describing)) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-unreachable-desc (type $8) (param $descriptor (ref null $describing)) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block (result (ref null $middle)) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-unreachable-desc (param $descriptor (ref null $describing)) + (func $br-on-cast-desc-eq-unreachable-desc (param $descriptor (ref null $describing)) (drop (block $l (result (ref null $middle)) - (br_on_cast_desc $l anyref (ref null $middle) + (br_on_cast_desc_eq $l anyref (ref null $middle) (unreachable) (local.get $descriptor) ) @@ -342,10 +342,10 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-fail-unreachable-desc (type $8) (param $descriptor (ref null $describing)) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-fail-unreachable-desc (type $8) (param $descriptor (ref null $describing)) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (block $l (result (ref null $middle)) - ;; CHECK-TEXT-NEXT: (br_on_cast_desc_fail $l (ref null $middle) (ref null $middle) + ;; CHECK-TEXT-NEXT: (br_on_cast_desc_eq_fail $l (ref null $middle) (ref null $middle) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) @@ -353,17 +353,17 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-fail-unreachable-desc (type $8) (param $descriptor (ref null $describing)) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-fail-unreachable-desc (type $8) (param $descriptor (ref null $describing)) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (block (result (ref null $middle)) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-fail-unreachable-desc (param $descriptor (ref null $describing)) + (func $br-on-cast-desc-eq-fail-unreachable-desc (param $descriptor (ref null $describing)) (drop (block $l (result (ref null $middle)) - (br_on_cast_desc_fail $l anyref (ref null $middle) + (br_on_cast_desc_eq_fail $l anyref (ref null $middle) (unreachable) (local.get $descriptor) ) @@ -372,7 +372,7 @@ ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-TEXT-NEXT: (block $label (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable BrOn we can't emit) ;; CHECK-TEXT-NEXT: (drop @@ -385,7 +385,7 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (ref.null none) ;; CHECK-BIN-NEXT: ) @@ -394,14 +394,14 @@ ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-null (param anyref) (result anyref) - (br_on_cast_desc 0 anyref (ref null $described) + (func $br-on-cast-desc-eq-null (param anyref) (result anyref) + (br_on_cast_desc_eq 0 anyref (ref null $described) (ref.null none) (ref.null none) ) ) - ;; CHECK-TEXT: (func $br-on-cast-desc-fail-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-TEXT: (func $br-on-cast-desc-eq-fail-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-TEXT-NEXT: (block $label (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable BrOn we can't emit) ;; CHECK-TEXT-NEXT: (drop @@ -414,7 +414,7 @@ ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $br-on-cast-desc-fail-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-BIN: (func $br-on-cast-desc-eq-fail-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (ref.null none) ;; CHECK-BIN-NEXT: ) @@ -423,14 +423,14 @@ ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $br-on-cast-desc-fail-null (param anyref) (result anyref) - (br_on_cast_desc_fail 0 anyref (ref null $described) + (func $br-on-cast-desc-eq-fail-null (param anyref) (result anyref) + (br_on_cast_desc_eq_fail 0 anyref (ref null $described) (ref.null none) (ref.null none) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-null-unreachable (type $9) (result anyref) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-null-unreachable (type $9) (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (unreachable) @@ -441,79 +441,79 @@ ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-null-unreachable (type $9) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-null-unreachable (type $9) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-null-unreachable (result anyref) + (func $ref-cast-desc-eq-null-unreachable (result anyref) (unreachable) - (ref.cast_desc (ref null $described)) + (ref.cast_desc_eq (ref null $described)) ) - ;; CHECK-TEXT: (func $ref-cast-desc-null-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref $described) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-null-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref $described) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-null-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-null-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-null-unreachable-ref (param $descriptor (ref null $middle)) (result anyref) - (ref.cast_desc (ref null $described) + (func $ref-cast-desc-eq-null-unreachable-ref (param $descriptor (ref null $middle)) (result anyref) + (ref.cast_desc_eq (ref null $described) (unreachable) (local.get $descriptor) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref $described) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref $described) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-unreachable-ref (type $10) (param $descriptor (ref null $middle)) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-unreachable-ref (param $descriptor (ref null $middle)) (result anyref) - (ref.cast_desc (ref $described) + (func $ref-cast-desc-eq-unreachable-ref (param $descriptor (ref null $middle)) (result anyref) + (ref.cast_desc_eq (ref $described) (unreachable) (local.get $descriptor) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-exact-null-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref (exact $described)) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-exact-null-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref (exact $described)) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-exact-null-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-exact-null-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-exact-null-unreachable-ref (param $descriptor (ref null (exact $middle))) (result anyref) - (ref.cast_desc (ref null (exact $described)) + (func $ref-cast-desc-eq-exact-null-unreachable-ref (param $descriptor (ref null (exact $middle))) (result anyref) + (ref.cast_desc_eq (ref null (exact $described)) (unreachable) (local.get $descriptor) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-exact-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref (exact $described)) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-exact-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref (exact $described)) ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: (local.get $descriptor) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-exact-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-exact-unreachable-ref (type $11) (param $descriptor (ref null (exact $middle))) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-exact-unreachable-ref (param $descriptor (ref null (exact $middle))) (result anyref) - (ref.cast_desc (ref (exact $described)) + (func $ref-cast-desc-eq-exact-unreachable-ref (param $descriptor (ref null (exact $middle))) (result anyref) + (ref.cast_desc_eq (ref (exact $described)) (unreachable) (local.get $descriptor) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-null-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-null-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (ref.null none) @@ -524,7 +524,7 @@ ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-null-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-null-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (ref.null none) ;; CHECK-BIN-NEXT: ) @@ -533,34 +533,34 @@ ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-null-null (param anyref) (result anyref) - (ref.cast_desc (ref null $described) + (func $ref-cast-desc-eq-null-null (param anyref) (result anyref) + (ref.cast_desc_eq (ref null $described) (ref.null none) (ref.null none) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-null-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref null (exact $described)) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-null-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref null (exact $described)) ;; CHECK-TEXT-NEXT: (local.get $any) ;; CHECK-TEXT-NEXT: (local.get $middle) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-null-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) - ;; CHECK-BIN-NEXT: (ref.cast_desc (ref null (exact $described)) + ;; CHECK-BIN: (func $ref-cast-desc-eq-null-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + ;; CHECK-BIN-NEXT: (ref.cast_desc_eq (ref null (exact $described)) ;; CHECK-BIN-NEXT: (local.get $any) ;; CHECK-BIN-NEXT: (local.get $middle) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-null-exact (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + (func $ref-cast-desc-eq-null-exact (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) ;; The cast type is exact because the descriptor is exact. - (ref.cast_desc (ref null (exact $described)) + (ref.cast_desc_eq (ref null (exact $described)) (local.get $any) (local.get $middle) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-nn-unreachable (type $9) (result anyref) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-nn-unreachable (type $9) (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (unreachable) @@ -571,15 +571,15 @@ ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-nn-unreachable (type $9) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-nn-unreachable (type $9) (result anyref) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-nn-unreachable (result anyref) + (func $ref-cast-desc-eq-nn-unreachable (result anyref) (unreachable) - (ref.cast_desc (ref $described)) + (ref.cast_desc_eq (ref $described)) ) - ;; CHECK-TEXT: (func $ref-cast-desc-nn-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-nn-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-TEXT-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; CHECK-TEXT-NEXT: (drop ;; CHECK-TEXT-NEXT: (ref.null none) @@ -590,7 +590,7 @@ ;; CHECK-TEXT-NEXT: (unreachable) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-nn-null (type $3) (param $0 anyref) (result anyref) + ;; CHECK-BIN: (func $ref-cast-desc-eq-nn-null (type $3) (param $0 anyref) (result anyref) ;; CHECK-BIN-NEXT: (drop ;; CHECK-BIN-NEXT: (ref.null none) ;; CHECK-BIN-NEXT: ) @@ -599,47 +599,47 @@ ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: (unreachable) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-nn-null (param anyref) (result anyref) - (ref.cast_desc (ref $described) + (func $ref-cast-desc-eq-nn-null (param anyref) (result anyref) + (ref.cast_desc_eq (ref $described) (ref.null none) (ref.null none) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-nn-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref (exact $described)) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-nn-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref (exact $described)) ;; CHECK-TEXT-NEXT: (local.get $any) ;; CHECK-TEXT-NEXT: (local.get $middle) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-nn-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) - ;; CHECK-BIN-NEXT: (ref.cast_desc (ref (exact $described)) + ;; CHECK-BIN: (func $ref-cast-desc-eq-nn-exact (type $12) (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + ;; CHECK-BIN-NEXT: (ref.cast_desc_eq (ref (exact $described)) ;; CHECK-BIN-NEXT: (local.get $any) ;; CHECK-BIN-NEXT: (local.get $middle) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-nn-exact (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) + (func $ref-cast-desc-eq-nn-exact (param $any anyref) (param $middle (ref null (exact $middle))) (result (ref null (exact $described))) ;; The cast type is exact because the descriptor is exact. - (ref.cast_desc (ref (exact $described)) + (ref.cast_desc_eq (ref (exact $described)) (local.get $any) (local.get $middle) ) ) - ;; CHECK-TEXT: (func $ref-cast-desc-nn-to-null (type $17) (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) - ;; CHECK-TEXT-NEXT: (ref.cast_desc (ref $described) + ;; CHECK-TEXT: (func $ref-cast-desc-eq-nn-to-null (type $17) (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) + ;; CHECK-TEXT-NEXT: (ref.cast_desc_eq (ref $described) ;; CHECK-TEXT-NEXT: (local.get $any-nn) ;; CHECK-TEXT-NEXT: (local.get $middle) ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT-NEXT: ) - ;; CHECK-BIN: (func $ref-cast-desc-nn-to-null (type $17) (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) - ;; CHECK-BIN-NEXT: (ref.cast_desc (ref $described) + ;; CHECK-BIN: (func $ref-cast-desc-eq-nn-to-null (type $17) (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) + ;; CHECK-BIN-NEXT: (ref.cast_desc_eq (ref $described) ;; CHECK-BIN-NEXT: (local.get $any-nn) ;; CHECK-BIN-NEXT: (local.get $middle) ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN-NEXT: ) - (func $ref-cast-desc-nn-to-null (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) - (ref.cast_desc (ref null $described) + (func $ref-cast-desc-eq-nn-to-null (param $any-nn (ref any)) (param $middle (ref null $middle)) (result (ref null $described)) + (ref.cast_desc_eq (ref null $described) (local.get $any-nn) (local.get $middle) ) @@ -757,7 +757,7 @@ ;; CHECK-BIN-NODEBUG-NEXT: (drop ;; CHECK-BIN-NODEBUG-NEXT: (block $block (result (ref null $1)) ;; CHECK-BIN-NODEBUG-NEXT: (drop -;; CHECK-BIN-NODEBUG-NEXT: (br_on_cast_desc $block anyref (ref null $1) +;; CHECK-BIN-NODEBUG-NEXT: (br_on_cast_desc_eq $block anyref (ref null $1) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $1) ;; CHECK-BIN-NODEBUG-NEXT: ) @@ -770,7 +770,7 @@ ;; CHECK-BIN-NODEBUG: (func $3 (type $7) (param $0 anyref) (param $1 (ref null $2)) ;; CHECK-BIN-NODEBUG-NEXT: (drop ;; CHECK-BIN-NODEBUG-NEXT: (block $block (result anyref) -;; CHECK-BIN-NODEBUG-NEXT: (br_on_cast_desc_fail $block anyref (ref null $1) +;; CHECK-BIN-NODEBUG-NEXT: (br_on_cast_desc_eq_fail $block anyref (ref null $1) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $1) ;; CHECK-BIN-NODEBUG-NEXT: ) @@ -861,7 +861,7 @@ ;; CHECK-BIN-NODEBUG-NEXT: ) ;; CHECK-BIN-NODEBUG: (func $16 (type $12) (param $0 anyref) (param $1 (ref null (exact $1))) (result (ref null (exact $0))) -;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc (ref null (exact $0)) +;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc_eq (ref null (exact $0)) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $1) ;; CHECK-BIN-NODEBUG-NEXT: ) @@ -882,14 +882,14 @@ ;; CHECK-BIN-NODEBUG-NEXT: ) ;; CHECK-BIN-NODEBUG: (func $19 (type $12) (param $0 anyref) (param $1 (ref null (exact $1))) (result (ref null (exact $0))) -;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc (ref (exact $0)) +;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc_eq (ref (exact $0)) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $1) ;; CHECK-BIN-NODEBUG-NEXT: ) ;; CHECK-BIN-NODEBUG-NEXT: ) ;; CHECK-BIN-NODEBUG: (func $20 (type $17) (param $0 (ref any)) (param $1 (ref null $1)) (result (ref null $0)) -;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc (ref $0) +;; CHECK-BIN-NODEBUG-NEXT: (ref.cast_desc_eq (ref $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $0) ;; CHECK-BIN-NODEBUG-NEXT: (local.get $1) ;; CHECK-BIN-NODEBUG-NEXT: ) diff --git a/test/lit/help/wasm-metadce.test b/test/lit/help/wasm-metadce.test index 41a285e9afb..98785fda862 100644 --- a/test/lit/help/wasm-metadce.test +++ b/test/lit/help/wasm-metadce.test @@ -179,7 +179,7 @@ ;; CHECK-NEXT: --gsi globally optimize struct values ;; CHECK-NEXT: ;; CHECK-NEXT: --gsi-desc-cast globally optimize struct values, -;; CHECK-NEXT: also emitting ref.cast_desc +;; CHECK-NEXT: also emitting ref.cast_desc_eq ;; CHECK-NEXT: ;; CHECK-NEXT: --gto globally optimize GC types ;; CHECK-NEXT: diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test index 5c08240c37a..4c0f4f67047 100644 --- a/test/lit/help/wasm-opt.test +++ b/test/lit/help/wasm-opt.test @@ -211,7 +211,7 @@ ;; CHECK-NEXT: --gsi globally optimize struct values ;; CHECK-NEXT: ;; CHECK-NEXT: --gsi-desc-cast globally optimize struct values, -;; CHECK-NEXT: also emitting ref.cast_desc +;; CHECK-NEXT: also emitting ref.cast_desc_eq ;; CHECK-NEXT: ;; CHECK-NEXT: --gto globally optimize GC types ;; CHECK-NEXT: diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index a7997e36f12..3c201f79ac4 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -143,7 +143,7 @@ ;; CHECK-NEXT: --gsi globally optimize struct values ;; CHECK-NEXT: ;; CHECK-NEXT: --gsi-desc-cast globally optimize struct values, -;; CHECK-NEXT: also emitting ref.cast_desc +;; CHECK-NEXT: also emitting ref.cast_desc_eq ;; CHECK-NEXT: ;; CHECK-NEXT: --gto globally optimize GC types ;; CHECK-NEXT: diff --git a/test/lit/passes/abstract-type-refining-desc.wast b/test/lit/passes/abstract-type-refining-desc.wast index 99b883b56e3..ae1b6de079a 100644 --- a/test/lit/passes/abstract-type-refining-desc.wast +++ b/test/lit/passes/abstract-type-refining-desc.wast @@ -126,7 +126,7 @@ ;; optimize out this cast because otherwise ReFinalization would make its ;; result (ref $struct) again and it would not be valid for the optimized ;; function result type. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -174,7 +174,7 @@ ;; NO_TNH-NEXT: ) (func $cast-nullable-effect (param $ref anyref) (param $desc (ref null $desc)) (result (ref null $struct)) ;; Same, but with side effects we cannot drop. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result anyref) (call $effect) (local.get $ref) @@ -204,7 +204,7 @@ ;; NO_TNH-NEXT: ) (func $cast-non-nullable (param $ref anyref) (param $desc (ref null $desc)) (result (ref null $struct)) ;; Same, but now the cast does not admit null. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (local.get $ref) (local.get $desc) ) @@ -222,7 +222,7 @@ ;; NO_TNH-NEXT: ) (func $cast-non-nullable-desc (param $ref anyref) (param $desc (ref $desc)) (result (ref null $struct)) ;; Same, but now the descriptor is additionally non-null. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (local.get $ref) (local.get $desc) ) @@ -268,7 +268,7 @@ ;; NO_TNH-NEXT: ) (func $cast-non-nullable-effect (param $ref anyref) (param $desc (ref $desc)) (result (ref null $struct)) ;; Same, but with side effects we cannot drop. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (block (result anyref) (call $effect) (local.get $ref) @@ -313,8 +313,8 @@ (func $branch-nullable (param $ref anyref) (param $desc (ref null $desc)) (result (ref null $struct)) (block $block (result (ref null $struct)) (drop - ;; Same, but with br_on_cast_desc. - (br_on_cast_desc $block anyref (ref null $struct) + ;; Same, but with br_on_cast_desc_eq. + (br_on_cast_desc_eq $block anyref (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -381,7 +381,7 @@ (block $block (result (ref null $struct)) (drop ;; Same, but with effects we cannot drop. - (br_on_cast_desc $block anyref (ref null $struct) + (br_on_cast_desc_eq $block anyref (ref null $struct) (block (result anyref) (call $effect) (local.get $ref) @@ -430,7 +430,7 @@ (block $block (result (ref null $struct)) (drop ;; Same, but now the cast does not admit nulls. - (br_on_cast_desc $block anyref (ref $struct) + (br_on_cast_desc_eq $block anyref (ref $struct) (local.get $ref) (local.get $desc) ) @@ -467,7 +467,7 @@ (block $block (result (ref null $struct)) (drop ;; Same, but now the descriptor is additionally non-null. - (br_on_cast_desc $block anyref (ref $struct) + (br_on_cast_desc_eq $block anyref (ref $struct) (local.get $ref) (local.get $desc) ) @@ -532,7 +532,7 @@ (block $block (result (ref null $struct)) (drop ;; Same, but with effects we cannot drop. - (br_on_cast_desc $block anyref (ref $struct) + (br_on_cast_desc_eq $block anyref (ref $struct) (block (result anyref) (call $effect) (local.get $ref) @@ -585,8 +585,8 @@ (drop (block $block (result anyref) (return - ;; Same, but with br_on_cast_desc_fail. - (br_on_cast_desc_fail $block anyref (ref null $struct) + ;; Same, but with br_on_cast_desc_eq_fail. + (br_on_cast_desc_eq_fail $block anyref (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -659,7 +659,7 @@ (block $block (result anyref) (return ;; Same, but with effects. - (br_on_cast_desc_fail $block anyref (ref null $struct) + (br_on_cast_desc_eq_fail $block anyref (ref null $struct) (block (result anyref) (call $effect) (local.get $ref) @@ -714,7 +714,7 @@ (block $block (result anyref) (return ;; Same, but now without admitting null. - (br_on_cast_desc_fail $block anyref (ref $struct) + (br_on_cast_desc_eq_fail $block anyref (ref $struct) (local.get $ref) (local.get $desc) ) @@ -757,7 +757,7 @@ (block $block (result anyref) (return ;; Same, but now the descriptor is additionally non-null. - (br_on_cast_desc_fail $block anyref (ref $struct) + (br_on_cast_desc_eq_fail $block anyref (ref $struct) (local.get $ref) (local.get $desc) ) @@ -828,7 +828,7 @@ (block $block (result anyref) (return ;; Same, but with effects. - (br_on_cast_desc_fail $block anyref (ref $struct) + (br_on_cast_desc_eq_fail $block anyref (ref $struct) (block (result anyref) (call $effect) (local.get $ref) diff --git a/test/lit/passes/abstract-type-refining-tnh-exact-casts.wast b/test/lit/passes/abstract-type-refining-tnh-exact-casts.wast index b96140862d1..a5e1cb63e60 100644 --- a/test/lit/passes/abstract-type-refining-tnh-exact-casts.wast +++ b/test/lit/passes/abstract-type-refining-tnh-exact-casts.wast @@ -95,23 +95,23 @@ ) ) - ;; CHECK: (func $ref-cast-desc (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $ref-cast-desc-eq (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (ref.cast (ref none) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref-cast-desc (param $ref anyref) (result anyref) + (func $ref-cast-desc-eq (param $ref anyref) (result anyref) ;; Unlike the normal casts, it would not be safe to update the target of a ;; descriptor cast because it is determined by the descriptor operand and ;; changing it would be invalid. But we optimize to a bottom cast anyway, so ;; there is no problem. - (ref.cast_desc (ref (exact $uninstantiated)) + (ref.cast_desc_eq (ref (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) ) - ;; CHECK: (func $ref-cast-desc-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $ref-cast-desc-eq-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (local.set $1 @@ -130,9 +130,9 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref-cast-desc-effect (param $ref anyref) (result anyref) + (func $ref-cast-desc-eq-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. - (ref.cast_desc (ref (exact $uninstantiated)) + (ref.cast_desc_eq (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -144,20 +144,20 @@ ) ) - ;; CHECK: (func $ref-cast-desc-null (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $ref-cast-desc-eq-null (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (ref.cast nullref ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref-cast-desc-null (param $ref anyref) (result anyref) + (func $ref-cast-desc-eq-null (param $ref anyref) (result anyref) ;; If the descriptor cast admits null, we optimize it to a null check. - (ref.cast_desc (ref null (exact $uninstantiated)) + (ref.cast_desc_eq (ref null (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) ) - ;; CHECK: (func $ref-cast-desc-null-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $ref-cast-desc-eq-null-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (local.set $1 @@ -176,9 +176,9 @@ ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref-cast-desc-null-effect (param $ref anyref) (result anyref) + (func $ref-cast-desc-eq-null-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. - (ref.cast_desc (ref null (exact $uninstantiated)) + (ref.cast_desc_eq (ref null (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -198,7 +198,7 @@ (func $ref-cast-nullable-desc (param $ref anyref) (result anyref) ;; Now the descriptor is nullable, but we assume traps never happen, so ;; we don't need to add a null check on it. - (ref.cast_desc (ref (exact $uninstantiated)) + (ref.cast_desc_eq (ref (exact $uninstantiated)) (local.get $ref) (global.get $nullable-desc) @@ -226,7 +226,7 @@ ;; CHECK-NEXT: ) (func $ref-cast-nullable-desc-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. - (ref.cast_desc (ref (exact $uninstantiated)) + (ref.cast_desc_eq (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -318,7 +318,7 @@ ) ) - ;; CHECK: (func $br-on-cast-desc (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (br_on_cast $l anyref (ref none) @@ -327,18 +327,18 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq (param $ref anyref) (result anyref) (block $l (result anyref) ;; As with normal br_on_cast, we know this cast will never succeed, so we ;; optimize the branch target to be uninhabitable. - (br_on_cast_desc $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) ) ) - ;; CHECK: (func $br-on-cast-desc-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (block $l (result anyref) @@ -361,10 +361,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-effect (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. (block $l (result anyref) - (br_on_cast_desc $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -377,7 +377,7 @@ ) ) - ;; CHECK: (func $br-on-cast-desc-null (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-null (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (block (result (ref any)) ;; CHECK-NEXT: (br_on_cast $l anyref nullref @@ -386,18 +386,18 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-null (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-null (param $ref anyref) (result anyref) (block $l (result anyref) ;; Same, but now the cast admits nulls, so we must optimize it to a null ;; check. - (br_on_cast_desc $l anyref (ref null (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref null (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) ) ) - ;; CHECK: (func $br-on-cast-desc-null-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-null-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (block $l (result anyref) @@ -420,10 +420,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-null-effect (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-null-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref null (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -449,7 +449,7 @@ (block $l (result anyref) ;; Now the descriptor is nullable, but we assume traps never happen, so ;; we don't need to add a null check on it. - (br_on_cast_desc $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref (exact $uninstantiated)) (local.get $ref) (global.get $nullable-desc) ) @@ -482,7 +482,7 @@ (func $br-on-cast-nullable-desc-effect (param $ref anyref) (result anyref) (block $l (result anyref) ;; Same, but with side effects we cannot drop. - (br_on_cast_desc $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq $l anyref (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -571,7 +571,7 @@ ) ) - ;; CHECK: (func $br-on-cast-desc-fail (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-fail (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (block (result (ref none)) ;; CHECK-NEXT: (br_on_cast_fail $l anyref (ref none) @@ -580,17 +580,17 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-fail (param $ref anyref) (result anyref) (block $l (result anyref) ;; Now we know the cast will always be taken. - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) ) ) - ;; CHECK: (func $br-on-cast-desc-fail-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-fail-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (block $l (result anyref) @@ -613,10 +613,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail-effect (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-fail-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -629,7 +629,7 @@ ) ) - ;; CHECK: (func $br-on-cast-desc-fail-null (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-fail-null (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (br_on_cast_fail $l anyref nullref @@ -638,10 +638,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail-null (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-fail-null (param $ref anyref) (result anyref) (block $l (result anyref) ;; Now we know the cast will always be taken, except on nulls. - (br_on_cast_desc_fail $l anyref (ref null (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref null (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) @@ -649,7 +649,7 @@ ) - ;; CHECK: (func $br-on-cast-desc-fail-null-effect (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-fail-null-effect (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local $2 (ref (exact $uninstantiated.desc))) ;; CHECK-NEXT: (block $l (result anyref) @@ -672,10 +672,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail-null-effect (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-fail-null-effect (param $ref anyref) (result anyref) ;; Same, but with side effects we cannot drop. (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref null (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -701,7 +701,7 @@ (block $l (result anyref) ;; Now the descriptor is nullable, but we assume traps never happen, so ;; we don't need to add a null check on it. - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) (local.get $ref) (global.get $nullable-desc) ) @@ -734,7 +734,7 @@ (func $br-on-cast-nullable-desc-fail-effect (param $ref anyref) (result anyref) (block $l (result anyref) ;; Same, but with side effects we cannot drop. - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) (block (result anyref) (call $effect) (local.get $ref) @@ -747,7 +747,7 @@ ) ) - ;; CHECK: (func $br-on-cast-desc-fail-squared (type $3) (param $ref anyref) (result anyref) + ;; CHECK: (func $br-on-cast-desc-eq-fail-squared (type $3) (param $ref anyref) (result anyref) ;; CHECK-NEXT: (local $1 (ref none)) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (block (result (ref none)) @@ -764,13 +764,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail-squared (param $ref anyref) (result anyref) + (func $br-on-cast-desc-eq-fail-squared (param $ref anyref) (result anyref) (block $l (result anyref) - ;; We should update the type of the inner br_on_cast_desc_fail after + ;; We should update the type of the inner br_on_cast_desc_eq_fail after ;; optimizing it so that the local produced when optimizing the outer - ;; br_on_cast_desc_fail has the more refined type. - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) - (br_on_cast_desc_fail $l anyref (ref (exact $uninstantiated)) + ;; br_on_cast_desc_eq_fail has the more refined type. + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) + (br_on_cast_desc_eq_fail $l anyref (ref (exact $uninstantiated)) (local.get $ref) (struct.new $uninstantiated.desc) ) diff --git a/test/lit/passes/gsi-to-desc-cast.wast b/test/lit/passes/gsi-to-desc-cast.wast index 571bbec26e6..7d1d354b9b2 100644 --- a/test/lit/passes/gsi-to-desc-cast.wast +++ b/test/lit/passes/gsi-to-desc-cast.wast @@ -56,7 +56,7 @@ ;; DESCC-NEXT: ) ;; DESCC-NEXT: ) ;; DESCC-NEXT: (drop - ;; DESCC-NEXT: (ref.cast_desc (ref $B) + ;; DESCC-NEXT: (ref.cast_desc_eq (ref $B) ;; DESCC-NEXT: (local.get $any) ;; DESCC-NEXT: (global.get $B.desc) ;; DESCC-NEXT: ) @@ -64,7 +64,7 @@ ;; DESCC-NEXT: ) (func $test (param $any anyref) ;; The second cast here is optimizable: it can only be to a single type with - ;; no subtypes, so we can use ref.cast_desc. + ;; no subtypes, so we can use ref.cast_desc_eq. (drop (ref.cast (ref $A) (local.get $any) @@ -96,7 +96,7 @@ ;; DESCC-NEXT: ) ;; DESCC-NEXT: ) ;; DESCC-NEXT: (drop - ;; DESCC-NEXT: (ref.cast_desc (ref $B) + ;; DESCC-NEXT: (ref.cast_desc_eq (ref $B) ;; DESCC-NEXT: (local.get $any) ;; DESCC-NEXT: (global.get $B.desc) ;; DESCC-NEXT: ) @@ -164,13 +164,13 @@ ;; CHECK-NEXT: ) ;; DESCC: (func $test (type $4) (param $any anyref) ;; DESCC-NEXT: (drop - ;; DESCC-NEXT: (ref.cast_desc (ref $A) + ;; DESCC-NEXT: (ref.cast_desc_eq (ref $A) ;; DESCC-NEXT: (local.get $any) ;; DESCC-NEXT: (global.get $A.desc) ;; DESCC-NEXT: ) ;; DESCC-NEXT: ) ;; DESCC-NEXT: (drop - ;; DESCC-NEXT: (ref.cast_desc (ref $B) + ;; DESCC-NEXT: (ref.cast_desc_eq (ref $B) ;; DESCC-NEXT: (local.get $any) ;; DESCC-NEXT: (global.get $B.desc) ;; DESCC-NEXT: ) @@ -366,7 +366,7 @@ ;; CHECK-NEXT: ) ;; DESCC: (func $test (type $2) (param $any anyref) ;; DESCC-NEXT: (drop - ;; DESCC-NEXT: (ref.cast_desc (ref null $A) + ;; DESCC-NEXT: (ref.cast_desc_eq (ref null $A) ;; DESCC-NEXT: (local.get $any) ;; DESCC-NEXT: (global.get $A.desc) ;; DESCC-NEXT: ) diff --git a/test/lit/passes/heap2local-desc.wast b/test/lit/passes/heap2local-desc.wast index 029d5d72005..31acabd29da 100644 --- a/test/lit/passes/heap2local-desc.wast +++ b/test/lit/passes/heap2local-desc.wast @@ -239,7 +239,7 @@ ) ) - ;; CHECK: (func $cast-desc-success (type $10) + ;; CHECK: (func $cast-desc-eq-success (type $10) ;; CHECK-NEXT: (local $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (local $1 (ref (exact $super.desc))) ;; CHECK-NEXT: (local $2 (ref (exact $super.desc))) @@ -276,13 +276,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-success + (func $cast-desc-eq-success (local $desc (ref null (exact $super.desc))) (local.set $desc (struct.new $super.desc) ) (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (struct.new_desc $super (local.get $desc) ) @@ -291,7 +291,7 @@ ) ) - ;; CHECK: (func $cast-desc-fail (type $11) (param $desc (ref null (exact $super.desc))) + ;; CHECK: (func $cast-desc-eq-fail (type $11) (param $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (local $1 (ref (exact $super.desc))) ;; CHECK-NEXT: (local $2 (ref (exact $super.desc))) ;; CHECK-NEXT: (drop @@ -322,9 +322,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail (param $desc (ref null (exact $super.desc))) + (func $cast-desc-eq-fail (param $desc (ref null (exact $super.desc))) (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (struct.new_desc $super (struct.new $super.desc) ) @@ -333,7 +333,7 @@ ) ) - ;; CHECK: (func $cast-desc-fail-reverse (type $11) (param $desc (ref null (exact $super.desc))) + ;; CHECK: (func $cast-desc-eq-fail-reverse (type $11) (param $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (local $1 (ref (exact $super.desc))) ;; CHECK-NEXT: (local $2 (ref (exact $super.desc))) ;; CHECK-NEXT: (drop @@ -368,10 +368,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail-reverse (param $desc (ref null (exact $super.desc))) + (func $cast-desc-eq-fail-reverse (param $desc (ref null (exact $super.desc))) ;; Same as above, but change where the parameter is used. (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (struct.new_desc $super (local.get $desc) ) @@ -380,7 +380,7 @@ ) ) - ;; CHECK: (func $cast-desc-fail-param (type $12) (param $ref (ref null (exact $super))) + ;; CHECK: (func $cast-desc-eq-fail-param (type $12) (param $ref (ref null (exact $super))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop @@ -395,18 +395,18 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail-param (param $ref (ref null (exact $super))) + (func $cast-desc-eq-fail-param (param $ref (ref null (exact $super))) ;; Now cast the parameter. We know it can't have the locally allocated ;; descriptor, so the cast fails. (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (local.get $ref) (struct.new $super.desc) ) ) ) - ;; CHECK: (func $cast-desc-fail-param-effect (type $12) (param $ref (ref null (exact $super))) + ;; CHECK: (func $cast-desc-eq-fail-param-effect (type $12) (param $ref (ref null (exact $super))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop @@ -427,10 +427,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail-param-effect (param $ref (ref null (exact $super))) + (func $cast-desc-eq-fail-param-effect (param $ref (ref null (exact $super))) ;; Same, but with effects we cannot drop. (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (block (result (ref null (exact $super))) (call $effect) (local.get $ref) @@ -443,7 +443,7 @@ ) ) - ;; CHECK: (func $cast-desc-fail-param-nullable (type $12) (param $ref (ref null (exact $super))) + ;; CHECK: (func $cast-desc-eq-fail-param-nullable (type $12) (param $ref (ref null (exact $super))) ;; CHECK-NEXT: (local $1 (ref null (exact $super))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) @@ -461,17 +461,17 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail-param-nullable (param $ref (ref null (exact $super))) + (func $cast-desc-eq-fail-param-nullable (param $ref (ref null (exact $super))) ;; Now the cast admits nulls. (drop - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (local.get $ref) (struct.new $super.desc) ) ) ) - ;; CHECK: (func $cast-desc-fail-param-nullable-effect (type $12) (param $ref (ref null (exact $super))) + ;; CHECK: (func $cast-desc-eq-fail-param-nullable-effect (type $12) (param $ref (ref null (exact $super))) ;; CHECK-NEXT: (local $1 (ref null (exact $super))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) @@ -495,10 +495,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-fail-param-nullable-effect (param $ref (ref null (exact $super))) + (func $cast-desc-eq-fail-param-nullable-effect (param $ref (ref null (exact $super))) ;; Now the cast admits nulls and there are effects we cannot remove. (drop - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (block (result (ref null (exact $super))) (call $effect) (local.get $ref) @@ -529,7 +529,7 @@ (func $cast-no-desc (param $desc (ref null (exact $super.desc))) ;; The allocation does not have a descriptor, so we know the cast must fail. (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (struct.new $no-desc) (local.get $desc) ) @@ -560,7 +560,7 @@ (func $cast-no-desc-effect (param $desc (ref null (exact $super.desc))) ;; Same, but with effects we cannot drop. (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (block (result (ref (exact $no-desc))) (call $effect) (struct.new $no-desc) @@ -593,7 +593,7 @@ ;; Although the cast admits nulls, we know we don't have a null here, so we ;; don't need to preserve a null cast. (drop - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (struct.new $no-desc) (local.get $desc) ) @@ -624,7 +624,7 @@ (func $cast-no-desc-nullable-effect (param $desc (ref null (exact $super.desc))) ;; Same, but with effects we cannot drop. (drop - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (block (result (ref (exact $no-desc))) (call $effect) (struct.new $no-desc) @@ -637,7 +637,7 @@ ) ) - ;; CHECK: (func $cast-desc-and-ref (type $14) (param $desc (ref null (exact $chain-descriptor))) + ;; CHECK: (func $cast-desc-eq-and-ref (type $14) (param $desc (ref null (exact $chain-descriptor))) ;; CHECK-NEXT: (local $middle (ref null (exact $chain-middle))) ;; CHECK-NEXT: (local $2 (ref (exact $chain-descriptor))) ;; CHECK-NEXT: (local $3 (ref (exact $chain-descriptor))) @@ -666,7 +666,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-and-ref (param $desc (ref null (exact $chain-descriptor))) + (func $cast-desc-eq-and-ref (param $desc (ref null (exact $chain-descriptor))) ;; The same allocation flows into both the descriptor and the reference. The ;; cast must fail because a value cannot be its own descriptor. We make sure ;; the descriptor itself has a descriptor so it is not handled by the same @@ -678,14 +678,14 @@ ) ) (drop - (ref.cast_desc (ref (exact $chain-described)) + (ref.cast_desc_eq (ref (exact $chain-described)) (local.get $middle) (local.get $middle) ) ) ) - ;; CHECK: (func $cast-desc-and-ref-nullable (type $14) (param $desc (ref null (exact $chain-descriptor))) + ;; CHECK: (func $cast-desc-eq-and-ref-nullable (type $14) (param $desc (ref null (exact $chain-descriptor))) ;; CHECK-NEXT: (local $middle (ref null (exact $chain-middle))) ;; CHECK-NEXT: (local $2 (ref (exact $chain-descriptor))) ;; CHECK-NEXT: (local $3 (ref (exact $chain-descriptor))) @@ -714,7 +714,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-and-ref-nullable (param $desc (ref null (exact $chain-descriptor))) + (func $cast-desc-eq-and-ref-nullable (param $desc (ref null (exact $chain-descriptor))) ;; Same, but now the cast allows nulls. It should still trap. (local $middle (ref null (exact $chain-middle))) (local.set $middle @@ -723,14 +723,14 @@ ) ) (drop - (ref.cast_desc (ref null (exact $chain-described)) + (ref.cast_desc_eq (ref null (exact $chain-described)) (local.get $middle) (local.get $middle) ) ) ) - ;; CHECK: (func $cast-desc-and-ref-tee (type $10) + ;; CHECK: (func $cast-desc-eq-and-ref-tee (type $10) ;; CHECK-NEXT: (local $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block @@ -746,12 +746,12 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-and-ref-tee + (func $cast-desc-eq-and-ref-tee ;; The same allocation flows into both the descriptor and the reference ;; again, but now it uses a tee. The allocation does not have a descriptor. (local $desc (ref null (exact $super.desc))) (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (local.tee $desc (struct.new $super.desc) ) @@ -760,7 +760,7 @@ ) ) - ;; CHECK: (func $cast-desc-and-ref-tee-nullable (type $10) + ;; CHECK: (func $cast-desc-eq-and-ref-tee-nullable (type $10) ;; CHECK-NEXT: (local $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block @@ -776,11 +776,11 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-and-ref-tee-nullable + (func $cast-desc-eq-and-ref-tee-nullable ;; Same, but the cast allows nulls. It should still trap. (local $desc (ref null (exact $super.desc))) (drop - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (local.tee $desc (struct.new $super.desc) ) @@ -789,7 +789,7 @@ ) ) - ;; CHECK: (func $cast-desc-stale-parent (type $15) (result (ref (exact $super))) + ;; CHECK: (func $cast-desc-eq-stale-parent (type $15) (result (ref (exact $super))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (ref.null none) @@ -805,10 +805,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) - (func $cast-desc-stale-parent (result (ref (exact $super))) - (ref.cast_desc (ref (exact $super)) + (func $cast-desc-eq-stale-parent (result (ref (exact $super))) + (ref.cast_desc_eq (ref (exact $super)) ;; We will optimize this allocation first, causing the parent - ;; ref.cast_desc to be optimized out. The parent map will no longer be up + ;; ref.cast_desc_eq to be optimized out. The parent map will no longer be up ;; to date when we optimize the second allocation, but we should sill be ;; able to optimize successfully without crashing. (struct.new_default $no-desc) @@ -819,7 +819,7 @@ ) ) - ;; CHECK: (func $cast-desc-stale-parent-escape (type $16) (result (ref (exact $super.desc))) + ;; CHECK: (func $cast-desc-eq-stale-parent-escape (type $16) (result (ref (exact $super.desc))) ;; CHECK-NEXT: (local $desc (ref null (exact $super.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block @@ -840,10 +840,10 @@ ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc-stale-parent-escape (result (ref (exact $super.desc))) + (func $cast-desc-eq-stale-parent-escape (result (ref (exact $super.desc))) (local $desc (ref (exact $super.desc))) (drop - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) ;; Same as above, but now the second alloocation escapes. We should still ;; optimize the first allocation and the cast, and we should still not ;; crash. @@ -996,7 +996,7 @@ ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $A (result (ref $A)) - (ref.cast_desc (ref $A) + (ref.cast_desc_eq (ref $A) (struct.new_default_desc $A2 (struct.new_default $B2) ) @@ -1129,7 +1129,7 @@ ) (local.set $v (struct.get $A 0 - (ref.cast_desc (ref $A) + (ref.cast_desc_eq (ref $A) (struct.new_default_desc $A (ref.as_non_null (ref.null none) @@ -1201,13 +1201,13 @@ (local $temp (ref $C)) (local.set $temp ;; We optimize this first, making the |local.get| below unreachable, and - ;; making that inner ref.cast_desc unreachable, which leads to the + ;; making that inner ref.cast_desc_eq unreachable, which leads to the ;; |struct.new_default $B| being dropped, and in particular having a new ;; parent (the drop). We should not get confused and error internally. (struct.new_default $C) ) - (ref.cast_desc (ref $B) - (ref.cast_desc (ref $B) + (ref.cast_desc_eq (ref $B) + (ref.cast_desc_eq (ref $B) (struct.new_default_desc $B (ref.null (shared none)) ) @@ -1264,13 +1264,13 @@ (struct.new_default $desc) ) ;; After we optimize the struct.new above, the local.get below will get - ;; removed, and we will see that the ref.cast_desc traps (the input + ;; removed, and we will see that the ref.cast_desc_eq traps (the input ;; descriptor differs from the one we test, the allocation we just ;; removed). When optimizing that, we should not emit invalid IR for the ;; ref.is_null: It has an i32 result normally, but in unreachable code it ;; must remain unreachable. (ref.is_null - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (struct.new_default_desc $struct (struct.new_default $desc) ) diff --git a/test/lit/passes/optimize-instructions-desc.wast b/test/lit/passes/optimize-instructions-desc.wast index 8cd0764fb13..151f9e9d32b 100644 --- a/test/lit/passes/optimize-instructions-desc.wast +++ b/test/lit/passes/optimize-instructions-desc.wast @@ -80,17 +80,17 @@ ) ) - ;; CHECK: (func $nonnull-cast-desc (type $19) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) + ;; CHECK: (func $nonnull-cast-desc-eq (type $19) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) ;; CHECK-NEXT: (struct.new_default_desc $struct ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $nonnull-cast-desc (type $19) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) + ;; NTRAP: (func $nonnull-cast-desc-eq (type $19) (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) ;; NTRAP-NEXT: (struct.new_default_desc $struct ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $nonnull-cast-desc (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) + (func $nonnull-cast-desc-eq (param $desc (ref null (exact $desc))) (result (ref (exact $struct))) (struct.new_desc $struct (ref.as_non_null (local.get $desc) @@ -128,19 +128,19 @@ ) ) - ;; CHECK: (func $cast-desc-null-desc (type $4) + ;; CHECK: (func $cast-desc-eq-null-desc (type $4) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-null-desc (type $4) + ;; NTRAP: (func $cast-desc-eq-null-desc (type $4) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (unreachable) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-null-desc + (func $cast-desc-eq-null-desc (drop - (ref.cast_desc (ref (exact $struct)) + (ref.cast_desc_eq (ref (exact $struct)) (struct.new_desc $struct (struct.new $desc) ) @@ -149,107 +149,107 @@ ) ) - ;; CHECK: (func $cast-desc-no-glb (type $9) (param $nn-sub (ref $sub)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-no-glb (type $9) (param $nn-sub (ref $sub)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (local.get $nn-sub) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-no-glb (type $9) (param $nn-sub (ref $sub)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-no-glb (type $9) (param $nn-sub (ref $sub)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) ;; NTRAP-NEXT: (local.get $nn-sub) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-no-glb (param $nn-sub (ref $sub)) (param $desc (ref $desc)) + (func $cast-desc-eq-no-glb (param $nn-sub (ref $sub)) (param $desc (ref $desc)) (drop ;; We cannot improve the cast target heap type, but we can improve the ;; nullability. With traps-never-happen we can optimize fully. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $nn-sub) (local.get $desc) ) ) ) - ;; CHECK: (func $cast-desc-improve-nullability (type $20) (param $nn-any (ref any)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-improve-nullability (type $20) (param $nn-any (ref any)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (local.get $nn-any) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-improve-nullability (type $20) (param $nn-any (ref any)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-improve-nullability (type $20) (param $nn-any (ref any)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $struct) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $struct) ;; NTRAP-NEXT: (local.get $nn-any) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-improve-nullability (param $nn-any (ref any)) (param $desc (ref $desc)) + (func $cast-desc-eq-improve-nullability (param $nn-any (ref any)) (param $desc (ref $desc)) (drop ;; Like above, but the ref isn't a subtype of the cast type. We can still ;; improve the nullability. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $nn-any) (local.get $desc) ) ) ) - ;; CHECK: (func $cast-desc-only-improve-nullability (type $8) (param $any anyref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-only-improve-nullability (type $8) (param $any anyref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-only-improve-nullability (type $8) (param $any anyref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-only-improve-nullability (type $8) (param $any anyref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $struct) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $struct) ;; NTRAP-NEXT: (local.get $any) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-only-improve-nullability (param $any anyref) (param $desc (ref $desc)) + (func $cast-desc-eq-only-improve-nullability (param $any anyref) (param $desc (ref $desc)) (drop ;; Now the cast target is already non-nullable. We shouldn't make it ;; nullable. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (local.get $any) (local.get $desc) ) ) ) - ;; CHECK: (func $cast-desc-unrelated-type (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + ;; CHECK: (func $cast-desc-eq-unrelated-type (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-unrelated-type (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + ;; NTRAP: (func $cast-desc-eq-unrelated-type (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (unreachable) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-unrelated-type (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + (func $cast-desc-eq-unrelated-type (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) (drop ;; We know this cast will fail so we can optimize. - (ref.cast_desc (ref (exact $struct-i32)) + (ref.cast_desc_eq (ref (exact $struct-i32)) (local.get $struct) (local.get $desc-i32) ) ) ) - ;; CHECK: (func $cast-desc-unrelated-type-effects (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + ;; CHECK: (func $cast-desc-eq-unrelated-type-effects (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop @@ -268,7 +268,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-unrelated-type-effects (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + ;; NTRAP: (func $cast-desc-eq-unrelated-type-effects (type $12) (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block ;; NTRAP-NEXT: (drop @@ -287,10 +287,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-unrelated-type-effects (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) + (func $cast-desc-eq-unrelated-type-effects (param $struct (ref $struct)) (param $desc-i32 (ref (exact $struct-i32.desc))) (drop ;; As above, but now with effects we need to keep. - (ref.cast_desc (ref (exact $struct-i32)) + (ref.cast_desc_eq (ref (exact $struct-i32)) (block (result (ref $struct)) (call $effect) (local.get $struct) @@ -303,32 +303,32 @@ ) ) - ;; CHECK: (func $cast-desc-unrelated-type-nullable (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-unrelated-type-nullable (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null $struct) ;; CHECK-NEXT: (local.get $struct-i32) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-unrelated-type-nullable (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-unrelated-type-nullable (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (ref.null none) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-unrelated-type-nullable (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + (func $cast-desc-eq-unrelated-type-nullable (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) (drop ;; Same as above, but now we allow nulls. We can optimize with traps-never-happen. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $struct-i32) (local.get $desc) ) ) ) - ;; CHECK: (func $cast-desc-unrelated-type-nullable-effects (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-unrelated-type-nullable-effects (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null $struct) ;; CHECK-NEXT: (block (result (ref null $struct-i32)) ;; CHECK-NEXT: (call $effect) ;; CHECK-NEXT: (local.get $struct-i32) @@ -340,7 +340,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-unrelated-type-nullable-effects (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-unrelated-type-nullable-effects (type $13) (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result nullref) ;; NTRAP-NEXT: (drop @@ -359,10 +359,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-unrelated-type-nullable-effects (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) + (func $cast-desc-eq-unrelated-type-nullable-effects (param $struct-i32 (ref null $struct-i32)) (param $desc (ref $desc)) (drop ;; Same as above, but now with effects we cannot drop. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result (ref null $struct-i32)) (call $effect) (local.get $struct-i32) @@ -375,9 +375,9 @@ ) ) - ;; CHECK: (func $cast-desc-wrong-desc (type $4) + ;; CHECK: (func $cast-desc-eq-wrong-desc (type $4) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; CHECK-NEXT: (struct.new_default_desc $struct ;; CHECK-NEXT: (struct.new_default $desc) ;; CHECK-NEXT: ) @@ -385,7 +385,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-wrong-desc (type $4) + ;; NTRAP: (func $cast-desc-eq-wrong-desc (type $4) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref (exact $struct))) ;; NTRAP-NEXT: (struct.new_default_desc $struct @@ -394,13 +394,13 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-wrong-desc + (func $cast-desc-eq-wrong-desc (drop ;; With traps-never-happen we assume the cast will succeed and optimize it ;; out, even even though it would actually fail. ;; TODO: We could see that the descriptor used in the allocation and the ;; descriptor used in the cast are different and optimize without TNH. - (ref.cast_desc (ref (exact $struct)) + (ref.cast_desc_eq (ref (exact $struct)) (struct.new_desc $struct (struct.new $desc) ) @@ -409,9 +409,9 @@ ) ) - ;; CHECK: (func $cast-desc-wrong-desc-effects (type $4) + ;; CHECK: (func $cast-desc-eq-wrong-desc-effects (type $4) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; CHECK-NEXT: (block (result (ref (exact $struct))) ;; CHECK-NEXT: (call $effect) ;; CHECK-NEXT: (struct.new_default_desc $struct @@ -425,7 +425,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-wrong-desc-effects (type $4) + ;; NTRAP: (func $cast-desc-eq-wrong-desc-effects (type $4) ;; NTRAP-NEXT: (local $0 (ref (exact $struct))) ;; NTRAP-NEXT: (local $1 (ref (exact $desc))) ;; NTRAP-NEXT: (drop @@ -448,10 +448,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-wrong-desc-effects + (func $cast-desc-eq-wrong-desc-effects (drop ;; Same, but with effects. - (ref.cast_desc (ref (exact $struct)) + (ref.cast_desc_eq (ref (exact $struct)) (block (result (ref (exact $struct))) (call $effect) (struct.new_desc $struct @@ -466,26 +466,26 @@ ) ) - ;; CHECK: (func $cast-desc-weaker-nondesc-child (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) + ;; CHECK: (func $cast-desc-eq-weaker-nondesc-child (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $sub) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $sub) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-weaker-nondesc-child (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) + ;; NTRAP: (func $cast-desc-eq-weaker-nondesc-child (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $sub) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $sub) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-weaker-nondesc-child (param $ref anyref) (param $desc (ref $sub.desc)) + (func $cast-desc-eq-weaker-nondesc-child (param $ref anyref) (param $desc (ref $sub.desc)) (drop ;; Optimize out the weaker child cast. - (ref.cast_desc (ref $sub) + (ref.cast_desc_eq (ref $sub) (ref.cast (ref any) (local.get $ref) ) @@ -494,9 +494,9 @@ ) ) - ;; CHECK: (func $cast-desc-weaker-nondesc-child-effects (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) + ;; CHECK: (func $cast-desc-eq-weaker-nondesc-child-effects (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $sub) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $sub) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (call $effect) @@ -510,9 +510,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-weaker-nondesc-child-effects (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) + ;; NTRAP: (func $cast-desc-eq-weaker-nondesc-child-effects (type $14) (param $ref anyref) (param $desc (ref $sub.desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $sub) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $sub) ;; NTRAP-NEXT: (ref.as_non_null ;; NTRAP-NEXT: (block (result anyref) ;; NTRAP-NEXT: (call $effect) @@ -526,11 +526,11 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-weaker-nondesc-child-effects (param $ref anyref) (param $desc (ref $sub.desc)) + (func $cast-desc-eq-weaker-nondesc-child-effects (param $ref anyref) (param $desc (ref $sub.desc)) (drop ;; Same, but with effects. Due to ordering, we cannot remove the inner ;; cast (which turns into ref.as_non_null). - (ref.cast_desc (ref $sub) + (ref.cast_desc_eq (ref $sub) (ref.cast (ref any) (block (result anyref) (call $effect) @@ -545,9 +545,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-nondesc-child (type $8) (param $ref anyref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-nondesc-child (type $8) (param $ref anyref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (ref.cast (ref $sub) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) @@ -555,7 +555,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-nondesc-child (type $8) (param $ref anyref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-nondesc-child (type $8) (param $ref anyref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) ;; NTRAP-NEXT: (ref.cast (ref $sub) @@ -564,11 +564,11 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-nondesc-child (param $ref anyref) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-nondesc-child (param $ref anyref) (param $desc (ref $desc)) (drop ;; With traps-never-happen we assume the outer cast will succeed and ;; optimize it out. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (ref.cast (ref $sub) (local.get $ref) ) @@ -577,9 +577,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-nondesc-child-effects (type $8) (param $ref anyref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-nondesc-child-effects (type $8) (param $ref anyref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (ref.cast (ref $sub) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (call $effect) @@ -593,7 +593,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-nondesc-child-effects (type $8) (param $ref anyref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-nondesc-child-effects (type $8) (param $ref anyref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (local $2 (ref $sub)) ;; NTRAP-NEXT: (local $3 (ref $desc)) ;; NTRAP-NEXT: (drop @@ -616,10 +616,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-nondesc-child-effects (param $ref anyref) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-nondesc-child-effects (param $ref anyref) (param $desc (ref $desc)) (drop ;; Same, but with effects. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (ref.cast (ref $sub) (block (result anyref) (call $effect) @@ -634,10 +634,10 @@ ) ) - ;; CHECK: (func $cast-desc-weaker-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + ;; CHECK: (func $cast-desc-eq-weaker-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $sub) - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $sub) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -645,9 +645,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-weaker-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + ;; NTRAP: (func $cast-desc-eq-weaker-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $sub) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $sub) ;; NTRAP-NEXT: (block (result anyref) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: ) @@ -655,13 +655,13 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-weaker-desc-child (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + (func $cast-desc-eq-weaker-desc-child (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) (drop ;; We can only optimize the weaker child cast with traps-never-happen ;; because it might fail due to an incorrect descriptor even when the ;; parent cast would succeed. - (ref.cast_desc (ref $sub) - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $sub) + (ref.cast_desc_eq (ref $struct) (local.get $ref) (local.get $desc) ) @@ -670,10 +670,10 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + ;; CHECK: (func $cast-desc-eq-stronger-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) - ;; CHECK-NEXT: (ref.cast_desc (ref $sub) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $sub) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $sub.desc) ;; CHECK-NEXT: ) @@ -681,22 +681,22 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-desc-child (type $15) (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) - ;; NTRAP-NEXT: (ref.cast_desc (ref $sub) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $sub) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: (local.get $sub.desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-desc-child (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) + (func $cast-desc-eq-stronger-desc-child (param $ref anyref) (param $desc (ref $desc)) (param $sub.desc (ref $sub.desc)) (drop ;; Like above, but now when we optimize with traps-never-happen we replace ;; the parent with the child. - (ref.cast_desc (ref $struct) - (ref.cast_desc (ref $sub) + (ref.cast_desc_eq (ref $struct) + (ref.cast_desc_eq (ref $sub) (local.get $ref) (local.get $sub.desc) ) @@ -705,9 +705,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -715,7 +715,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (local $2 (ref $sub)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) @@ -730,11 +730,11 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough (param $sub (ref $sub)) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough (param $sub (ref $sub)) (param $desc (ref $desc)) (drop ;; Like above, but now the stronger child is deeper. We use a tee to ;; extract it. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (block (result anyref) (local.get $sub) ) @@ -743,9 +743,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-effects (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-effects (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (call $effect) ;; CHECK-NEXT: (local.get $sub) @@ -757,7 +757,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-effects (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-effects (type $9) (param $sub (ref $sub)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (local $2 (ref $sub)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) @@ -779,10 +779,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-effects (param $sub (ref $sub)) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough-effects (param $sub (ref $sub)) (param $desc (ref $desc)) (drop ;; Like above, but now with effects we cannot drop. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (block (result anyref) (call $effect) (local.get $sub) @@ -795,9 +795,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-nullck (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-nullck (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -805,7 +805,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-nullck (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-nullck (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (local $2 (ref null $sub)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) @@ -822,10 +822,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-nullck (param $sub (ref null $sub)) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough-nullck (param $sub (ref null $sub)) (param $desc (ref $desc)) (drop ;; Like above, but now we also need a null check. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (block (result anyref) (local.get $sub) ) @@ -834,9 +834,9 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-nullck-effects (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-nullck-effects (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (call $effect) ;; CHECK-NEXT: (local.get $sub) @@ -848,7 +848,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-nullck-effects (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-nullck-effects (type $16) (param $sub (ref null $sub)) (param $desc (ref $desc)) ;; NTRAP-NEXT: (local $2 (ref null $sub)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result (ref $sub)) @@ -872,10 +872,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-nullck-effects (param $sub (ref null $sub)) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough-nullck-effects (param $sub (ref null $sub)) (param $desc (ref $desc)) (drop ;; Like above, but now with effects. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (block (result anyref) (call $effect) (local.get $sub) @@ -888,20 +888,20 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-null (type $17) (param $null nullref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-null (type $17) (param $null nullref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-null (type $17) (param $null nullref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-null (type $17) (param $null nullref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (ref.null none) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-null (param $null nullref) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough-null (param $null nullref) (param $desc (ref $desc)) (drop ;; Like above, but now the value itself is null and we allow it. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result anyref) (local.get $null) ) @@ -910,7 +910,7 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-null-effects (type $17) (param $null nullref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-null-effects (type $17) (param $null nullref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop @@ -929,7 +929,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-null-effects (type $17) (param $null nullref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-null-effects (type $17) (param $null nullref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result nullref) ;; NTRAP-NEXT: (drop @@ -948,10 +948,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-null-effects (param $null nullref) (param $desc (ref $desc)) + (func $cast-desc-eq-stronger-fallthrough-null-effects (param $null nullref) (param $desc (ref $desc)) (drop ;; Like above, but now with effects. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result anyref) (call $effect) (local.get $null) @@ -964,7 +964,7 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-null-null-desc (type $18) (param $null nullref) (param $desc (ref null $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-null-null-desc (type $18) (param $null nullref) (param $desc (ref null $desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop @@ -976,16 +976,16 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-null-null-desc (type $18) (param $null nullref) (param $desc (ref null $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-null-null-desc (type $18) (param $null nullref) (param $desc (ref null $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (ref.null none) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-null-null-desc (param $null nullref) (param $desc (ref null $desc)) + (func $cast-desc-eq-stronger-fallthrough-null-null-desc (param $null nullref) (param $desc (ref null $desc)) (drop ;; Like above, but now the descriptor is nullable so we have to add a null ;; check to it. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result anyref) (local.get $null) ) @@ -994,7 +994,7 @@ ) ) - ;; CHECK: (func $cast-desc-stronger-fallthrough-null-null-desc-effects (type $18) (param $null nullref) (param $desc (ref null $desc)) + ;; CHECK: (func $cast-desc-eq-stronger-fallthrough-null-null-desc-effects (type $18) (param $null nullref) (param $desc (ref null $desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block (result nullref) ;; CHECK-NEXT: (drop @@ -1015,7 +1015,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-stronger-fallthrough-null-null-desc-effects (type $18) (param $null nullref) (param $desc (ref null $desc)) + ;; NTRAP: (func $cast-desc-eq-stronger-fallthrough-null-null-desc-effects (type $18) (param $null nullref) (param $desc (ref null $desc)) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block (result nullref) ;; NTRAP-NEXT: (drop @@ -1034,10 +1034,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-stronger-fallthrough-null-null-desc-effects (param $null nullref) (param $desc (ref null $desc)) + (func $cast-desc-eq-stronger-fallthrough-null-null-desc-effects (param $null nullref) (param $desc (ref null $desc)) (drop ;; Like above, but now with effects. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (block (result anyref) (call $effect) (local.get $null) @@ -1050,26 +1050,26 @@ ) ) - ;; CHECK: (func $cast-desc-ref-as-non-null (type $8) (param $any anyref) (param $desc (ref $desc)) + ;; CHECK: (func $cast-desc-eq-ref-as-non-null (type $8) (param $any anyref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-ref-as-non-null (type $8) (param $any anyref) (param $desc (ref $desc)) + ;; NTRAP: (func $cast-desc-eq-ref-as-non-null (type $8) (param $any anyref) (param $desc (ref $desc)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref $struct) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref $struct) ;; NTRAP-NEXT: (local.get $any) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-ref-as-non-null (param $any anyref) (param $desc (ref $desc)) + (func $cast-desc-eq-ref-as-non-null (param $any anyref) (param $desc (ref $desc)) (drop ;; We can roll the ref.as_non_null into the cast. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (ref.as_non_null (local.get $any) ) @@ -1078,7 +1078,7 @@ ) ) - ;; CHECK: (func $cast-desc-unreachable-desc (type $4) + ;; CHECK: (func $cast-desc-eq-unreachable-desc (type $4) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; CHECK-NEXT: (drop @@ -1091,7 +1091,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-unreachable-desc (type $4) + ;; NTRAP: (func $cast-desc-eq-unreachable-desc (type $4) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block ;; (replaces unreachable RefCast we can't emit) ;; NTRAP-NEXT: (drop @@ -1104,10 +1104,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-unreachable-desc + (func $cast-desc-eq-unreachable-desc (drop ;; Don't crash on an unreachable descriptor. - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (ref.null none) (unreachable) ) @@ -1148,25 +1148,25 @@ ) ) - ;; CHECK: (func $cast-desc-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; CHECK: (func $cast-desc-eq-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $cast-desc-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; NTRAP: (func $cast-desc-eq-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $cast-desc-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + (func $cast-desc-eq-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) (drop - (ref.cast_desc (ref (exact $struct)) + (ref.cast_desc_eq (ref (exact $struct)) (local.get $ref) ;; This is not needed, as the parent traps on null anyhow. (ref.as_non_null @@ -1176,11 +1176,11 @@ ) ) - ;; CHECK: (func $br_on_cast_desc-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; CHECK: (func $br_on_cast_desc_eq-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result (ref null $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l (ref null $struct) (ref null (exact $struct)) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref null $struct) (ref null (exact $struct)) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -1189,11 +1189,11 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $br_on_cast_desc-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; NTRAP: (func $br_on_cast_desc_eq-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block $l (result (ref null $struct)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (br_on_cast_desc $l (ref null $struct) (ref null (exact $struct)) + ;; NTRAP-NEXT: (br_on_cast_desc_eq $l (ref null $struct) (ref null (exact $struct)) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) @@ -1202,10 +1202,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $br_on_cast_desc-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + (func $br_on_cast_desc_eq-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) (drop (block $l (result (ref null $struct)) - (br_on_cast_desc $l anyref (ref null $struct) + (br_on_cast_desc_eq $l anyref (ref null $struct) (local.get $ref) ;; This is not needed, as the parent traps on null anyhow. (ref.as_non_null @@ -1217,11 +1217,11 @@ ) ) - ;; CHECK: (func $br_on_cast_desc_fail-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; CHECK: (func $br_on_cast_desc_eq_fail-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result (ref null $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l (ref null $struct) (ref null (exact $struct)) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l (ref null $struct) (ref null (exact $struct)) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -1230,11 +1230,11 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $br_on_cast_desc_fail-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; NTRAP: (func $br_on_cast_desc_eq_fail-skip-non-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block $l (result (ref null $struct)) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (br_on_cast_desc_fail $l (ref null $struct) (ref null (exact $struct)) + ;; NTRAP-NEXT: (br_on_cast_desc_eq_fail $l (ref null $struct) (ref null (exact $struct)) ;; NTRAP-NEXT: (local.get $ref) ;; NTRAP-NEXT: (local.get $desc) ;; NTRAP-NEXT: ) @@ -1243,10 +1243,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $br_on_cast_desc_fail-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + (func $br_on_cast_desc_eq_fail-skip-non-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) (drop (block $l (result (ref null $struct)) - (br_on_cast_desc_fail $l anyref (ref null $struct) + (br_on_cast_desc_eq_fail $l anyref (ref null $struct) (local.get $ref) ;; This is not needed, as the parent traps on null anyhow. (ref.as_non_null @@ -1258,7 +1258,7 @@ ) ) - ;; CHECK: (func $br_on_cast_desc-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; CHECK: (func $br_on_cast_desc_eq-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result (ref none)) ;; CHECK-NEXT: (drop @@ -1283,7 +1283,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $br_on_cast_desc-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; NTRAP: (func $br_on_cast_desc_eq-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block $l (result (ref none)) ;; NTRAP-NEXT: (drop @@ -1308,10 +1308,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $br_on_cast_desc-trap-on-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + (func $br_on_cast_desc_eq-trap-on-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) (drop (block $l (result (ref null $struct)) - (br_on_cast_desc $l anyref (ref null $struct) + (br_on_cast_desc_eq $l anyref (ref null $struct) (local.get $ref) (block (result (ref null $desc)) (ref.null $desc) @@ -1322,7 +1322,7 @@ ) ) - ;; CHECK: (func $br_on_cast_desc_fail-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; CHECK: (func $br_on_cast_desc_eq_fail-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result (ref null $struct)) ;; CHECK-NEXT: (drop @@ -1347,7 +1347,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $br_on_cast_desc_fail-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + ;; NTRAP: (func $br_on_cast_desc_eq_fail-trap-on-null (type $7) (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) ;; NTRAP-NEXT: (drop ;; NTRAP-NEXT: (block $l (result (ref null $struct)) ;; NTRAP-NEXT: (drop @@ -1372,10 +1372,10 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $br_on_cast_desc_fail-trap-on-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) + (func $br_on_cast_desc_eq_fail-trap-on-null (param $ref (ref null $struct)) (param $desc (ref null (exact $desc))) (drop (block $l (result (ref null $struct)) - (br_on_cast_desc_fail $l anyref (ref null $struct) + (br_on_cast_desc_eq_fail $l anyref (ref null $struct) (local.get $ref) (block (result (ref null $desc)) (ref.null $desc) @@ -1386,10 +1386,10 @@ ) ) - ;; CHECK: (func $ref.cast_desc-ref.as_non_null (type $4) + ;; CHECK: (func $ref.cast_desc_eq-ref.as_non_null (type $4) ;; CHECK-NEXT: (local $null (ref null $struct)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (local.get $null) ;; CHECK-NEXT: ) @@ -1399,13 +1399,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; CHECK-NEXT: (local.get $null) ;; CHECK-NEXT: (struct.new_default $desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NTRAP: (func $ref.cast_desc-ref.as_non_null (type $4) + ;; NTRAP: (func $ref.cast_desc_eq-ref.as_non_null (type $4) ;; NTRAP-NEXT: (local $null (ref null $struct)) ;; NTRAP-NEXT: (local $1 (ref $struct)) ;; NTRAP-NEXT: (local $2 (ref null $desc)) @@ -1425,20 +1425,20 @@ ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: (drop - ;; NTRAP-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; NTRAP-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; NTRAP-NEXT: (local.get $null) ;; NTRAP-NEXT: (struct.new_default $desc) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) ;; NTRAP-NEXT: ) - (func $ref.cast_desc-ref.as_non_null + (func $ref.cast_desc_eq-ref.as_non_null (local $null (ref null $struct)) - ;; We read a null local and cast it to non-null, trapping. The ref.cast_desc + ;; We read a null local and cast it to non-null, trapping. The ref.cast_desc_eq ;; would trap on null anyhow, so it seems we can remove the ref.as_non_null, ;; but doing so would allow us to reach the block, which returns *before* the - ;; ref.cast_desc would trap. + ;; ref.cast_desc_eq would trap. (drop - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (ref.as_non_null (local.get $null) ) @@ -1451,7 +1451,7 @@ ;; As above, but without dangerous effects: we can remove the ;; ref.as_non_null. (drop - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (ref.as_non_null (local.get $null) ) diff --git a/test/lit/passes/precompute-desc.wast b/test/lit/passes/precompute-desc.wast index 767b4a2b200..623970cd39a 100644 --- a/test/lit/passes/precompute-desc.wast +++ b/test/lit/passes/precompute-desc.wast @@ -47,14 +47,14 @@ ) ) - ;; CHECK: (func $br-on-cast-desc (type $0) (result i32) + ;; CHECK: (func $br-on-cast-desc-eq (type $0) (result i32) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) - (func $br-on-cast-desc (result i32) + (func $br-on-cast-desc-eq (result i32) (ref.eq (block $l (result eqref) (drop - (br_on_cast_desc $l eqref (ref $struct) + (br_on_cast_desc_eq $l eqref (ref $struct) (global.get $struct) (global.get $desc) ) @@ -65,14 +65,14 @@ ) ) - ;; CHECK: (func $br-on-cast-desc-fail (type $0) (result i32) + ;; CHECK: (func $br-on-cast-desc-eq-fail (type $0) (result i32) ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) - (func $br-on-cast-desc-fail (result i32) + (func $br-on-cast-desc-eq-fail (result i32) (ref.eq (block $l (result eqref) (drop - (br_on_cast_desc_fail $l eqref (ref $struct) + (br_on_cast_desc_eq_fail $l eqref (ref $struct) (global.get $struct) (global.get $desc) ) diff --git a/test/lit/passes/remove-unused-brs-desc.wast b/test/lit/passes/remove-unused-brs-desc.wast index 7750ee02a43..cdf63f2de36 100644 --- a/test/lit/passes/remove-unused-brs-desc.wast +++ b/test/lit/passes/remove-unused-brs-desc.wast @@ -25,7 +25,7 @@ ;; CHECK: (func $no-glb (type $6) (param $sub (ref $sub)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l (ref $sub) (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref $sub) (ref $super) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: (local.get $super.desc) ;; CHECK-NEXT: ) @@ -38,7 +38,7 @@ (drop ;; We cannot improve the cast type even though it is a supertype of the ;; ref type because the cast type is determined by the descriptor. - (br_on_cast_desc $l (ref $sub) (ref $super) + (br_on_cast_desc_eq $l (ref $sub) (ref $super) (local.get $sub) (local.get $super.desc) ) @@ -51,7 +51,7 @@ ;; CHECK-NEXT: (block $l (result (ref null $super)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_non_null - ;; CHECK-NEXT: (br_on_cast_desc $l (ref $sub) (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref $sub) (ref $super) ;; CHECK-NEXT: (block (result (ref $sub)) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -66,7 +66,7 @@ (block $l (result anyref) (drop ;; We can improve the nullability, though, even via fallthrough. - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (block (result anyref) (local.get $sub) ) @@ -80,7 +80,7 @@ ;; CHECK: (func $only-improve-nullability (type $10) (param $sub (ref null $sub)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l anyref (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l anyref (ref $super) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -94,7 +94,7 @@ (block $l (result anyref) (drop ;; We do not flip the nullability if the target is already non-nullable. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (block (result anyref) (local.get $sub) ) @@ -108,7 +108,7 @@ ;; CHECK: (func $fail-no-glb (type $6) (param $sub (ref $sub)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l (ref $sub) (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l (ref $sub) (ref $super) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: (local.get $super.desc) ;; CHECK-NEXT: ) @@ -121,7 +121,7 @@ (drop ;; We cannot improve the cast type even though it is a supertype of the ;; ref type because the cast type is determined by the descriptor. - (br_on_cast_desc_fail $l (ref $sub) (ref $super) + (br_on_cast_desc_eq_fail $l (ref $sub) (ref $super) (local.get $sub) (local.get $super.desc) ) @@ -133,7 +133,7 @@ ;; CHECK: (func $fail-no-improve-nullability (type $6) (param $sub (ref $sub)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l anyref (ref null $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref null $super) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -148,7 +148,7 @@ (drop ;; In the fail case we cannot improve the nullability, either, because ;; that would make the sent values nullable, which might not be allowed. - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (block (result anyref) (local.get $sub) ) @@ -162,7 +162,7 @@ ;; CHECK: (func $fail-only-improve-nullability (type $10) (param $sub (ref null $sub)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l anyref (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref $super) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (local.get $sub) ;; CHECK-NEXT: ) @@ -176,7 +176,7 @@ (block $l (result anyref) (drop ;; We do not flip the nullability if the target is already non-nullable. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (block (result anyref) (local.get $sub) ) @@ -190,7 +190,7 @@ ;; CHECK: (func $unknown-result (type $11) (param $super (ref $super)) (param $sub.desc (ref $sub.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l (ref $super) (ref $sub) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref $super) (ref $sub) ;; CHECK-NEXT: (local.get $super) ;; CHECK-NEXT: (local.get $sub.desc) ;; CHECK-NEXT: ) @@ -203,7 +203,7 @@ (drop ;; We do not know anything about the result of this cast and cannot ;; optimize. - (br_on_cast_desc $l anyref (ref $sub) + (br_on_cast_desc_eq $l anyref (ref $sub) (local.get $super) (local.get $sub.desc) ) @@ -215,7 +215,7 @@ ;; CHECK: (func $fail-unknown-result (type $11) (param $super (ref $super)) (param $sub.desc (ref $sub.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l (ref $super) (ref $sub) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l (ref $super) (ref $sub) ;; CHECK-NEXT: (local.get $super) ;; CHECK-NEXT: (local.get $sub.desc) ;; CHECK-NEXT: ) @@ -228,7 +228,7 @@ (drop ;; We do not know anything about the result of this cast and cannot ;; optimize. - (br_on_cast_desc_fail $l anyref (ref $sub) + (br_on_cast_desc_eq_fail $l anyref (ref $sub) (local.get $super) (local.get $sub.desc) ) @@ -249,7 +249,7 @@ (block $l (result anyref) (drop ;; The cast cannot be reached, so we can optimize it out entirely. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (local.get $uninhabitable) (local.get $super.desc) ) @@ -284,7 +284,7 @@ (block $l (result anyref) (drop ;; Same, but now there are effects we must preserve. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (block (result (ref none)) (call $effect) (local.get $uninhabitable) @@ -311,7 +311,7 @@ (block $l (result anyref) (drop ;; The cast cannot be reached, so we can optimize it out entirely. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (local.get $uninhabitable) (local.get $super.desc) ) @@ -346,7 +346,7 @@ (block $l (result anyref) (drop ;; Same, but now there are effects we must preserve. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (block (result (ref none)) (call $effect) (local.get $uninhabitable) @@ -364,7 +364,7 @@ ;; CHECK: (func $cast-success-on-null (type $9) (param $other (ref null $other)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l (ref null $other) (ref null $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref null $other) (ref null $super) ;; CHECK-NEXT: (local.get $other) ;; CHECK-NEXT: (local.get $super.desc) ;; CHECK-NEXT: ) @@ -378,7 +378,7 @@ ;; We know the cast can only succeed if the value is null. We can ;; optimize to a branch on null in principle, but we do not do this yet ;; TODO. - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (local.get $other) (local.get $super.desc) ) @@ -407,7 +407,7 @@ (drop ;; We know the cast can only succeed if the value is null. We can ;; optimize to a branch on non-null. - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (local.get $other) (local.get $super.desc) ) @@ -442,7 +442,7 @@ (drop ;; Same as above, but now the descriptor is nullable so we have to ;; insert a ref.as_non_null to preserve the trap on a null descriptor. - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (local.get $other) (local.get $super.desc) ) @@ -484,7 +484,7 @@ (block $l (result anyref) (drop ;; Same, but now there are other effects we must preserve instead. - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (block (result (ref null $other)) (call $effect) (local.get $other) @@ -502,7 +502,7 @@ ;; CHECK: (func $cast-success-on-nonnull (type $12) (param $super (ref null $super)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc $l (ref null $super) (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l (ref null $super) (ref $super) ;; CHECK-NEXT: (local.get $super) ;; CHECK-NEXT: (local.get $super.desc) ;; CHECK-NEXT: ) @@ -515,7 +515,7 @@ (drop ;; We cannot replace this with a br_on_non_null because we would also ;; have to check that the descriptor values match. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (local.get $super) (local.get $super.desc) ) @@ -527,7 +527,7 @@ ;; CHECK: (func $fail-cast-success-on-nonnull (type $12) (param $super (ref null $super)) (param $super.desc (ref $super.desc)) (result anyref) ;; CHECK-NEXT: (block $l (result anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_desc_fail $l (ref null $super) (ref $super) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l (ref null $super) (ref $super) ;; CHECK-NEXT: (local.get $super) ;; CHECK-NEXT: (local.get $super.desc) ;; CHECK-NEXT: ) @@ -540,7 +540,7 @@ (drop ;; We cannot replace this with a br_on_null because we would also have ;; to check that the descriptor values match. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (local.get $super) (local.get $super.desc) ) @@ -563,7 +563,7 @@ (block $l (result anyref) (drop ;; We know based on the types that the cast will fail. We can remove it. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (local.get $other) (local.get $super.desc) ) @@ -593,7 +593,7 @@ (drop ;; Same, but the descriptor is now nullable, so we need to insert a ;; ref.as_non_null to preserve the trap on null descriptor. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (local.get $other) (local.get $super.desc) ) @@ -630,7 +630,7 @@ (block $l (result anyref) (drop ;; Same, but now there are other effects to preserve. - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (block (result (ref $other)) (call $effect) (local.get $other) @@ -662,7 +662,7 @@ (drop ;; We know based on the types that the cast will fail. We can replace it ;; with an unconditional branch. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (local.get $other) (local.get $super.desc) ) @@ -694,7 +694,7 @@ (drop ;; Same, but now the descriptor is nullable and we need to preserve the ;; trap on null descriptor. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (local.get $other) (local.get $super.desc) ) @@ -733,7 +733,7 @@ (block $l (result anyref) (drop ;; Same, but now there are other effects to preserve. - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (block (result (ref $other)) (call $effect) (local.get $other) @@ -767,7 +767,7 @@ (block $block (result anyref) ;; 3) ReFinalize will make this unreachable BrOn a block. The ref.null ;; below needs to be dropped for the block to be valid. - (br_on_cast_desc $block nullref (ref null $super) + (br_on_cast_desc_eq $block nullref (ref null $super) (ref.null none) ;; 2) ReFinalize will make this block unreachable because it is no ;; longer a branch target. diff --git a/test/lit/passes/type-merging-desc.wast b/test/lit/passes/type-merging-desc.wast index fa963b6eba7..5b950873254 100644 --- a/test/lit/passes/type-merging-desc.wast +++ b/test/lit/passes/type-merging-desc.wast @@ -269,14 +269,14 @@ ;; CHECK: (global $B.desc (ref null $B.desc) (ref.null none)) (global $B.desc (ref null $B.desc) (ref.null none)) - ;; CHECK: (func $cast-desc (type $4) + ;; CHECK: (func $cast-desc-eq (type $4) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref (exact $B.desc)) ;; CHECK-NEXT: (struct.new_default $B.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc + (func $cast-desc-eq (drop (ref.test (ref $B.desc) (struct.new $B.desc) @@ -312,14 +312,14 @@ ;; CHECK: (global $B.desc (ref null $B.desc) (ref.null none)) (global $B.desc (ref null $B.desc) (ref.null none)) - ;; CHECK: (func $cast-desc (type $4) + ;; CHECK: (func $cast-desc-eq (type $4) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref (exact $A.desc)) ;; CHECK-NEXT: (struct.new_default $A.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc + (func $cast-desc-eq (drop (ref.test (ref (exact $A.desc)) (struct.new $A.desc) @@ -352,14 +352,14 @@ ;; CHECK: (global $B.desc (ref null $A.desc) (ref.null none)) (global $B.desc (ref null $B.desc) (ref.null none)) - ;; CHECK: (func $cast-desc (type $2) (param $0 anyref) + ;; CHECK: (func $cast-desc-eq (type $2) (param $0 anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.test (ref $A.desc) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $cast-desc (param anyref) + (func $cast-desc-eq (param anyref) (drop (ref.test (ref $A.desc) (local.get 0) diff --git a/test/lit/passes/unsubtyping-desc.wast b/test/lit/passes/unsubtyping-desc.wast index 5407da2f971..214357b81fb 100644 --- a/test/lit/passes/unsubtyping-desc.wast +++ b/test/lit/passes/unsubtyping-desc.wast @@ -385,7 +385,7 @@ ) ) -;; ref.cast_desc requires a descriptor and also still affects subtyping like a +;; ref.cast_desc_eq requires a descriptor and also still affects subtyping like a ;; normal cast. (module (rec @@ -407,17 +407,17 @@ ;; CHECK-NEXT: )) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $ref.cast_desc (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) + ;; CHECK: (func $ref.cast_desc_eq (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null $top) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null $top) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref.cast_desc (param $any anyref) (param $top.desc (ref $top.desc)) + (func $ref.cast_desc_eq (param $any anyref) (param $top.desc (ref $top.desc)) (drop - (ref.cast_desc (ref null $top) + (ref.cast_desc_eq (ref null $top) (local.get $any) (local.get $top.desc) ) @@ -425,7 +425,7 @@ ) ) -;; If the ref.cast_desc is exact, then it doesn't need to transitively require +;; If the ref.cast_desc_eq is exact, then it doesn't need to transitively require ;; any subtypings except that the cast destination is a subtype of the cast ;; source. (module @@ -445,18 +445,18 @@ ;; CHECK: (global $bot-sub-any anyref (struct.new_default $bot)) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $ref.cast_desc (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) + ;; CHECK: (func $ref.cast_desc_eq (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null (exact $top)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null (exact $top)) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref.cast_desc (param $any anyref) (param $top.desc (ref (exact $top.desc))) + (func $ref.cast_desc_eq (param $any anyref) (param $top.desc (ref (exact $top.desc))) (drop ;; This is now exact. - (ref.cast_desc (ref null (exact $top)) + (ref.cast_desc_eq (ref null (exact $top)) (local.get $any) (local.get $top.desc) ) @@ -464,7 +464,7 @@ ) ) -;; br_on_cast_desc requires a descriptor and also still affects subtyping like a +;; br_on_cast_desc_eq requires a descriptor and also still affects subtyping like a ;; normal cast. (module (rec @@ -486,20 +486,20 @@ ;; CHECK-NEXT: )) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $br_on_cast_desc (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) + ;; CHECK: (func $br_on_cast_desc_eq (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result anyref) - ;; CHECK-NEXT: (br_on_cast_desc $l anyref (ref null $top) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l anyref (ref null $top) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_desc (param $any anyref) (param $top.desc (ref $top.desc)) + (func $br_on_cast_desc_eq (param $any anyref) (param $top.desc (ref $top.desc)) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $top) + (br_on_cast_desc_eq $l anyref (ref null $top) (local.get $any) (local.get $top.desc) ) @@ -508,7 +508,7 @@ ) ) -;; If the br_on_cast_desc is exact, then it doesn't need to transitively require +;; If the br_on_cast_desc_eq is exact, then it doesn't need to transitively require ;; any subtypings except that the cast destination is a subtype of the cast ;; source. (module @@ -528,21 +528,21 @@ ;; CHECK: (global $bot-sub-any anyref (struct.new_default $bot)) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $br_on_cast_desc (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) + ;; CHECK: (func $br_on_cast_desc_eq (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result anyref) - ;; CHECK-NEXT: (br_on_cast_desc $l anyref (ref null (exact $top)) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l anyref (ref null (exact $top)) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_desc (param $any anyref) (param $top.desc (ref (exact $top.desc))) + (func $br_on_cast_desc_eq (param $any anyref) (param $top.desc (ref (exact $top.desc))) (drop (block $l (result anyref) ;; This is now exact. - (br_on_cast_desc $l anyref (ref null (exact $top)) + (br_on_cast_desc_eq $l anyref (ref null (exact $top)) (local.get $any) (local.get $top.desc) ) @@ -551,7 +551,7 @@ ) ) -;; br_on_cast_desc_fail requires a descriptor and also still affects subtyping +;; br_on_cast_desc_eq_fail requires a descriptor and also still affects subtyping ;; like a normal cast. (module (rec @@ -573,20 +573,20 @@ ;; CHECK-NEXT: )) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $br_on_cast_desc_fail (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) + ;; CHECK: (func $br_on_cast_desc_eq_fail (type $4) (param $any anyref) (param $top.desc (ref $top.desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result anyref) - ;; CHECK-NEXT: (br_on_cast_desc_fail $l anyref (ref null $top) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref null $top) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_desc_fail (param $any anyref) (param $top.desc (ref $top.desc)) + (func $br_on_cast_desc_eq_fail (param $any anyref) (param $top.desc (ref $top.desc)) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $top) + (br_on_cast_desc_eq_fail $l anyref (ref null $top) (local.get $any) (local.get $top.desc) ) @@ -595,7 +595,7 @@ ) ) -;; If the br_on_cast_desc_fail is exact, then it doesn't need to transitively +;; If the br_on_cast_desc_eq_fail is exact, then it doesn't need to transitively ;; require any subtypings except that the cast destination is a subtype of the ;; cast source. (module @@ -615,21 +615,21 @@ ;; CHECK: (global $bot-sub-any anyref (struct.new_default $bot)) (global $bot-sub-any anyref (struct.new_desc $bot (struct.new $bot.desc))) - ;; CHECK: (func $br_on_cast_desc_fail (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) + ;; CHECK: (func $br_on_cast_desc_eq_fail (type $3) (param $any anyref) (param $top.desc (ref (exact $top.desc))) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result anyref) - ;; CHECK-NEXT: (br_on_cast_desc_fail $l anyref (ref null (exact $top)) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref null (exact $top)) ;; CHECK-NEXT: (local.get $any) ;; CHECK-NEXT: (local.get $top.desc) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $br_on_cast_desc_fail (param $any anyref) (param $top.desc (ref (exact $top.desc))) + (func $br_on_cast_desc_eq_fail (param $any anyref) (param $top.desc (ref (exact $top.desc))) (drop (block $l (result anyref) ;; This is now exact. - (br_on_cast_desc_fail $l anyref (ref null (exact $top)) + (br_on_cast_desc_eq_fail $l anyref (ref null (exact $top)) (local.get $any) (local.get $top.desc) ) @@ -1225,7 +1225,7 @@ ;; CHECK-NEXT: (local $struct (ref $struct)) ;; CHECK-NEXT: (local $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref (exact $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref (exact $struct)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: (struct.new_default $desc) ;; CHECK-NEXT: ) @@ -1235,7 +1235,7 @@ (local $struct (ref $struct)) (local $desc (ref $desc)) (drop - (ref.cast_desc (ref $struct) + (ref.cast_desc_eq (ref $struct) (unreachable) (struct.new $desc) ) diff --git a/test/lit/passes/vacuum-desc.wast b/test/lit/passes/vacuum-desc.wast index 4c89a5fc396..37a7efdde26 100644 --- a/test/lit/passes/vacuum-desc.wast +++ b/test/lit/passes/vacuum-desc.wast @@ -113,7 +113,7 @@ ;; CKTNH-NEXT: ) (func $cast-null-desc (param $ref anyref) (param $desc nullref) (drop - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -122,7 +122,7 @@ ;; CHECK: (func $cast-nullable-desc (type $3) (param $ref anyref) (param $desc (ref null $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null $struct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -136,7 +136,7 @@ ;; CKTNH-NEXT: ) (func $cast-nullable-desc (param $ref anyref) (param $desc (ref null $desc)) (drop - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -145,7 +145,7 @@ ;; CHECK: (func $cast-non-nullable-desc (type $4) (param $ref anyref) (param $desc (ref $desc)) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_desc (ref null $struct) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref null $struct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -160,7 +160,7 @@ (func $cast-non-nullable-desc (param $ref anyref) (param $desc (ref $desc)) (drop ;; The cast can still trap on failure, so by default we cannot remove it. - (ref.cast_desc (ref null $struct) + (ref.cast_desc_eq (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -203,7 +203,7 @@ (func $br-on-cast-null-desc (param $ref anyref) (param $desc nullref) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $struct) + (br_on_cast_desc_eq $l anyref (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -214,7 +214,7 @@ ;; CHECK: (func $br-on-cast-nullable-desc (type $3) (param $ref anyref) (param $desc (ref null $desc)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block $l (result anyref) - ;; CHECK-NEXT: (br_on_cast_desc $l anyref (ref null $struct) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l anyref (ref null $struct) ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (local.get $desc) ;; CHECK-NEXT: ) @@ -230,7 +230,7 @@ (func $br-on-cast-nullable-desc (param $ref anyref) (param $desc (ref null $desc)) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $struct) + (br_on_cast_desc_eq $l anyref (ref null $struct) (local.get $ref) (local.get $desc) ) @@ -250,7 +250,7 @@ (func $br-on-cast-non-nullable-desc (param $ref anyref) (param $desc (ref $desc)) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $struct) + (br_on_cast_desc_eq $l anyref (ref null $struct) (local.get $ref) (local.get $desc) ) diff --git a/test/lit/ref-cast-desc.wast b/test/lit/ref-cast-desc.wast new file mode 100644 index 00000000000..490ada02bda --- /dev/null +++ b/test/lit/ref-cast-desc.wast @@ -0,0 +1,62 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt -all %s -S -o - | filecheck %s + +;; Check that we still parse the deprecated instruction mnemonics for descriptor +;; casts + +(module + (rec + ;; CHECK: (rec + ;; CHECK-NEXT: (type $struct (descriptor $desc) (struct)) + (type $struct (descriptor $desc) (struct)) + ;; CHECK: (type $desc (describes $struct) (struct)) + (type $desc (describes $struct) (struct)) + ) + + ;; CHECK: (func $ref-cast-desc (type $3) (param $0 anyref) (param $1 (ref $desc)) (result (ref $struct)) + ;; CHECK-NEXT: (ref.cast_desc_eq (ref $struct) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $ref-cast-desc (param anyref) (param (ref $desc)) (result (ref $struct)) + (ref.cast_desc (ref $struct) + (local.get 0) + (local.get 1) + ) + ) + + ;; CHECK: (func $br-on-cast-desc (type $2) (param $0 anyref) (param $1 (ref $desc)) (result anyref) + ;; CHECK-NEXT: (block $l (result anyref) + ;; CHECK-NEXT: (br_on_cast_desc_eq $l anyref (ref $struct) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $br-on-cast-desc (param anyref) (param (ref $desc)) (result anyref) + (block $l (result anyref) + (br_on_cast_desc $l anyref (ref $struct) + (local.get 0) + (local.get 1) + ) + ) + ) + + ;; CHECK: (func $br-on-cast-desc_fail (type $2) (param $0 anyref) (param $1 (ref $desc)) (result anyref) + ;; CHECK-NEXT: (block $l (result anyref) + ;; CHECK-NEXT: (br_on_cast_desc_eq_fail $l anyref (ref $struct) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $br-on-cast-desc_fail (param anyref) (param (ref $desc)) (result anyref) + (block $l (result anyref) + (br_on_cast_desc_fail $l anyref (ref $struct) + (local.get 0) + (local.get 1) + ) + ) + ) +) diff --git a/test/spec/br_on_cast_desc.wast b/test/spec/br_on_cast_desc_eq.wast similarity index 75% rename from test/spec/br_on_cast_desc.wast rename to test/spec/br_on_cast_desc_eq.wast index 0b9bf094860..c40653b753a 100644 --- a/test/spec/br_on_cast_desc.wast +++ b/test/spec/br_on_cast_desc_eq.wast @@ -14,27 +14,27 @@ (global $sub.desc (ref (exact $sub.desc)) (struct.new $sub.desc)) (global $sub (ref $sub) (struct.new_desc $sub (global.get $sub.desc))) - ;; br_on_cast_desc + ;; br_on_cast_desc_eq - (func $br_on_cast_desc-unreachable (result anyref) + (func $br_on_cast_desc_eq-unreachable (result anyref) (unreachable) - (br_on_cast_desc 0 anyref (ref null $super)) + (br_on_cast_desc_eq 0 anyref (ref null $super)) ) - (func $br_on_cast_desc-null (param anyref) (result anyref) - (br_on_cast_desc 0 anyref (ref null $super) + (func $br_on_cast_desc_eq-null (param anyref) (result anyref) + (br_on_cast_desc_eq 0 anyref (ref null $super) (ref.null none) (ref.null none) ) ) - (func $br_on_cast_desc-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) - (br_on_cast_desc 0 (ref null $sub) (ref null $super) + (func $br_on_cast_desc_eq-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) + (br_on_cast_desc_eq 0 (ref null $sub) (ref null $super) (local.get $sub) (local.get $super.desc) ) ) - (func $br_on_cast_desc-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) + (func $br_on_cast_desc_eq-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) ;; The sent type is exact because the descriptor is exact. - (br_on_cast_desc 0 anyref (ref null $super) + (br_on_cast_desc_eq 0 anyref (ref null $super) (local.get $any) (local.get $super.desc) ) @@ -43,7 +43,7 @@ (func (export "cast-success") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (global.get $super1) (global.get $super.desc1) ) @@ -55,7 +55,7 @@ (func (export "cast-success-supertype") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (global.get $sub) (global.get $sub.desc) ) @@ -67,7 +67,7 @@ (func (export "cast-success-null") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (ref.null none) (global.get $super.desc1) ) @@ -79,7 +79,7 @@ (func (export "cast-fail-null") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref $super) + (br_on_cast_desc_eq $l anyref (ref $super) (ref.null none) (global.get $super.desc1) ) @@ -91,7 +91,7 @@ (func (export "cast-fail-wrong-desc") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (global.get $super1) (global.get $super.desc2) ) @@ -103,7 +103,7 @@ (func (export "cast-fail-null-desc") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc $l anyref (ref null $super) + (br_on_cast_desc_eq $l anyref (ref null $super) (global.get $super1) (ref.null none) ) @@ -113,28 +113,28 @@ (i32.const 1) ) - ;; br_on_cast_desc_fail + ;; br_on_cast_desc_eq_fail - (func $br_on_cast_desc_fail-unreachable (result anyref) + (func $br_on_cast_desc_eq_fail-unreachable (result anyref) (unreachable) - (br_on_cast_desc_fail 0 anyref (ref null $super)) + (br_on_cast_desc_eq_fail 0 anyref (ref null $super)) ) - (func $br_on_cast_desc_fail-null (param anyref) (result anyref) - (br_on_cast_desc_fail 0 anyref (ref null $super) + (func $br_on_cast_desc_eq_fail-null (param anyref) (result anyref) + (br_on_cast_desc_eq_fail 0 anyref (ref null $super) (ref.null none) (ref.null none) ) ) - (func $br_on_cast_desc_fail-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) - (br_on_cast_desc_fail 0 (ref null $sub) (ref null $super) + (func $br_on_cast_desc_eq_fail-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) + (br_on_cast_desc_eq_fail 0 (ref null $sub) (ref null $super) (local.get $sub) (local.get $super.desc) ) ) - (func $br_on_cast_desc_fail-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result anyref) + (func $br_on_cast_desc_eq_fail-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result anyref) (block (result (ref null (exact $super))) ;; The result type can be exact because the descriptor is exact. - (br_on_cast_desc_fail 1 anyref (ref null (exact $super)) + (br_on_cast_desc_eq_fail 1 anyref (ref null (exact $super)) (local.get $any) (local.get $super.desc) ) @@ -143,7 +143,7 @@ (func (export "fail-cast-success") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (global.get $super1) (global.get $super.desc1) ) @@ -155,7 +155,7 @@ (func (export "fail-cast-success-supertype") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (global.get $sub) (global.get $sub.desc) ) @@ -167,7 +167,7 @@ (func (export "fail-cast-success-null") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (ref.null none) (global.get $super.desc1) ) @@ -179,7 +179,7 @@ (func (export "fail-cast-fail-null") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref $super) + (br_on_cast_desc_eq_fail $l anyref (ref $super) (ref.null none) (global.get $super.desc1) ) @@ -191,7 +191,7 @@ (func (export "fail-cast-fail-wrong-desc") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (global.get $super1) (global.get $super.desc2) ) @@ -203,7 +203,7 @@ (func (export "fail-cast-fail-null-desc") (result i32) (drop (block $l (result anyref) - (br_on_cast_desc_fail $l anyref (ref null $super) + (br_on_cast_desc_eq_fail $l anyref (ref null $super) (global.get $super1) (ref.null none) ) @@ -229,25 +229,25 @@ (assert_malformed ;; Input type must be a reference. - (module quote "(module (rec (type $struct (descriptor $desc) (struct)) (type $desc (describes $struct) (struct))) (func (result anyref) (unreachable) (br_on_cast_desc 0 i32 (ref null $struct))))") + (module quote "(module (rec (type $struct (descriptor $desc) (struct)) (type $desc (describes $struct) (struct))) (func (result anyref) (unreachable) (br_on_cast_desc_eq 0 i32 (ref null $struct))))") "expected reftype" ) (assert_malformed ;; Input type must be a reference. - (module quote "(module (rec (type $struct (descriptor $desc) (struct)) (type $desc (describes $struct) (struct))) (func (result anyref) (unreachable) (br_on_cast_desc_fail 0 i32 (ref null $struct))))") + (module quote "(module (rec (type $struct (descriptor $desc) (struct)) (type $desc (describes $struct) (struct))) (func (result anyref) (unreachable) (br_on_cast_desc_eq_fail 0 i32 (ref null $struct))))") "expected reftype" ) (assert_malformed ;; Cast type must be a reference. - (module quote "(module (func (unreachable) (br_on_cast_desc 0 anyref i32) (unreachable)))") + (module quote "(module (func (unreachable) (br_on_cast_desc_eq 0 anyref i32) (unreachable)))") "expected reftype" ) (assert_malformed ;; Cast type must be a reference. - (module quote "(module (func (unreachable) (br_on_cast_desc_fail 0 anyref i32) (unreachable)))") + (module quote "(module (func (unreachable) (br_on_cast_desc_eq_fail 0 anyref i32) (unreachable)))") "expected reftype" ) @@ -257,7 +257,7 @@ (func (result anyref) (unreachable) ;; Cannot do a descriptor cast to a type without a descriptor. - (br_on_cast_desc 0 anyref (ref null 0)) + (br_on_cast_desc_eq 0 anyref (ref null 0)) ) ) "cast target must have descriptor" @@ -269,7 +269,7 @@ (func (result anyref) (unreachable) ;; Cannot do a descriptor cast to a type without a descriptor. - (br_on_cast_desc_fail 0 anyref (ref null 0)) + (br_on_cast_desc_eq_fail 0 anyref (ref null 0)) ) ) "cast target must have descriptor" @@ -282,7 +282,7 @@ (type (describes 0 (struct))) ) (func (param anyref) (result anyref) - (br_on_cast_desc 0 eqref (ref null 0) + (br_on_cast_desc_eq 0 eqref (ref null 0) ;; This should be an eqref but is an anyref. (local.get 0) (ref.null none) @@ -299,7 +299,7 @@ (type $desc (describes $struct) (struct)) ) (func (param anyref) (result anyref) - (br_on_cast_desc_fail 0 eqref (ref null $struct) + (br_on_cast_desc_eq_fail 0 eqref (ref null $struct) ;; This should be an eqref but is an anyref. (local.get 0) (ref.null none) @@ -319,7 +319,7 @@ (type $sub.desc (sub $super.desc (describes $sub) (struct))) ) (func (param $any anyref) (param $super.desc (ref null $super.desc)) (result anyref) - (br_on_cast_desc 0 anyref (ref null $sub) + (br_on_cast_desc_eq 0 anyref (ref null $sub) (local.get $any) ;; This should be a $sub.desc but it is a $super.desc. (local.get $super.desc) @@ -339,7 +339,7 @@ (type $sub.desc (sub $super.desc (describes $sub) (struct))) ) (func (param $any anyref) (param $super.desc (ref null $super.desc)) (result anyref) - (br_on_cast_desc_fail 0 anyref (ref null $sub) + (br_on_cast_desc_eq_fail 0 anyref (ref null $sub) (local.get $any) ;; This should be a $sub.desc but it is a $super.desc. (local.get $super.desc) @@ -357,7 +357,7 @@ ) (func (param $any anyref) (param $desc (ref null $desc)) (result (ref null (exact $struct))) ;; The sent type cannnot be exact because the descriptor is not exact. - (br_on_cast_desc 0 anyref (ref null $struct) + (br_on_cast_desc_eq 0 anyref (ref null $struct) (local.get $any) (local.get $desc) ) @@ -376,7 +376,7 @@ (func (param $any anyref) (param $desc (ref null $desc)) (result anyref) (block (result (ref null (exact $struct))) ;; The result type can be exact because the descriptor is exact. - (br_on_cast_desc_fail 1 anyref (ref null (exact $struct)) + (br_on_cast_desc_eq_fail 1 anyref (ref null (exact $struct)) (local.get $any) (local.get $desc) ) diff --git a/test/spec/ref.cast_desc.wast b/test/spec/ref.cast_desc_eq.wast similarity index 74% rename from test/spec/ref.cast_desc.wast rename to test/spec/ref.cast_desc_eq.wast index 2211f300c2c..f04b48585ed 100644 --- a/test/spec/ref.cast_desc.wast +++ b/test/spec/ref.cast_desc_eq.wast @@ -14,34 +14,34 @@ (global $sub.desc (ref (exact $sub.desc)) (struct.new $sub.desc)) (global $sub (ref $sub) (struct.new_desc $sub (global.get $sub.desc))) - ;; ref.cast_desc (ref null ht) + ;; ref.cast_desc_eq (ref null ht) - (func $ref.cast_desc-null-unreachable (result anyref) + (func $ref.cast_desc_eq-null-unreachable (result anyref) (unreachable) - (ref.cast_desc (ref null $super)) + (ref.cast_desc_eq (ref null $super)) ) - (func $ref.cast_desc-null-null (param anyref) (result anyref) - (ref.cast_desc (ref null $super) + (func $ref.cast_desc_eq-null-null (param anyref) (result anyref) + (ref.cast_desc_eq (ref null $super) (ref.null none) (ref.null none) ) ) - (func $ref.cast_desc-null-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) - (ref.cast_desc (ref null $super) + (func $ref.cast_desc_eq-null-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) + (ref.cast_desc_eq (ref null $super) (local.get $sub) (local.get $super.desc) ) ) - (func $ref.cast_desc-null-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) + (func $ref.cast_desc_eq-null-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) ;; The cast type is exact because the descriptor is exact. - (ref.cast_desc (ref null (exact $super)) + (ref.cast_desc_eq (ref null (exact $super)) (local.get $any) (local.get $super.desc) ) ) (func (export "cast-success") (drop - (ref.cast_desc (ref null $super) + (ref.cast_desc_eq (ref null $super) (global.get $super1) (global.get $super.desc1) ) @@ -49,7 +49,7 @@ ) (func (export "cast-success-supertype") (drop - (ref.cast_desc (ref null $super) + (ref.cast_desc_eq (ref null $super) (global.get $sub) (global.get $sub.desc) ) @@ -57,7 +57,7 @@ ) (func (export "cast-success-null") (drop - (ref.cast_desc (ref null $super) + (ref.cast_desc_eq (ref null $super) (ref.null none) (global.get $super.desc1) ) @@ -65,7 +65,7 @@ ) (func (export "cast-fail-wrong-desc") (drop - (ref.cast_desc (ref null $super) + (ref.cast_desc_eq (ref null $super) (global.get $super1) (global.get $super.desc2) ) @@ -73,41 +73,41 @@ ) (func (export "cast-fail-null-desc") (drop - (ref.cast_desc (ref null $super) + (ref.cast_desc_eq (ref null $super) (global.get $super1) (ref.null none) ) ) ) - ;; ref.cast_desc (ref ht) + ;; ref.cast_desc_eq (ref ht) - (func $ref.cast_desc-nn-unreachable (result anyref) + (func $ref.cast_desc_eq-nn-unreachable (result anyref) (unreachable) - (ref.cast_desc (ref $super)) + (ref.cast_desc_eq (ref $super)) ) - (func $ref.cast_desc-nn-null (param anyref) (result anyref) - (ref.cast_desc (ref $super) + (func $ref.cast_desc_eq-nn-null (param anyref) (result anyref) + (ref.cast_desc_eq (ref $super) (ref.null none) (ref.null none) ) ) - (func $ref.cast_desc-nn-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) - (ref.cast_desc (ref $super) + (func $ref.cast_desc_eq-nn-upcast (param $sub (ref null $sub)) (param $super.desc (ref null $super.desc)) (result (ref null $super)) + (ref.cast_desc_eq (ref $super) (local.get $sub) (local.get $super.desc) ) ) - (func $ref.cast_desc-nn-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) + (func $ref.cast_desc_eq-nn-exact (param $any anyref) (param $super.desc (ref null (exact $super.desc))) (result (ref null (exact $super))) ;; The cast type is exact because the descriptor is exact. - (ref.cast_desc (ref (exact $super)) + (ref.cast_desc_eq (ref (exact $super)) (local.get $any) (local.get $super.desc) ) ) (func (export "cast-nn-success") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (global.get $super1) (global.get $super.desc1) ) @@ -115,7 +115,7 @@ ) (func (export "cast-nn-success-supertype") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (global.get $sub) (global.get $sub.desc) ) @@ -123,7 +123,7 @@ ) (func (export "cast-nn-fail-null") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (ref.null none) (global.get $super.desc1) ) @@ -131,7 +131,7 @@ ) (func (export "cast-nn-fail-wrong-desc") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (global.get $super1) (global.get $super.desc2) ) @@ -139,7 +139,7 @@ ) (func (export "cast-nn-fail-null-desc") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (global.get $super1) (ref.null none) ) @@ -148,7 +148,7 @@ (func (export "cast-branch-ref") (result i32) (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (return (i32.const 1)) (ref.null none) ) @@ -157,7 +157,7 @@ ) (func (export "cast-branch-desc") (result i32) (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (ref.null none) (return (i32.const 1)) ) @@ -167,7 +167,7 @@ (func (export "cast-i31ref") (drop - (ref.cast_desc (ref $super) + (ref.cast_desc_eq (ref $super) (ref.i31 (i32.const 0)) (struct.new $super.desc) ) @@ -191,7 +191,7 @@ (assert_malformed ;; Cast type must be a reference. - (module quote "(module (func (unreachable) (ref.cast_desc i32) (unreachable)))") + (module quote "(module (func (unreachable) (ref.cast_desc_eq i32) (unreachable)))") "expected reftype" ) @@ -201,7 +201,7 @@ (func (result anyref) (unreachable) ;; Cannot do a descriptor cast to a type without a descriptor. - (ref.cast_desc (ref null 0)) + (ref.cast_desc_eq (ref null 0)) ) ) "cast target must have descriptor" @@ -213,7 +213,7 @@ (func (result anyref) (unreachable) ;; Cannot do a descriptor cast to a type without a descriptor. - (ref.cast_desc (ref 0)) + (ref.cast_desc_eq (ref 0)) ) ) "cast target must have descriptor" @@ -229,7 +229,7 @@ (type $sub.desc (sub $super.desc (describes $sub) (struct))) ) (func (param $super.desc (ref null $super.desc)) (result anyref) - (ref.cast_desc (ref null $sub) + (ref.cast_desc_eq (ref null $sub) (local.get 0) ;; This should be a $sub.desc but it is a $super.desc. (local.get $super.desc) @@ -249,7 +249,7 @@ (type $sub.desc (sub $super.desc (describes $sub) (struct))) ) (func (param $super.desc (ref null $super.desc)) (result anyref) - (ref.cast_desc (ref $sub) + (ref.cast_desc_eq (ref $sub) (local.get 0) ;; This should be a $sub.desc but it is a $super.desc. (local.get $super.desc) @@ -267,7 +267,7 @@ ) (func (param $any anyref) (param $desc (ref null $desc)) (result anyref) ;; The cast type cannot be exact because the descriptor is not exact. - (ref.cast_desc (ref null (exact $struct)) + (ref.cast_desc_eq (ref null (exact $struct)) (local.get $any) (local.get $desc) ) @@ -284,7 +284,7 @@ ) (func (param $any anyref) (param $desc (ref null $desc)) (result anyref) ;; The cast type cannot be exact because the descriptor is not exact. - (ref.cast_desc (ref (exact $struct)) + (ref.cast_desc_eq (ref (exact $struct)) (local.get $any) (local.get $desc) )