diff options
43 files changed, 719 insertions, 606 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 608d1359f..f4a008bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Current Trunk argument `optimize`. (#4832) - Remove support for the `let` instruction that has been removed from the typed function references spec. +- HeapType::ext has been restored but is no longer a subtype of HeapType::any to + match the latest updates in the GC spec. (#4898) v109 ---- diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 869f3a92a..95569adfd 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -58,10 +58,11 @@ BinaryenLiteral toBinaryenLiteral(Literal x) { case HeapType::func: ret.func = x.isNull() ? nullptr : x.getFunc().c_str(); break; - case HeapType::any: + case HeapType::ext: case HeapType::eq: assert(x.isNull() && "unexpected non-null reference type literal"); break; + case HeapType::any: case HeapType::i31: case HeapType::data: case HeapType::string: @@ -113,6 +114,7 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) { case HeapType::data: assert(false && "Literals must have concrete types"); WASM_UNREACHABLE("no fallthrough here"); + case HeapType::ext: case HeapType::i31: case HeapType::string: case HeapType::stringview_wtf8: @@ -158,7 +160,6 @@ extern "C" { // // Core types -// TODO: Deprecate BinaryenTypeExternref? BinaryenType BinaryenTypeNone(void) { return Type::none; } BinaryenType BinaryenTypeInt32(void) { return Type::i32; } @@ -170,7 +171,7 @@ BinaryenType BinaryenTypeFuncref(void) { return Type(HeapType::func, Nullable).getID(); } BinaryenType BinaryenTypeExternref(void) { - return Type(HeapType::any, Nullable).getID(); + return Type(HeapType::ext, Nullable).getID(); } BinaryenType BinaryenTypeAnyref(void) { return Type(HeapType::any, Nullable).getID(); @@ -239,6 +240,9 @@ BinaryenPackedType BinaryenPackedTypeInt16(void) { // Heap types +BinaryenHeapType BinaryenHeapTypeExt() { + return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::ext); +} BinaryenHeapType BinaryenHeapTypeFunc() { return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::func); } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index f5bb71eb9..f9d78e8c9 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -137,6 +137,7 @@ BINARYEN_API BinaryenPackedType BinaryenPackedTypeInt16(void); typedef uintptr_t BinaryenHeapType; +BINARYEN_API BinaryenHeapType BinaryenHeapTypeExt(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeFunc(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeAny(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeEq(void); diff --git a/src/ir/possible-constant.h b/src/ir/possible-constant.h index b3272461d..21f1cfa65 100644 --- a/src/ir/possible-constant.h +++ b/src/ir/possible-constant.h @@ -114,8 +114,14 @@ public: auto type = getConstantLiteral().type.getHeapType(); auto otherType = other.getConstantLiteral().type.getHeapType(); auto lub = HeapType::getLeastUpperBound(type, otherType); - if (lub != type) { - value = Literal::makeNull(lub); + if (!lub) { + // TODO: Remove this workaround once we have bottom types to assign to + // null literals. + value = Many(); + return true; + } + if (*lub != type) { + value = Literal::makeNull(*lub); return true; } return false; diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 7079a9446..d9c608bda 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -56,7 +56,13 @@ void PossibleContents::combine(const PossibleContents& other) { assert(other.isNull()); auto lub = HeapType::getLeastUpperBound(type.getHeapType(), otherType.getHeapType()); - value = Literal::makeNull(lub); + if (!lub) { + // TODO: Remove this workaround once we have bottom types to assign to + // null literals. + value = Many(); + return; + } + value = Literal::makeNull(*lub); } return; } diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index 761aac2a9..311d4a27b 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -57,7 +57,7 @@ Name get_f32("get_f32"); Name get_f64("get_f64"); Name get_v128("get_v128"); Name get_funcref("get_funcref"); -Name get_anyref("get_anyref"); +Name get_externref("get_externref"); Name set_i32("set_i32"); Name set_i64("set_i64"); @@ -65,7 +65,7 @@ Name set_f32("set_f32"); Name set_f64("set_f64"); Name set_v128("set_v128"); Name set_funcref("set_funcref"); -Name set_anyref("set_anyref"); +Name set_externref("set_externref"); struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { void visitLocalGet(LocalGet* curr) { @@ -75,8 +75,8 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { auto heapType = curr->type.getHeapType(); if (heapType == HeapType::func && curr->type.isNullable()) { import = get_funcref; - } else if (heapType == HeapType::any && curr->type.isNullable()) { - import = get_anyref; + } else if (heapType == HeapType::ext && curr->type.isNullable()) { + import = get_externref; } else { WASM_UNREACHABLE("TODO: general reference types"); } @@ -128,8 +128,8 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { auto heapType = type.getHeapType(); if (heapType == HeapType::func && type.isNullable()) { import = set_funcref; - } else if (heapType == HeapType::any && type.isNullable()) { - import = set_anyref; + } else if (heapType == HeapType::ext && type.isNullable()) { + import = set_externref; } else { WASM_UNREACHABLE("TODO: general reference types"); } @@ -175,12 +175,12 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { if (curr->features.hasReferenceTypes()) { Type func = Type(HeapType::func, Nullable); - Type any = Type(HeapType::any, Nullable); + Type ext = Type(HeapType::ext, Nullable); addImport(curr, get_funcref, {Type::i32, Type::i32, func}, func); addImport(curr, set_funcref, {Type::i32, Type::i32, func}, func); - addImport(curr, get_anyref, {Type::i32, Type::i32, any}, any); - addImport(curr, set_anyref, {Type::i32, Type::i32, any}, any); + addImport(curr, get_externref, {Type::i32, Type::i32, ext}, ext); + addImport(curr, set_externref, {Type::i32, Type::i32, ext}, ext); } if (curr->features.hasSIMD()) { addImport(curr, get_v128, {Type::i32, Type::i32, Type::v128}, Type::v128); diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 87c33ed93..81ae1bfc6 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -88,6 +88,9 @@ static bool maybePrintRefShorthand(std::ostream& o, Type type) { if (heapType.isBasic()) { if (type.isNullable()) { switch (heapType.getBasic()) { + case HeapType::ext: + o << "externref"; + return true; case HeapType::func: o << "funcref"; return true; @@ -115,6 +118,7 @@ static bool maybePrintRefShorthand(std::ostream& o, Type type) { } } else { switch (heapType.getBasic()) { + case HeapType::ext: case HeapType::func: case HeapType::any: case HeapType::eq: diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index cdefe29f1..cc64b3b6a 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -1968,6 +1968,10 @@ Expression* TranslateToFuzzReader::makeConstBasicRef(Type type) { assert(heapType.isBasic()); assert(wasm.features.hasReferenceTypes()); switch (heapType.getBasic()) { + case HeapType::ext: { + assert(type.isNullable() && "Cannot handle non-nullable externref"); + return builder.makeRefNull(type); + } case HeapType::func: { return makeRefFuncConst(type); } @@ -3089,13 +3093,14 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) { case HeapType::func: // TODO: Typed function references. return HeapType::func; + case HeapType::ext: + return HeapType::ext; case HeapType::any: // TODO: nontrivial types as well. return pick( FeatureOptions<HeapType>() - .add(FeatureSet::ReferenceTypes, HeapType::func, HeapType::any) + .add(FeatureSet::ReferenceTypes, HeapType::func /*, HeapType::ext*/) .add(FeatureSet::ReferenceTypes | FeatureSet::GC, - HeapType::func, HeapType::any, HeapType::eq, HeapType::i31, diff --git a/src/tools/fuzzing/heap-types.cpp b/src/tools/fuzzing/heap-types.cpp index 364065b8b..5a8f0fc0e 100644 --- a/src/tools/fuzzing/heap-types.cpp +++ b/src/tools/fuzzing/heap-types.cpp @@ -153,6 +153,7 @@ struct HeapTypeGeneratorImpl { HeapType::BasicHeapType generateBasicHeapType() { return rand.pick(HeapType::func, + HeapType::ext, HeapType::any, HeapType::eq, HeapType::i31, @@ -278,6 +279,7 @@ struct HeapTypeGeneratorImpl { return type; } else { switch (type) { + case HeapType::ext: case HeapType::i31: // No other subtypes. return type; @@ -371,6 +373,8 @@ struct HeapTypeGeneratorImpl { // This is not a constructed type, so it must be a basic type. assert(type.isBasic()); switch (type.getBasic()) { + case HeapType::ext: + return HeapType::ext; case HeapType::func: return pickSubFunc(); case HeapType::any: @@ -477,16 +481,31 @@ struct HeapTypeGeneratorImpl { switch (*basic) { case HeapType::func: return SignatureKind{}; + case HeapType::ext: case HeapType::i31: return super; case HeapType::any: - return generateHeapTypeKind(); + if (rand.oneIn(4)) { + switch (rand.upTo(3)) { + case 0: + return HeapType::eq; + case 1: + return HeapType::i31; + case 2: + return HeapType::data; + } + } + return DataKind{}; case HeapType::eq: if (rand.oneIn(4)) { - return HeapType::i31; - } else { - return DataKind{}; + switch (rand.upTo(2)) { + case 0: + return HeapType::i31; + case 1: + return HeapType::data; + } } + return DataKind{}; case HeapType::data: return DataKind{}; case HeapType::string: diff --git a/src/tools/wasm-fuzz-types.cpp b/src/tools/wasm-fuzz-types.cpp index d80c89ea8..bbf4967e3 100644 --- a/src/tools/wasm-fuzz-types.cpp +++ b/src/tools/wasm-fuzz-types.cpp @@ -152,46 +152,72 @@ void Fuzzer::checkLUBs() const { HeapType a = types[i], b = types[j]; // Check that their LUB is stable when calculated multiple times and in // reverse order. - HeapType lub = HeapType::getLeastUpperBound(a, b); - if (lub != HeapType::getLeastUpperBound(b, a) || - lub != HeapType::getLeastUpperBound(a, b)) { - Fatal() << "Could not calculate a stable LUB of HeapTypes " << i - << " and " << j << "!\n" - << i << ": " << a << "\n" - << j << ": " << b << "\n"; - } - // Check that each type is a subtype of the LUB. - if (!HeapType::isSubType(a, lub)) { - Fatal() << "HeapType " << i - << " is not a subtype of its LUB with HeapType " << j << "!\n" - << i << ": " << a << "\n" - << j << ": " << b << "\n" - << "lub: " << lub << "\n"; - } - if (!HeapType::isSubType(b, lub)) { - Fatal() << "HeapType " << j - << " is not a subtype of its LUB with HeapType " << i << "!\n" - << i << ": " << a << "\n" - << j << ": " << b << "\n" - << "lub: " << lub << "\n"; - } - // Check that the LUB of each type and the original LUB is still the - // original LUB. - if (lub != HeapType::getLeastUpperBound(a, lub)) { - Fatal() << "The LUB of HeapType " << i << " and HeapType " << j - << " should be the LUB of itself and HeapType " << i - << ", but it is not!\n" - << i << ": " << a << "\n" - << j << ": " << b << "\n" - << "lub: " << lub << "\n"; - } - if (lub != HeapType::getLeastUpperBound(lub, b)) { - Fatal() << "The LUB of HeapType " << i << " and HeapType " << j - << " should be the LUB of itself and HeapType " << j - << ", but it is not!\n" - << i << ": " << a << "\n" - << j << ": " << b << "\n" - << "lub: " << lub << "\n"; + auto lub = HeapType::getLeastUpperBound(a, b); + if (lub) { + if (lub != HeapType::getLeastUpperBound(b, a) || + lub != HeapType::getLeastUpperBound(a, b)) { + Fatal() << "Could not calculate a stable LUB of HeapTypes " << i + << " and " << j << "!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n"; + } + // Check that each type is a subtype of the LUB. + if (!HeapType::isSubType(a, *lub)) { + Fatal() << "HeapType " << i + << " is not a subtype of its LUB with HeapType " << j << "!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n" + << "lub: " << *lub << "\n"; + } + if (!HeapType::isSubType(b, *lub)) { + Fatal() << "HeapType " << j + << " is not a subtype of its LUB with HeapType " << i << "!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n" + << "lub: " << *lub << "\n"; + } + // Check that the LUB of each type and the original LUB is still the + // original LUB. + if (lub != HeapType::getLeastUpperBound(a, *lub)) { + Fatal() << "The LUB of HeapType " << i << " and HeapType " << j + << " should be the LUB of itself and HeapType " << i + << ", but it is not!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n" + << "lub: " << *lub << "\n"; + } + if (lub != HeapType::getLeastUpperBound(*lub, b)) { + Fatal() << "The LUB of HeapType " << i << " and HeapType " << j + << " should be the LUB of itself and HeapType " << j + << ", but it is not!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n" + << "lub: " << *lub << "\n"; + } + } else { + // No LUB. Check that this is symmetrical. + if (auto lub2 = HeapType::getLeastUpperBound(b, a)) { + Fatal() << "There is no LUB of HeapType " << i << " and HeapType " + << j << ", but there is a LUB in the reverse direction!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n" + << "lub: " << *lub2 << "\n"; + } + // There also shouldn't be a subtype relation in this case. + if (HeapType::isSubType(a, b)) { + Fatal() << "There is no LUB of HeapType " << i << " and HeapType " + << j << ", but HeapType " << i << " is a subtype of HeapType " + << j << "!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n"; + } + if (HeapType::isSubType(b, a)) { + Fatal() << "There is no LUB of HeapType " << i << " and HeapType " + << j << ", but HeapType " << j << " is a subtype of HeapType " + << i << "!\n" + << i << ": " << a << "\n" + << j << ": " << b << "\n"; + } } } } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 9424f6fda..aef1767bb 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -363,8 +363,10 @@ enum EncodedType { i16 = -0x7, // 0x79 // function reference type funcref = -0x10, // 0x70 - // top type of references, including host references - anyref = -0x11, // 0x6f + // external (host) references + externref = -0x11, // 0x6f + // top type of references to non-function Wasm data. + anyref = -0x12, // 0x6e // comparable reference type eqref = -0x13, // 0x6d // nullable typed function reference type, with parameter @@ -396,7 +398,8 @@ enum EncodedType { enum EncodedHeapType { func = -0x10, // 0x70 - any = -0x11, // 0x6f + ext = -0x11, // 0x6f + any = -0x12, // 0x6e eq = -0x13, // 0x6d i31 = -0x16, // 0x6a data = -0x19, // 0x67 diff --git a/src/wasm-type.h b/src/wasm-type.h index 014e28646..7235cda8b 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -316,6 +316,7 @@ class HeapType { public: enum BasicHeapType : uint32_t { + ext, func, any, eq, @@ -398,8 +399,8 @@ public: // exists. std::vector<HeapType> getReferencedHeapTypes() const; - // Return the LUB of two HeapTypes. The LUB always exists. - static HeapType getLeastUpperBound(HeapType a, HeapType b); + // Return the LUB of two HeapTypes, which may or may not exist. + static std::optional<HeapType> getLeastUpperBound(HeapType a, HeapType b); // Helper allowing the value of `print(...)` to be sent to an ostream. Stores // a `TypeID` because `Type` is incomplete at this point and using a reference diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 05f9d93d5..684108581 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -101,6 +101,7 @@ Literal::Literal(const Literal& other) : type(other.type) { auto heapType = type.getHeapType(); if (heapType.isBasic()) { switch (heapType.getBasic()) { + case HeapType::ext: case HeapType::any: case HeapType::eq: return; // null @@ -464,6 +465,10 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { } } else { switch (literal.type.getHeapType().getBasic()) { + case HeapType::ext: + assert(literal.isNull() && "unexpected non-null externref literal"); + o << "externref(null)"; + break; case HeapType::any: assert(literal.isNull() && "unexpected non-null anyref literal"); o << "anyref(null)"; diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 7008d185c..fe827f291 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1368,6 +1368,9 @@ void WasmBinaryWriter::writeType(Type type) { auto heapType = type.getHeapType(); if (heapType.isBasic() && type.isNullable()) { switch (heapType.getBasic()) { + case HeapType::ext: + o << S32LEB(BinaryConsts::EncodedType::externref); + return; case HeapType::any: o << S32LEB(BinaryConsts::EncodedType::anyref); return; @@ -1443,6 +1446,9 @@ void WasmBinaryWriter::writeHeapType(HeapType type) { int ret = 0; if (type.isBasic()) { switch (type.getBasic()) { + case HeapType::ext: + ret = BinaryConsts::EncodedHeapType::ext; + break; case HeapType::func: ret = BinaryConsts::EncodedHeapType::func; break; @@ -1805,6 +1811,9 @@ bool WasmBinaryBuilder::getBasicType(int32_t code, Type& out) { case BinaryConsts::EncodedType::funcref: out = Type(HeapType::func, Nullable); return true; + case BinaryConsts::EncodedType::externref: + out = Type(HeapType::ext, Nullable); + return true; case BinaryConsts::EncodedType::anyref: out = Type(HeapType::any, Nullable); return true; @@ -1839,6 +1848,9 @@ bool WasmBinaryBuilder::getBasicHeapType(int64_t code, HeapType& out) { case BinaryConsts::EncodedHeapType::func: out = HeapType::func; return true; + case BinaryConsts::EncodedHeapType::ext: + out = HeapType::ext; + return true; case BinaryConsts::EncodedHeapType::any: out = HeapType::any; return true; diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 55551ef58..86d7b27e9 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1169,8 +1169,10 @@ Type SExpressionWasmBuilder::stringToType(const char* str, if (strncmp(str, "funcref", 7) == 0 && (prefix || str[7] == 0)) { return Type(HeapType::func, Nullable); } - if ((strncmp(str, "externref", 9) == 0 && (prefix || str[9] == 0)) || - (strncmp(str, "anyref", 6) == 0 && (prefix || str[6] == 0))) { + if (strncmp(str, "externref", 9) == 0 && (prefix || str[9] == 0)) { + return Type(HeapType::ext, Nullable); + } + if (strncmp(str, "anyref", 6) == 0 && (prefix || str[6] == 0)) { return Type(HeapType::any, Nullable); } if (strncmp(str, "eqref", 5) == 0 && (prefix || str[5] == 0)) { @@ -1214,7 +1216,7 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str, } if (str[1] == 'x' && str[2] == 't' && str[3] == 'e' && str[4] == 'r' && str[5] == 'n' && (prefix || str[6] == 0)) { - return HeapType::any; + return HeapType::ext; } } if (str[0] == 'a') { diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 23d2877f7..f9ccea9f6 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -172,7 +172,7 @@ struct TypeBounder { bool hasLeastUpperBound(Type a, Type b); Type getLeastUpperBound(Type a, Type b); - HeapType getLeastUpperBound(HeapType a, HeapType b); + std::optional<HeapType> getLeastUpperBound(HeapType a, HeapType b); private: // Return the LUB iff a LUB was found. The HeapType and Struct overloads are @@ -181,7 +181,7 @@ private: // Note that these methods can return temporary types, so they should never be // used directly. std::optional<Type> lub(Type a, Type b); - HeapType lub(HeapType a, HeapType b); + std::optional<HeapType> lub(HeapType a, HeapType b); std::optional<Tuple> lub(const Tuple& a, const Tuple& b); std::optional<Field> lub(const Field& a, const Field& b); std::optional<Signature> lub(const Signature& a, const Signature& b); @@ -573,8 +573,8 @@ HeapType::BasicHeapType getBasicHeapSupertype(HeapType type) { WASM_UNREACHABLE("unexpected kind"); }; -HeapType getBasicHeapTypeLUB(HeapType::BasicHeapType a, - HeapType::BasicHeapType b) { +std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a, + HeapType::BasicHeapType b) { if (a == b) { return a; } @@ -583,25 +583,27 @@ HeapType getBasicHeapTypeLUB(HeapType::BasicHeapType a, std::swap(a, b); } switch (a) { + case HeapType::ext: + return {}; case HeapType::func: case HeapType::any: - return HeapType::any; + return {HeapType::any}; case HeapType::eq: if (b == HeapType::i31 || b == HeapType::data) { - return HeapType::eq; + return {HeapType::eq}; } - return HeapType::any; + return {HeapType::any}; case HeapType::i31: if (b == HeapType::data) { - return HeapType::eq; + return {HeapType::eq}; } - return HeapType::any; + return {HeapType::any}; case HeapType::data: case HeapType::string: case HeapType::stringview_wtf8: case HeapType::stringview_wtf16: case HeapType::stringview_iter: - return HeapType::any; + return {HeapType::any}; } WASM_UNREACHABLE("unexpected basic type"); } @@ -1205,11 +1207,12 @@ Type Type::getLeastUpperBound(Type a, Type b) { return Type(elems); } if (a.isRef() && b.isRef()) { - auto nullability = - (a.isNullable() || b.isNullable()) ? Nullable : NonNullable; - auto heapType = - HeapType::getLeastUpperBound(a.getHeapType(), b.getHeapType()); - return Type(heapType, nullability); + if (auto heapType = + HeapType::getLeastUpperBound(a.getHeapType(), b.getHeapType())) { + auto nullability = + (a.isNullable() || b.isNullable()) ? Nullable : NonNullable; + return Type(*heapType, nullability); + } } return Type::none; WASM_UNREACHABLE("unexpected type"); @@ -1411,7 +1414,7 @@ std::vector<HeapType> HeapType::getReferencedHeapTypes() const { return types; } -HeapType HeapType::getLeastUpperBound(HeapType a, HeapType b) { +std::optional<HeapType> HeapType::getLeastUpperBound(HeapType a, HeapType b) { if (a == b) { return a; } @@ -1616,10 +1619,13 @@ bool SubTyper::isSubType(HeapType a, HeapType b) { } if (b.isBasic()) { switch (b.getBasic()) { + case HeapType::ext: + return a == HeapType::ext; case HeapType::func: return a.isSignature(); case HeapType::any: - return true; + // TODO: exclude functions as well. + return a != HeapType::ext; case HeapType::eq: return a == HeapType::i31 || a.isData(); case HeapType::i31: @@ -1735,8 +1741,13 @@ Type TypeBounder::getLeastUpperBound(Type a, Type b) { return built.back().getArray().element.type; } -HeapType TypeBounder::getLeastUpperBound(HeapType a, HeapType b) { - HeapType l = lub(a, b); +std::optional<HeapType> TypeBounder::getLeastUpperBound(HeapType a, + HeapType b) { + auto maybeLub = lub(a, b); + if (!maybeLub) { + return std::nullopt; + } + HeapType l = *maybeLub; if (!isTemp(l)) { // The LUB is already canonical, so we're done. return l; @@ -1767,15 +1778,16 @@ std::optional<Type> TypeBounder::lub(Type a, Type b) { } return builder.getTempTupleType(*tuple); } else if (a.isRef() && b.isRef()) { - auto nullability = - (a.isNullable() || b.isNullable()) ? Nullable : NonNullable; - HeapType heapType = lub(a.getHeapType(), b.getHeapType()); - return builder.getTempRefType(heapType, nullability); + if (auto heapType = lub(a.getHeapType(), b.getHeapType())) { + auto nullability = + (a.isNullable() || b.isNullable()) ? Nullable : NonNullable; + return builder.getTempRefType(*heapType, nullability); + } } return {}; } -HeapType TypeBounder::lub(HeapType a, HeapType b) { +std::optional<HeapType> TypeBounder::lub(HeapType a, HeapType b) { if (a == b) { return a; } @@ -1999,6 +2011,8 @@ std::ostream& TypePrinter::print(Type type) { std::ostream& TypePrinter::print(HeapType type) { if (type.isBasic()) { switch (type.getBasic()) { + case HeapType::ext: + return os << "extern"; case HeapType::func: return os << "func"; case HeapType::any: diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 92f6c76bf..e837c2dd6 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -3099,7 +3099,7 @@ static void validateTables(Module& module, ValidationInfo& info) { } } - Type anyref = Type(HeapType::any, Nullable); + Type externref = Type(HeapType::ext, Nullable); Type funcref = Type(HeapType::func, Nullable); for (auto& table : module.tables) { info.shouldBeTrue(table->initial <= table->max, @@ -3110,15 +3110,15 @@ static void validateTables(Module& module, ValidationInfo& info) { "table", "Non-nullable reference types are not yet supported for tables"); if (!module.features.hasGC()) { - info.shouldBeTrue(table->type.isFunction() || table->type == anyref, + info.shouldBeTrue(table->type.isFunction() || table->type == externref, "table", "Only function reference types or externref are valid " "for table type (when GC is disabled)"); } if (!module.features.hasTypedFunctionReferences()) { - info.shouldBeTrue(table->type == funcref || table->type == anyref, + info.shouldBeTrue(table->type == funcref || table->type == externref, "table", - "Only funcref and anyref are valid for table type " + "Only funcref and externref are valid for table type " "(when typed-function references are disabled)"); } } diff --git a/src/wasm/wat-parser.cpp b/src/wasm/wat-parser.cpp index 89eab3297..5455c0438 100644 --- a/src/wasm/wat-parser.cpp +++ b/src/wasm/wat-parser.cpp @@ -431,7 +431,7 @@ template<typename Ctx> struct TypeParserCtx { HeapTypeT makeFunc() { return HeapType::func; } HeapTypeT makeAny() { return HeapType::any; } - HeapTypeT makeExtern() { return HeapType::any; } + HeapTypeT makeExtern() { return HeapType::ext; } HeapTypeT makeEq() { return HeapType::eq; } HeapTypeT makeI31() { return HeapType::i31; } HeapTypeT makeData() { return HeapType::data; } diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 1be13aefe..3e5f9afb0 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -2057,7 +2057,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (ref.is_null - (ref.null any) + (ref.null extern) ) ) (drop @@ -2152,7 +2152,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop funcref) ) (drop - (pop anyref) + (pop externref) ) (drop (pop anyref) @@ -4161,7 +4161,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (ref.is_null - (ref.null any) + (ref.null extern) ) ) (drop @@ -4256,7 +4256,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop funcref) ) (drop - (pop anyref) + (pop externref) ) (drop (pop anyref) diff --git a/test/ctor-eval/bad-indirect-call3.wast.out b/test/ctor-eval/bad-indirect-call3.wast.out index 257bf3168..4b470e10a 100644 --- a/test/ctor-eval/bad-indirect-call3.wast.out +++ b/test/ctor-eval/bad-indirect-call3.wast.out @@ -1,5 +1,5 @@ (module - (type $anyref_=>_none (func (param anyref))) + (type $externref_=>_none (func (param externref))) (type $none_=>_none (func)) (type $funcref_=>_none (func (param funcref))) (memory $0 256 256) @@ -7,7 +7,7 @@ (table $0 1 1 funcref) (elem (i32.const 0) $callee) (export "sig_mismatch" (func $sig_mismatch)) - (func $callee (param $0 anyref) + (func $callee (param $0 externref) (i32.store8 (i32.const 40) (i32.const 67) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index cb8349f89..f6cee93fa 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -318,6 +318,7 @@ void test_types() { BinaryenPackedType i16 = BinaryenPackedTypeInt16(); printf("BinaryenPackedTypeInt16: %d\n", i16); + printf("BinaryenHeapTypeExt: %zd\n", BinaryenHeapTypeExt()); printf("BinaryenHeapTypeFunc: %zd\n", BinaryenHeapTypeFunc()); printf("BinaryenHeapTypeAny: %zd\n", BinaryenHeapTypeAny()); printf("BinaryenHeapTypeEq: %zd\n", BinaryenHeapTypeEq()); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index ff71e08e5..31a6875bb 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -19,15 +19,16 @@ BinaryenTypeAuto: -1 BinaryenPackedTypeNotPacked: 0 BinaryenPackedTypeInt8: 1 BinaryenPackedTypeInt16: 2 -BinaryenHeapTypeFunc: 0 -BinaryenHeapTypeAny: 1 -BinaryenHeapTypeEq: 2 -BinaryenHeapTypeI31: 3 -BinaryenHeapTypeData: 4 -BinaryenHeapTypeString: 5 -BinaryenHeapTypeStringviewWTF8: 6 -BinaryenHeapTypeStringviewWTF16: 7 -BinaryenHeapTypeStringviewIter: 8 +BinaryenHeapTypeExt: 0 +BinaryenHeapTypeFunc: 1 +BinaryenHeapTypeAny: 2 +BinaryenHeapTypeEq: 3 +BinaryenHeapTypeI31: 4 +BinaryenHeapTypeData: 5 +BinaryenHeapTypeString: 6 +BinaryenHeapTypeStringviewWTF8: 7 +BinaryenHeapTypeStringviewWTF16: 8 +BinaryenHeapTypeStringviewIter: 9 BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 BinaryenFeatureBulkMemory: 16 @@ -81,7 +82,7 @@ BinaryenFeatureAll: 122879 (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) - (local $5 anyref) + (local $5 externref) (block $the-body (result i32) (block $the-nothing (drop @@ -1962,7 +1963,7 @@ BinaryenFeatureAll: 122879 ) (drop (ref.is_null - (ref.null any) + (ref.null extern) ) ) (drop @@ -2102,7 +2103,7 @@ BinaryenFeatureAll: 122879 (pop funcref) ) (drop - (pop anyref) + (pop externref) ) (drop (pop i32 i64 f32 f64) diff --git a/test/lit/passes/flatten_all-features.wast b/test/lit/passes/flatten_all-features.wast index b563159c6..6a9ffc16a 100644 --- a/test/lit/passes/flatten_all-features.wast +++ b/test/lit/passes/flatten_all-features.wast @@ -3416,55 +3416,59 @@ ;; value type, we need the value to be set into two locals: one with the outer ;; block's type, and one with its value type. ;; CHECK: (func $subtype (result anyref) - ;; CHECK-NEXT: (local $0 anyref) + ;; CHECK-NEXT: (local $0 eqref) ;; CHECK-NEXT: (local $1 anyref) - ;; CHECK-NEXT: (local $2 anyref) - ;; CHECK-NEXT: (local $3 anyref) - ;; CHECK-NEXT: (local $4 anyref) - ;; CHECK-NEXT: (local $5 anyref) - ;; CHECK-NEXT: (local $6 anyref) + ;; CHECK-NEXT: (local $2 eqref) + ;; CHECK-NEXT: (local $3 eqref) + ;; CHECK-NEXT: (local $4 eqref) + ;; CHECK-NEXT: (local $5 eqref) + ;; CHECK-NEXT: (local $6 eqref) + ;; CHECK-NEXT: (local $7 anyref) ;; CHECK-NEXT: (block $label0 ;; CHECK-NEXT: (block $block ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: (ref.null eq) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $2 + ;; CHECK-NEXT: (ref.null eq) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (br_if $label0 ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $2 - ;; CHECK-NEXT: (local.get $1) + ;; CHECK-NEXT: (local.set $3 + ;; CHECK-NEXT: (local.get $2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $0 - ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: (local.get $3) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $3 + ;; CHECK-NEXT: (local.set $4 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $4 - ;; CHECK-NEXT: (local.get $3) + ;; CHECK-NEXT: (local.set $5 + ;; CHECK-NEXT: (local.get $4) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $5 - ;; CHECK-NEXT: (local.get $4) + ;; CHECK-NEXT: (local.set $6 + ;; CHECK-NEXT: (local.get $5) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (local.get $5) + ;; CHECK-NEXT: (local.get $6) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $6 + ;; CHECK-NEXT: (local.set $7 ;; CHECK-NEXT: (local.get $1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $6) + ;; CHECK-NEXT: (local.get $7) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $subtype (result anyref) - (local $0 externref) + (local $0 eqref) (block $label0 (result anyref) - (block (result externref) + (block (result eqref) (local.tee $0 (br_if $label0 - (ref.null extern) + (ref.null eq) (i32.const 0) ) ) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index d8fb51e50..73201a169 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -2961,7 +2961,7 @@ ;; CHECK: (memory $0 10) - ;; CHECK: (table $t 0 anyref) + ;; CHECK: (table $t 0 externref) ;; CHECK: (tag $e-i32 (param i32)) (tag $e-i32 (param i32)) @@ -3210,7 +3210,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (table.grow $t - ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: (ref.null extern) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/instrument-locals_all-features_disable-typed-function-references.wast b/test/lit/passes/instrument-locals_all-features_disable-typed-function-references.wast index 3c0ded9ee..70ccf3364 100644 --- a/test/lit/passes/instrument-locals_all-features_disable-typed-function-references.wast +++ b/test/lit/passes/instrument-locals_all-features_disable-typed-function-references.wast @@ -14,7 +14,7 @@ ;; CHECK: (type $i32_i32_funcref_=>_funcref (func (param i32 i32 funcref) (result funcref))) - ;; CHECK: (type $i32_i32_anyref_=>_anyref (func (param i32 i32 anyref) (result anyref))) + ;; CHECK: (type $i32_i32_externref_=>_externref (func (param i32 i32 externref) (result externref))) ;; CHECK: (type $i32_i32_v128_=>_v128 (func (param i32 i32 v128) (result v128))) @@ -40,9 +40,9 @@ ;; CHECK: (import "env" "set_funcref" (func $set_funcref (param i32 i32 funcref) (result funcref))) - ;; CHECK: (import "env" "get_anyref" (func $get_anyref (param i32 i32 anyref) (result anyref))) + ;; CHECK: (import "env" "get_externref" (func $get_externref (param i32 i32 externref) (result externref))) - ;; CHECK: (import "env" "set_anyref" (func $set_anyref (param i32 i32 anyref) (result anyref))) + ;; CHECK: (import "env" "set_externref" (func $set_externref (param i32 i32 externref) (result externref))) ;; CHECK: (import "env" "get_v128" (func $get_v128 (param i32 i32 v128) (result v128))) @@ -56,7 +56,7 @@ ;; CHECK-NEXT: (local $z f32) ;; CHECK-NEXT: (local $w f64) ;; CHECK-NEXT: (local $F funcref) - ;; CHECK-NEXT: (local $X anyref) + ;; CHECK-NEXT: (local $X externref) ;; CHECK-NEXT: (local $S v128) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $get_i32 @@ -90,7 +90,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (call $get_anyref + ;; CHECK-NEXT: (call $get_externref ;; CHECK-NEXT: (i32.const 4) ;; CHECK-NEXT: (i32.const 5) ;; CHECK-NEXT: (local.get $X) @@ -128,7 +128,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (call $get_anyref + ;; CHECK-NEXT: (call $get_externref ;; CHECK-NEXT: (i32.const 9) ;; CHECK-NEXT: (i32.const 5) ;; CHECK-NEXT: (local.get $X) @@ -162,10 +162,10 @@ ;; CHECK-NEXT: (ref.func $test) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $X - ;; CHECK-NEXT: (call $set_anyref + ;; CHECK-NEXT: (call $set_externref ;; CHECK-NEXT: (i32.const 14) ;; CHECK-NEXT: (i32.const 5) - ;; CHECK-NEXT: (call $get_anyref + ;; CHECK-NEXT: (call $get_externref ;; CHECK-NEXT: (i32.const 13) ;; CHECK-NEXT: (i32.const 5) ;; CHECK-NEXT: (local.get $X) @@ -208,10 +208,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $X - ;; CHECK-NEXT: (call $set_anyref + ;; CHECK-NEXT: (call $set_externref ;; CHECK-NEXT: (i32.const 21) ;; CHECK-NEXT: (i32.const 5) - ;; CHECK-NEXT: (call $get_anyref + ;; CHECK-NEXT: (call $get_externref ;; CHECK-NEXT: (i32.const 20) ;; CHECK-NEXT: (i32.const 5) ;; CHECK-NEXT: (local.get $X) diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index f6a1b5d09..7a0eea294 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -47,37 +47,37 @@ ;; These functions test if an `if` with subtyped arms is correctly folded ;; 1. if its `ifTrue` and `ifFalse` arms are identical (can fold) ;; CHECK: (func $if-arms-subtype-fold (result anyref) - ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: (ref.null eq) ;; CHECK-NEXT: ) ;; NOMNL: (func $if-arms-subtype-fold (type $none_=>_anyref) (result anyref) - ;; NOMNL-NEXT: (ref.null any) + ;; NOMNL-NEXT: (ref.null eq) ;; NOMNL-NEXT: ) (func $if-arms-subtype-fold (result anyref) (if (result anyref) (i32.const 0) - (ref.null extern) - (ref.null extern) + (ref.null eq) + (ref.null eq) ) ) ;; 2. if its `ifTrue` and `ifFalse` arms are not identical (cannot fold) ;; CHECK: (func $if-arms-subtype-nofold (result anyref) ;; CHECK-NEXT: (if (result anyref) ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: (ref.null eq) ;; CHECK-NEXT: (ref.null func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $if-arms-subtype-nofold (type $none_=>_anyref) (result anyref) ;; NOMNL-NEXT: (if (result anyref) ;; NOMNL-NEXT: (i32.const 0) - ;; NOMNL-NEXT: (ref.null any) + ;; NOMNL-NEXT: (ref.null eq) ;; NOMNL-NEXT: (ref.null func) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $if-arms-subtype-nofold (result anyref) (if (result anyref) (i32.const 0) - (ref.null extern) + (ref.null eq) (ref.null func) ) ) diff --git a/test/multi-table.wast.from-wast b/test/multi-table.wast.from-wast index 545bb9c56..73a9abea3 100644 --- a/test/multi-table.wast.from-wast +++ b/test/multi-table.wast.from-wast @@ -5,7 +5,7 @@ (global $g2 i32 (i32.const 0)) (table $t2 3 3 funcref) (table $t3 4 4 funcref) - (table $textern 0 anyref) + (table $textern 0 externref) (table $tspecial 5 5 (ref null $none_=>_none)) (elem $0 (table $t1) (i32.const 0) func $f) (elem $1 (table $t2) (i32.const 0) func $f) diff --git a/test/multi-table.wast.fromBinary b/test/multi-table.wast.fromBinary index 105706621..427fb44f3 100644 --- a/test/multi-table.wast.fromBinary +++ b/test/multi-table.wast.fromBinary @@ -5,7 +5,7 @@ (global $g2 i32 (i32.const 0)) (table $t2 3 3 funcref) (table $t3 4 4 funcref) - (table $textern 0 anyref) + (table $textern 0 externref) (table $tspecial 5 5 (ref null $none_=>_none)) (elem $0 (table $t1) (i32.const 0) func $f) (elem $1 (table $t2) (i32.const 0) func $f) diff --git a/test/multi-table.wast.fromBinary.noDebugInfo b/test/multi-table.wast.fromBinary.noDebugInfo index 174d2a912..7fc667087 100644 --- a/test/multi-table.wast.fromBinary.noDebugInfo +++ b/test/multi-table.wast.fromBinary.noDebugInfo @@ -5,7 +5,7 @@ (global $global$1 i32 (i32.const 0)) (table $0 3 3 funcref) (table $1 4 4 funcref) - (table $2 0 anyref) + (table $2 0 externref) (table $3 5 5 (ref null $none_=>_none)) (elem $0 (table $timport$0) (i32.const 0) func $0) (elem $1 (table $0) (i32.const 0) func $0) diff --git a/test/multivalue.wast.from-wast b/test/multivalue.wast.from-wast index c6aa020dd..9340c183a 100644 --- a/test/multivalue.wast.from-wast +++ b/test/multivalue.wast.from-wast @@ -3,7 +3,7 @@ (type $none_=>_none (func)) (type $none_=>_i64 (func (result i64))) (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) - (type $none_=>_i32_i64_anyref (func (result i32 i64 anyref))) + (type $none_=>_i32_i64_externref (func (result i32 i64 externref))) (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) (type $none_=>_i32 (func (result i32))) (type $none_=>_f32 (func (result f32))) @@ -135,18 +135,18 @@ ) ) ) - (func $mv-if (result i32 i64 anyref) - (if (result i32 i64 anyref) + (func $mv-if (result i32 i64 externref) + (if (result i32 i64 externref) (i32.const 1) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) ) ) diff --git a/test/multivalue.wast.fromBinary b/test/multivalue.wast.fromBinary index cc900e024..dd39d4b34 100644 --- a/test/multivalue.wast.fromBinary +++ b/test/multivalue.wast.fromBinary @@ -1,7 +1,7 @@ (module (type $none_=>_i32_i64 (func (result i32 i64))) (type $none_=>_none (func)) - (type $none_=>_i32_i64_anyref (func (result i32 i64 anyref))) + (type $none_=>_i32_i64_externref (func (result i32 i64 externref))) (type $none_=>_i64 (func (result i64))) (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) @@ -389,20 +389,20 @@ ) ) ) - (func $mv-if (result i32 i64 anyref) - (local $0 (i32 i64 anyref)) + (func $mv-if (result i32 i64 externref) + (local $0 (i32 i64 externref)) (local.set $0 - (if (result i32 i64 anyref) + (if (result i32 i64 externref) (i32.const 1) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) ) ) diff --git a/test/multivalue.wast.fromBinary.noDebugInfo b/test/multivalue.wast.fromBinary.noDebugInfo index daf0a743e..66c0f52c5 100644 --- a/test/multivalue.wast.fromBinary.noDebugInfo +++ b/test/multivalue.wast.fromBinary.noDebugInfo @@ -1,7 +1,7 @@ (module (type $none_=>_i32_i64 (func (result i32 i64))) (type $none_=>_none (func)) - (type $none_=>_i32_i64_anyref (func (result i32 i64 anyref))) + (type $none_=>_i32_i64_externref (func (result i32 i64 externref))) (type $none_=>_i64 (func (result i64))) (type $none_=>_f32_i64_i32 (func (result f32 i64 i32))) (type $none_=>_i32_i64_f32 (func (result i32 i64 f32))) @@ -389,20 +389,20 @@ ) ) ) - (func $14 (result i32 i64 anyref) - (local $0 (i32 i64 anyref)) + (func $14 (result i32 i64 externref) + (local $0 (i32 i64 externref)) (local.set $0 - (if (result i32 i64 anyref) + (if (result i32 i64 externref) (i32.const 1) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) (tuple.make (i32.const 42) (i64.const 42) - (ref.null any) + (ref.null extern) ) ) ) diff --git a/test/passes/precompute_all-features.txt b/test/passes/precompute_all-features.txt index 70c790484..89d334a93 100644 --- a/test/passes/precompute_all-features.txt +++ b/test/passes/precompute_all-features.txt @@ -5,7 +5,7 @@ (type $0 (func (param i32))) (type $none_=>_v128 (func (result v128))) (type $none_=>_i32_i64 (func (result i32 i64))) - (type $none_=>_anyref (func (result anyref))) + (type $none_=>_externref (func (result externref))) (global $global i32 (i32.const 1)) (global $global-mut (mut i32) (i32.const 2)) (memory $0 512 512) @@ -253,8 +253,8 @@ (func $loop-precompute (result i32) (i32.const 1) ) - (func $reftype-test (result anyref) - (ref.null any) + (func $reftype-test (result externref) + (ref.null extern) ) (func $dummy (nop) @@ -276,18 +276,18 @@ ) ) (drop - (block $l2 (result anyref) + (block $l2 (result externref) (drop (block $l3 (global.set $global-mut (i32.const 1) ) (br $l2 - (ref.null any) + (ref.null extern) ) ) ) - (ref.null any) + (ref.null extern) ) ) (drop diff --git a/test/passes/simplify-globals_all-features.txt b/test/passes/simplify-globals_all-features.txt index 5ad54b0a8..ace056aac 100644 --- a/test/passes/simplify-globals_all-features.txt +++ b/test/passes/simplify-globals_all-features.txt @@ -213,9 +213,9 @@ ) (module (type $none_=>_none (func)) - (import "env" "global-1" (global $g1 anyref)) - (global $g2 anyref (global.get $g1)) - (global $g3 anyref (ref.null any)) + (import "env" "global-1" (global $g1 externref)) + (global $g2 externref (global.get $g1)) + (global $g3 externref (ref.null extern)) (func $test1 (drop (global.get $g1) @@ -226,7 +226,7 @@ ) (func $test2 (drop - (ref.null any) + (ref.null extern) ) ) ) diff --git a/test/passes/simplify-locals_all-features.txt b/test/passes/simplify-locals_all-features.txt index 0c25ea54b..d4338870d 100644 --- a/test/passes/simplify-locals_all-features.txt +++ b/test/passes/simplify-locals_all-features.txt @@ -1884,7 +1884,7 @@ (module (type $none_=>_anyref (func (result anyref))) (func $subtype-test (result anyref) - (local $0 anyref) + (local $0 eqref) (local $1 anyref) (local $2 anyref) (block $block diff --git a/test/passes/simplify-locals_all-features.wast b/test/passes/simplify-locals_all-features.wast index 7d153efd9..ff70a2774 100644 --- a/test/passes/simplify-locals_all-features.wast +++ b/test/passes/simplify-locals_all-features.wast @@ -1657,7 +1657,7 @@ ) (module (func $subtype-test (result anyref) - (local $0 externref) + (local $0 eqref) (local $1 anyref) (local $2 anyref) (block diff --git a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt index fa7221683..994453007 100644 --- a/test/passes/strip-target-features_roundtrip_print-features_all-features.txt +++ b/test/passes/strip-target-features_roundtrip_print-features_all-features.txt @@ -15,14 +15,14 @@ --enable-extended-const --enable-strings (module - (type $none_=>_v128_anyref (func (result v128 anyref))) - (func $foo (result v128 anyref) + (type $none_=>_v128_externref (func (result v128 externref))) + (func $foo (result v128 externref) (tuple.make (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) - (ref.null any) + (ref.null extern) ) ) - (func $bar (result v128 anyref) + (func $bar (result v128 externref) (return_call $foo) ) ) diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index aac1cbc83..5e4beae81 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,6 +1,6 @@ total - [exports] : 10 - [funcs] : 12 + [exports] : 9 + [funcs] : 13 [globals] : 6 [imports] : 5 [memories] : 1 @@ -8,34 +8,33 @@ total [table-data] : 4 [tables] : 1 [tags] : 0 - [total] : 549 - [vars] : 22 - AtomicCmpxchg : 1 - AtomicFence : 1 - Binary : 71 - Block : 60 - Break : 2 - Call : 23 - CallRef : 2 - Const : 119 - Drop : 3 - GlobalGet : 35 - GlobalSet : 19 - I31New : 6 - If : 25 - Load : 16 - LocalGet : 45 - LocalSet : 23 - Loop : 6 - Nop : 7 - RefFunc : 11 + [total] : 669 + [vars] : 20 + ArrayInit : 3 + AtomicCmpxchg : 2 + Binary : 75 + Block : 81 + Break : 8 + Call : 44 + CallRef : 1 + Const : 137 + Drop : 10 + GlobalGet : 41 + GlobalSet : 22 + I31New : 8 + If : 31 + Load : 18 + LocalGet : 48 + LocalSet : 27 + Loop : 8 + Nop : 12 + RefFunc : 10 RefIs : 1 - RefNull : 2 + RefNull : 4 Return : 27 - SIMDExtract : 1 Select : 1 - Store : 3 - StructNew : 2 - TupleMake : 7 - Unary : 29 - Unreachable : 1 + Store : 1 + StructNew : 7 + TupleExtract : 1 + TupleMake : 6 + Unary : 35 diff --git a/test/reference-types.wast b/test/reference-types.wast index afdb38c89..a7f84a93c 100644 --- a/test/reference-types.wast +++ b/test/reference-types.wast @@ -1,51 +1,43 @@ -;; reftype :: externref | funcref - -;; NOTE: the subtyping relationship has been removed from the reference-types proposal but an -;; `--enable-anyref` feature flag is present in Binaryen that we use below to test subtyping. -;; -;; reftype :: reftype | anyref -;; reftype <: anyref - (module - (type $sig_externref (func (param externref))) + (type $sig_eqref (func (param eqref))) (type $sig_funcref (func (param funcref))) (type $sig_anyref (func (param anyref))) - (func $take_externref (param externref)) + (func $take_eqref (param eqref)) (func $take_funcref (param funcref)) (func $take_anyref (param anyref)) (func $foo) - (table funcref (elem $take_externref $take_funcref $take_anyref)) + (table funcref (elem $take_eqref $take_funcref $take_anyref)) (elem declare func $ref-taken-but-not-in-table) - (import "env" "import_func" (func $import_func (param externref) (result funcref))) - (import "env" "import_global" (global $import_global externref)) - (export "export_func" (func $import_func (param externref) (result funcref))) + (import "env" "import_func" (func $import_func (param eqref) (result funcref))) + (import "env" "import_global" (global $import_global eqref)) + (export "export_func" (func $import_func (param eqref) (result funcref))) (export "export_global" (global $import_global)) ;; Test global initializer expressions - (global $global_externref (mut externref) (ref.null extern)) + (global $global_eqref (mut eqref) (ref.null eq)) (global $global_funcref (mut funcref) (ref.null func)) (global $global_funcref_func (mut funcref) (ref.func $foo)) (global $global_anyref (mut anyref) (ref.null any)) ;; Test subtype relationship in global initializer expressions - (global $global_anyref2 (mut anyref) (ref.null extern)) + (global $global_anyref2 (mut anyref) (ref.null eq)) (global $global_anyref3 (mut anyref) (ref.null func)) (global $global_anyref4 (mut anyref) (ref.func $foo)) (tag $e-i32 (param i32)) (func $test - (local $local_externref externref) + (local $local_eqref eqref) (local $local_funcref funcref) (local $local_anyref anyref) ;; Test types for local.get/set - (local.set $local_externref (local.get $local_externref)) - (local.set $local_externref (global.get $global_externref)) - (local.set $local_externref (ref.null extern)) + (local.set $local_eqref (local.get $local_eqref)) + (local.set $local_eqref (global.get $global_eqref)) + (local.set $local_eqref (ref.null eq)) (local.set $local_funcref (local.get $local_funcref)) (local.set $local_funcref (global.get $global_funcref)) (local.set $local_funcref (ref.null func)) @@ -55,18 +47,18 @@ (local.set $local_anyref (ref.null any)) ;; Test subtype relationship for local.set - (local.set $local_anyref (local.get $local_externref)) - (local.set $local_anyref (global.get $global_externref)) - (local.set $local_anyref (ref.null extern)) + (local.set $local_anyref (local.get $local_eqref)) + (local.set $local_anyref (global.get $global_eqref)) + (local.set $local_anyref (ref.null eq)) (local.set $local_anyref (local.get $local_funcref)) (local.set $local_anyref (global.get $global_funcref)) (local.set $local_anyref (ref.null func)) (local.set $local_anyref (ref.func $foo)) ;; Test types for global.get/set - (global.set $global_externref (global.get $global_externref)) - (global.set $global_externref (local.get $local_externref)) - (global.set $global_externref (ref.null extern)) + (global.set $global_eqref (global.get $global_eqref)) + (global.set $global_eqref (local.get $local_eqref)) + (global.set $global_eqref (ref.null eq)) (global.set $global_funcref (global.get $global_funcref)) (global.set $global_funcref (local.get $local_funcref)) (global.set $global_funcref (ref.null func)) @@ -76,18 +68,18 @@ (global.set $global_anyref (ref.null any)) ;; Test subtype relationship for global.set - (global.set $global_anyref (global.get $global_externref)) - (global.set $global_anyref (local.get $local_externref)) - (global.set $global_anyref (ref.null extern)) + (global.set $global_anyref (global.get $global_eqref)) + (global.set $global_anyref (local.get $local_eqref)) + (global.set $global_anyref (ref.null eq)) (global.set $global_anyref (global.get $global_funcref)) (global.set $global_anyref (local.get $local_funcref)) (global.set $global_anyref (ref.null func)) (global.set $global_anyref (ref.func $foo)) ;; Test function call params - (call $take_externref (local.get $local_externref)) - (call $take_externref (global.get $global_externref)) - (call $take_externref (ref.null extern)) + (call $take_eqref (local.get $local_eqref)) + (call $take_eqref (global.get $global_eqref)) + (call $take_eqref (ref.null eq)) (call $take_funcref (local.get $local_funcref)) (call $take_funcref (global.get $global_funcref)) (call $take_funcref (ref.null func)) @@ -97,18 +89,18 @@ (call $take_anyref (ref.null any)) ;; Test subtype relationship for function call params - (call $take_anyref (local.get $local_externref)) - (call $take_anyref (global.get $global_externref)) - (call $take_anyref (ref.null extern)) + (call $take_anyref (local.get $local_eqref)) + (call $take_anyref (global.get $global_eqref)) + (call $take_anyref (ref.null eq)) (call $take_anyref (local.get $local_funcref)) (call $take_anyref (global.get $global_funcref)) (call $take_anyref (ref.null func)) (call $take_anyref (ref.func $foo)) ;; Test call_indirect params - (call_indirect (type $sig_externref) (local.get $local_externref) (i32.const 0)) - (call_indirect (type $sig_externref) (global.get $global_externref) (i32.const 0)) - (call_indirect (type $sig_externref) (ref.null extern) (i32.const 0)) + (call_indirect (type $sig_eqref) (local.get $local_eqref) (i32.const 0)) + (call_indirect (type $sig_eqref) (global.get $global_eqref) (i32.const 0)) + (call_indirect (type $sig_eqref) (ref.null eq) (i32.const 0)) (call_indirect (type $sig_funcref) (local.get $local_funcref) (i32.const 1)) (call_indirect (type $sig_funcref) (global.get $global_funcref) (i32.const 1)) (call_indirect (type $sig_funcref) (ref.null func) (i32.const 1)) @@ -118,9 +110,9 @@ (call_indirect (type $sig_anyref) (ref.null any) (i32.const 3)) ;; Test subtype relationship for call_indirect params - (call_indirect (type $sig_anyref) (local.get $local_externref) (i32.const 3)) - (call_indirect (type $sig_anyref) (global.get $global_externref) (i32.const 3)) - (call_indirect (type $sig_anyref) (ref.null extern) (i32.const 3)) + (call_indirect (type $sig_anyref) (local.get $local_eqref) (i32.const 3)) + (call_indirect (type $sig_anyref) (global.get $global_eqref) (i32.const 3)) + (call_indirect (type $sig_anyref) (ref.null eq) (i32.const 3)) (call_indirect (type $sig_anyref) (local.get $local_funcref) (i32.const 3)) (call_indirect (type $sig_anyref) (global.get $global_funcref) (i32.const 3)) (call_indirect (type $sig_anyref) (ref.null func) (i32.const 3)) @@ -128,18 +120,18 @@ ;; Test block return type (drop - (block (result externref) - (br_if 0 (local.get $local_externref) (i32.const 1)) + (block (result eqref) + (br_if 0 (local.get $local_eqref) (i32.const 1)) ) ) (drop - (block (result externref) - (br_if 0 (global.get $global_externref) (i32.const 1)) + (block (result eqref) + (br_if 0 (global.get $global_eqref) (i32.const 1)) ) ) (drop - (block (result externref) - (br_if 0 (ref.null extern) (i32.const 1)) + (block (result eqref) + (br_if 0 (ref.null eq) (i32.const 1)) ) ) (drop @@ -181,7 +173,7 @@ ;; Test subtype relationship for block return type (drop (block (result anyref) - (br_if 0 (local.get $local_externref) (i32.const 1)) + (br_if 0 (local.get $local_eqref) (i32.const 1)) ) ) (drop @@ -191,7 +183,7 @@ ) (drop (block (result anyref) - (br_if 0 (ref.null extern) (i32.const 1)) + (br_if 0 (ref.null eq) (i32.const 1)) ) ) (drop @@ -207,18 +199,18 @@ ;; Test loop return type (drop - (loop (result externref) - (local.get $local_externref) + (loop (result eqref) + (local.get $local_eqref) ) ) (drop - (loop (result externref) - (global.get $global_externref) + (loop (result eqref) + (global.get $global_eqref) ) ) (drop - (loop (result externref) - (ref.null extern) + (loop (result eqref) + (ref.null eq) ) ) (drop @@ -260,17 +252,17 @@ ;; Test subtype relationship for loop return type (drop (loop (result anyref) - (local.get $local_externref) + (local.get $local_eqref) ) ) (drop (loop (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) ) (drop (loop (result anyref) - (ref.null extern) + (ref.null eq) ) ) (drop @@ -296,10 +288,10 @@ ;; Test if return type (drop - (if (result externref) + (if (result eqref) (i32.const 1) - (local.get $local_externref) - (ref.null extern) + (local.get $local_eqref) + (ref.null eq) ) ) (drop @@ -321,14 +313,14 @@ (drop (if (result anyref) (i32.const 1) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) ) ) (drop (if (result anyref) (i32.const 1) - (ref.null extern) + (ref.null eq) (ref.null func) ) ) @@ -336,19 +328,19 @@ (if (result anyref) (i32.const 1) (ref.func $foo) - (ref.null extern) + (ref.null eq) ) ) ;; Test try return type (drop - (try (result externref) + (try (result eqref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $e-i32 (drop (pop i32)) - (ref.null extern) + (ref.null eq) ) ) ) @@ -368,7 +360,7 @@ (drop (try (result anyref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $e-i32 (drop (pop i32)) @@ -383,16 +375,16 @@ ) (catch $e-i32 (drop (pop i32)) - (local.get $local_externref) + (local.get $local_eqref) ) ) ) ;; Test typed select (drop - (select (result externref) - (local.get $local_externref) - (ref.null extern) + (select (result eqref) + (local.get $local_eqref) + (ref.null eq) (i32.const 1) ) ) @@ -414,7 +406,7 @@ ;; Test subtype relationship for typed select (drop (select (result anyref) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) (i32.const 1) ) @@ -422,15 +414,15 @@ (drop (select (result anyref) (local.get $local_funcref) - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) ;; ref.is_null takes any reference types - (drop (ref.is_null (local.get $local_externref))) - (drop (ref.is_null (global.get $global_externref))) - (drop (ref.is_null (ref.null extern))) + (drop (ref.is_null (local.get $local_eqref))) + (drop (ref.is_null (global.get $global_eqref))) + (drop (ref.is_null (ref.null eq))) (drop (ref.is_null (local.get $local_funcref))) (drop (ref.is_null (global.get $global_funcref))) (drop (ref.is_null (ref.null func))) @@ -441,15 +433,15 @@ ) ;; Test function return type - (func $return_externref_local (result externref) - (local $local_externref externref) - (local.get $local_externref) + (func $return_eqref_local (result eqref) + (local $local_eqref eqref) + (local.get $local_eqref) ) - (func $return_externref_global (result externref) - (global.get $global_externref) + (func $return_eqref_global (result eqref) + (global.get $global_eqref) ) - (func $return_externref_null (result externref) - (ref.null extern) + (func $return_eqref_null (result eqref) + (ref.null eq) ) (func $return_funcref_local (result funcref) (local $local_funcref funcref) @@ -477,14 +469,14 @@ ;; Test subtype relationship in function return type (func $return_anyref2 (result anyref) - (local $local_externref externref) - (local.get $local_externref) + (local $local_eqref eqref) + (local.get $local_eqref) ) (func $return_anyref3 (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) (func $return_anyref4 (result anyref) - (ref.null extern) + (ref.null eq) ) (func $return_anyref5 (result anyref) (local $local_funcref funcref) @@ -501,11 +493,11 @@ ) ;; Test returns - (func $returns_externref (result externref) - (local $local_externref externref) - (return (local.get $local_externref)) - (return (global.get $global_externref)) - (return (ref.null extern)) + (func $returns_eqref (result eqref) + (local $local_eqref eqref) + (return (local.get $local_eqref)) + (return (global.get $global_eqref)) + (return (ref.null eq)) ) (func $returns_funcref (result funcref) (local $local_funcref funcref) @@ -523,11 +515,11 @@ ;; Test subtype relationship in returns (func $returns_anyref2 (result anyref) - (local $local_externref externref) + (local $local_eqref eqref) (local $local_funcref funcref) - (return (local.get $local_externref)) - (return (global.get $global_externref)) - (return (ref.null extern)) + (return (local.get $local_eqref)) + (return (global.get $global_eqref)) + (return (ref.null eq)) (return (local.get $local_funcref)) (return (global.get $global_funcref)) (return (ref.func $foo)) diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast index 5afb74eda..47f1b9893 100644 --- a/test/reference-types.wast.from-wast +++ b/test/reference-types.wast.from-wast @@ -3,25 +3,27 @@ (type $sig_anyref (func (param anyref))) (type $sig_funcref (func (param funcref))) (type $none_=>_funcref (func (result funcref))) + (type $sig_eqref (func (param eqref))) (type $none_=>_none (func)) + (type $none_=>_eqref (func (result eqref))) (type $i32_=>_none (func (param i32))) - (type $anyref_=>_funcref (func (param anyref) (result funcref))) - (import "env" "import_global" (global $import_global anyref)) - (import "env" "import_func" (func $import_func (param anyref) (result funcref))) - (global $global_externref (mut anyref) (ref.null any)) + (type $eqref_=>_funcref (func (param eqref) (result funcref))) + (import "env" "import_global" (global $import_global eqref)) + (import "env" "import_func" (func $import_func (param eqref) (result funcref))) + (global $global_eqref (mut eqref) (ref.null eq)) (global $global_funcref (mut funcref) (ref.null func)) (global $global_funcref_func (mut funcref) (ref.func $foo)) (global $global_anyref (mut anyref) (ref.null any)) - (global $global_anyref2 (mut anyref) (ref.null any)) + (global $global_anyref2 (mut anyref) (ref.null eq)) (global $global_anyref3 (mut anyref) (ref.null func)) (global $global_anyref4 (mut anyref) (ref.func $foo)) (table $0 3 3 funcref) - (elem (i32.const 0) $take_externref $take_funcref $take_anyref) + (elem (i32.const 0) $take_eqref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) (tag $e-i32 (param i32)) (export "export_func" (func $import_func)) (export "export_global" (global $import_global)) - (func $take_externref (param $0 anyref) + (func $take_eqref (param $0 eqref) (nop) ) (func $take_funcref (param $0 funcref) @@ -34,17 +36,17 @@ (nop) ) (func $test - (local $local_externref anyref) + (local $local_eqref eqref) (local $local_funcref funcref) (local $local_anyref anyref) - (local.set $local_externref - (local.get $local_externref) + (local.set $local_eqref + (local.get $local_eqref) ) - (local.set $local_externref - (global.get $global_externref) + (local.set $local_eqref + (global.get $global_eqref) ) - (local.set $local_externref - (ref.null any) + (local.set $local_eqref + (ref.null eq) ) (local.set $local_funcref (local.get $local_funcref) @@ -68,13 +70,13 @@ (ref.null any) ) (local.set $local_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (local.set $local_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (local.set $local_anyref - (ref.null any) + (ref.null eq) ) (local.set $local_anyref (local.get $local_funcref) @@ -88,14 +90,14 @@ (local.set $local_anyref (ref.func $foo) ) - (global.set $global_externref - (global.get $global_externref) + (global.set $global_eqref + (global.get $global_eqref) ) - (global.set $global_externref - (local.get $local_externref) + (global.set $global_eqref + (local.get $local_eqref) ) - (global.set $global_externref - (ref.null any) + (global.set $global_eqref + (ref.null eq) ) (global.set $global_funcref (global.get $global_funcref) @@ -119,13 +121,13 @@ (ref.null any) ) (global.set $global_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (global.set $global_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (global.set $global_anyref - (ref.null any) + (ref.null eq) ) (global.set $global_anyref (global.get $global_funcref) @@ -139,14 +141,14 @@ (global.set $global_anyref (ref.func $foo) ) - (call $take_externref - (local.get $local_externref) + (call $take_eqref + (local.get $local_eqref) ) - (call $take_externref - (global.get $global_externref) + (call $take_eqref + (global.get $global_eqref) ) - (call $take_externref - (ref.null any) + (call $take_eqref + (ref.null eq) ) (call $take_funcref (local.get $local_funcref) @@ -170,13 +172,13 @@ (ref.null any) ) (call $take_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (call $take_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (call $take_anyref - (ref.null any) + (ref.null eq) ) (call $take_anyref (local.get $local_funcref) @@ -190,16 +192,16 @@ (call $take_anyref (ref.func $foo) ) - (call_indirect $0 (type $sig_anyref) - (local.get $local_externref) + (call_indirect $0 (type $sig_eqref) + (local.get $local_eqref) (i32.const 0) ) - (call_indirect $0 (type $sig_anyref) - (global.get $global_externref) + (call_indirect $0 (type $sig_eqref) + (global.get $global_eqref) (i32.const 0) ) - (call_indirect $0 (type $sig_anyref) - (ref.null any) + (call_indirect $0 (type $sig_eqref) + (ref.null eq) (i32.const 0) ) (call_indirect $0 (type $sig_funcref) @@ -231,15 +233,15 @@ (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (local.get $local_externref) + (local.get $local_eqref) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (global.get $global_externref) + (global.get $global_eqref) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (ref.null any) + (ref.null eq) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) @@ -259,25 +261,25 @@ (i32.const 3) ) (drop - (block $block (result anyref) + (block $block (result eqref) (br_if $block - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) ) (drop - (block $block0 (result anyref) + (block $block0 (result eqref) (br_if $block0 - (global.get $global_externref) + (global.get $global_eqref) (i32.const 1) ) ) ) (drop - (block $block1 (result anyref) + (block $block1 (result eqref) (br_if $block1 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -341,7 +343,7 @@ (drop (block $block9 (result anyref) (br_if $block9 - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) @@ -357,7 +359,7 @@ (drop (block $block11 (result anyref) (br_if $block11 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -379,18 +381,18 @@ ) ) (drop - (loop $loop-in (result anyref) - (local.get $local_externref) + (loop $loop-in (result eqref) + (local.get $local_eqref) ) ) (drop - (loop $loop-in14 (result anyref) - (global.get $global_externref) + (loop $loop-in14 (result eqref) + (global.get $global_eqref) ) ) (drop - (loop $loop-in15 (result anyref) - (ref.null any) + (loop $loop-in15 (result eqref) + (ref.null eq) ) ) (drop @@ -430,17 +432,17 @@ ) (drop (loop $loop-in23 (result anyref) - (local.get $local_externref) + (local.get $local_eqref) ) ) (drop (loop $loop-in24 (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) ) (drop (loop $loop-in25 (result anyref) - (ref.null any) + (ref.null eq) ) ) (drop @@ -464,10 +466,10 @@ ) ) (drop - (if (result anyref) + (if (result eqref) (i32.const 1) - (local.get $local_externref) - (ref.null any) + (local.get $local_eqref) + (ref.null eq) ) ) (drop @@ -487,14 +489,14 @@ (drop (if (result anyref) (i32.const 1) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) ) ) (drop (if (result anyref) (i32.const 1) - (ref.null any) + (ref.null eq) (ref.null func) ) ) @@ -502,19 +504,19 @@ (if (result anyref) (i32.const 1) (ref.func $foo) - (ref.null any) + (ref.null eq) ) ) (drop - (try $try (result anyref) + (try $try (result eqref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $e-i32 (drop (pop i32) ) - (ref.null any) + (ref.null eq) ) ) ) @@ -534,7 +536,7 @@ (drop (try $try36 (result anyref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $e-i32 (drop @@ -553,14 +555,14 @@ (drop (pop i32) ) - (local.get $local_externref) + (local.get $local_eqref) ) ) ) (drop - (select (result anyref) - (local.get $local_externref) - (ref.null any) + (select (result eqref) + (local.get $local_eqref) + (ref.null eq) (i32.const 1) ) ) @@ -580,7 +582,7 @@ ) (drop (select (result anyref) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) (i32.const 1) ) @@ -588,23 +590,23 @@ (drop (select (result anyref) (local.get $local_funcref) - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) (drop (ref.is_null - (local.get $local_externref) + (local.get $local_eqref) ) ) (drop (ref.is_null - (global.get $global_externref) + (global.get $global_eqref) ) ) (drop (ref.is_null - (ref.null any) + (ref.null eq) ) ) (drop @@ -643,15 +645,15 @@ ) ) ) - (func $return_externref_local (result anyref) - (local $local_externref anyref) - (local.get $local_externref) + (func $return_eqref_local (result eqref) + (local $local_eqref eqref) + (local.get $local_eqref) ) - (func $return_externref_global (result anyref) - (global.get $global_externref) + (func $return_eqref_global (result eqref) + (global.get $global_eqref) ) - (func $return_externref_null (result anyref) - (ref.null any) + (func $return_eqref_null (result eqref) + (ref.null eq) ) (func $return_funcref_local (result funcref) (local $local_funcref funcref) @@ -677,14 +679,14 @@ (ref.null any) ) (func $return_anyref2 (result anyref) - (local $local_externref anyref) - (local.get $local_externref) + (local $local_eqref eqref) + (local.get $local_eqref) ) (func $return_anyref3 (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) (func $return_anyref4 (result anyref) - (ref.null any) + (ref.null eq) ) (func $return_anyref5 (result anyref) (local $local_funcref funcref) @@ -699,16 +701,16 @@ (func $return_anyref8 (result anyref) (ref.func $foo) ) - (func $returns_externref (result anyref) - (local $local_externref anyref) + (func $returns_eqref (result eqref) + (local $local_eqref eqref) (return - (local.get $local_externref) + (local.get $local_eqref) ) (return - (global.get $global_externref) + (global.get $global_eqref) ) (return - (ref.null any) + (ref.null eq) ) ) (func $returns_funcref (result funcref) @@ -739,16 +741,16 @@ ) ) (func $returns_anyref2 (result anyref) - (local $local_externref anyref) + (local $local_eqref eqref) (local $local_funcref funcref) (return - (local.get $local_externref) + (local.get $local_eqref) ) (return - (global.get $global_externref) + (global.get $global_eqref) ) (return - (ref.null any) + (ref.null eq) ) (return (local.get $local_funcref) diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary index 37a57ac78..68ed3e63d 100644 --- a/test/reference-types.wast.fromBinary +++ b/test/reference-types.wast.fromBinary @@ -3,25 +3,27 @@ (type $sig_anyref (func (param anyref))) (type $sig_funcref (func (param funcref))) (type $none_=>_funcref (func (result funcref))) + (type $sig_eqref (func (param eqref))) (type $none_=>_none (func)) + (type $none_=>_eqref (func (result eqref))) (type $i32_=>_none (func (param i32))) - (type $anyref_=>_funcref (func (param anyref) (result funcref))) - (import "env" "import_global" (global $import_global anyref)) - (import "env" "import_func" (func $import_func (param anyref) (result funcref))) - (global $global_externref (mut anyref) (ref.null any)) + (type $eqref_=>_funcref (func (param eqref) (result funcref))) + (import "env" "import_global" (global $import_global eqref)) + (import "env" "import_func" (func $import_func (param eqref) (result funcref))) + (global $global_eqref (mut eqref) (ref.null eq)) (global $global_funcref (mut funcref) (ref.null func)) (global $global_funcref_func (mut funcref) (ref.func $foo)) (global $global_anyref (mut anyref) (ref.null any)) - (global $global_anyref2 (mut anyref) (ref.null any)) + (global $global_anyref2 (mut anyref) (ref.null eq)) (global $global_anyref3 (mut anyref) (ref.null func)) (global $global_anyref4 (mut anyref) (ref.func $foo)) (table $0 3 3 funcref) - (elem (i32.const 0) $take_externref $take_funcref $take_anyref) + (elem (i32.const 0) $take_eqref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) (tag $tag$0 (param i32)) (export "export_func" (func $import_func)) (export "export_global" (global $import_global)) - (func $take_externref (param $0 anyref) + (func $take_eqref (param $0 eqref) (nop) ) (func $take_funcref (param $0 funcref) @@ -34,17 +36,17 @@ (nop) ) (func $test - (local $local_externref anyref) - (local $local_anyref anyref) + (local $local_eqref eqref) (local $local_funcref funcref) - (local.set $local_externref - (local.get $local_externref) + (local $local_anyref anyref) + (local.set $local_eqref + (local.get $local_eqref) ) - (local.set $local_externref - (global.get $global_externref) + (local.set $local_eqref + (global.get $global_eqref) ) - (local.set $local_externref - (ref.null any) + (local.set $local_eqref + (ref.null eq) ) (local.set $local_funcref (local.get $local_funcref) @@ -68,13 +70,13 @@ (ref.null any) ) (local.set $local_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (local.set $local_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (local.set $local_anyref - (ref.null any) + (ref.null eq) ) (local.set $local_anyref (local.get $local_funcref) @@ -88,14 +90,14 @@ (local.set $local_anyref (ref.func $foo) ) - (global.set $global_externref - (global.get $global_externref) + (global.set $global_eqref + (global.get $global_eqref) ) - (global.set $global_externref - (local.get $local_externref) + (global.set $global_eqref + (local.get $local_eqref) ) - (global.set $global_externref - (ref.null any) + (global.set $global_eqref + (ref.null eq) ) (global.set $global_funcref (global.get $global_funcref) @@ -119,13 +121,13 @@ (ref.null any) ) (global.set $global_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (global.set $global_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (global.set $global_anyref - (ref.null any) + (ref.null eq) ) (global.set $global_anyref (global.get $global_funcref) @@ -139,14 +141,14 @@ (global.set $global_anyref (ref.func $foo) ) - (call $take_externref - (local.get $local_externref) + (call $take_eqref + (local.get $local_eqref) ) - (call $take_externref - (global.get $global_externref) + (call $take_eqref + (global.get $global_eqref) ) - (call $take_externref - (ref.null any) + (call $take_eqref + (ref.null eq) ) (call $take_funcref (local.get $local_funcref) @@ -170,13 +172,13 @@ (ref.null any) ) (call $take_anyref - (local.get $local_externref) + (local.get $local_eqref) ) (call $take_anyref - (global.get $global_externref) + (global.get $global_eqref) ) (call $take_anyref - (ref.null any) + (ref.null eq) ) (call $take_anyref (local.get $local_funcref) @@ -190,16 +192,16 @@ (call $take_anyref (ref.func $foo) ) - (call_indirect $0 (type $sig_anyref) - (local.get $local_externref) + (call_indirect $0 (type $sig_eqref) + (local.get $local_eqref) (i32.const 0) ) - (call_indirect $0 (type $sig_anyref) - (global.get $global_externref) + (call_indirect $0 (type $sig_eqref) + (global.get $global_eqref) (i32.const 0) ) - (call_indirect $0 (type $sig_anyref) - (ref.null any) + (call_indirect $0 (type $sig_eqref) + (ref.null eq) (i32.const 0) ) (call_indirect $0 (type $sig_funcref) @@ -231,15 +233,15 @@ (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (local.get $local_externref) + (local.get $local_eqref) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (global.get $global_externref) + (global.get $global_eqref) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) - (ref.null any) + (ref.null eq) (i32.const 3) ) (call_indirect $0 (type $sig_anyref) @@ -259,25 +261,25 @@ (i32.const 3) ) (drop - (block $label$1 (result anyref) + (block $label$1 (result eqref) (br_if $label$1 - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) ) (drop - (block $label$2 (result anyref) + (block $label$2 (result eqref) (br_if $label$2 - (global.get $global_externref) + (global.get $global_eqref) (i32.const 1) ) ) ) (drop - (block $label$3 (result anyref) + (block $label$3 (result eqref) (br_if $label$3 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -341,7 +343,7 @@ (drop (block $label$11 (result anyref) (br_if $label$11 - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) @@ -357,7 +359,7 @@ (drop (block $label$13 (result anyref) (br_if $label$13 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -379,18 +381,18 @@ ) ) (drop - (loop $label$16 (result anyref) - (local.get $local_externref) + (loop $label$16 (result eqref) + (local.get $local_eqref) ) ) (drop - (loop $label$17 (result anyref) - (global.get $global_externref) + (loop $label$17 (result eqref) + (global.get $global_eqref) ) ) (drop - (loop $label$18 (result anyref) - (ref.null any) + (loop $label$18 (result eqref) + (ref.null eq) ) ) (drop @@ -430,17 +432,17 @@ ) (drop (loop $label$26 (result anyref) - (local.get $local_externref) + (local.get $local_eqref) ) ) (drop (loop $label$27 (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) ) (drop (loop $label$28 (result anyref) - (ref.null any) + (ref.null eq) ) ) (drop @@ -464,10 +466,10 @@ ) ) (drop - (if (result anyref) + (if (result eqref) (i32.const 1) - (local.get $local_externref) - (ref.null any) + (local.get $local_eqref) + (ref.null eq) ) ) (drop @@ -487,14 +489,14 @@ (drop (if (result anyref) (i32.const 1) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) ) ) (drop (if (result anyref) (i32.const 1) - (ref.null any) + (ref.null eq) (ref.null func) ) ) @@ -502,19 +504,19 @@ (if (result anyref) (i32.const 1) (ref.func $foo) - (ref.null any) + (ref.null eq) ) ) (drop - (try $label$47 (result anyref) + (try $label$47 (result eqref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $tag$0 (drop (pop i32) ) - (ref.null any) + (ref.null eq) ) ) ) @@ -534,7 +536,7 @@ (drop (try $label$53 (result anyref) (do - (local.get $local_externref) + (local.get $local_eqref) ) (catch $tag$0 (drop @@ -553,14 +555,14 @@ (drop (pop i32) ) - (local.get $local_externref) + (local.get $local_eqref) ) ) ) (drop - (select (result anyref) - (local.get $local_externref) - (ref.null any) + (select (result eqref) + (local.get $local_eqref) + (ref.null eq) (i32.const 1) ) ) @@ -580,7 +582,7 @@ ) (drop (select (result anyref) - (local.get $local_externref) + (local.get $local_eqref) (local.get $local_funcref) (i32.const 1) ) @@ -588,23 +590,23 @@ (drop (select (result anyref) (local.get $local_funcref) - (local.get $local_externref) + (local.get $local_eqref) (i32.const 1) ) ) (drop (ref.is_null - (local.get $local_externref) + (local.get $local_eqref) ) ) (drop (ref.is_null - (global.get $global_externref) + (global.get $global_eqref) ) ) (drop (ref.is_null - (ref.null any) + (ref.null eq) ) ) (drop @@ -643,15 +645,15 @@ ) ) ) - (func $return_externref_local (result anyref) - (local $local_externref anyref) - (local.get $local_externref) + (func $return_eqref_local (result eqref) + (local $local_eqref eqref) + (local.get $local_eqref) ) - (func $return_externref_global (result anyref) - (global.get $global_externref) + (func $return_eqref_global (result eqref) + (global.get $global_eqref) ) - (func $return_externref_null (result anyref) - (ref.null any) + (func $return_eqref_null (result eqref) + (ref.null eq) ) (func $return_funcref_local (result funcref) (local $local_funcref funcref) @@ -677,14 +679,14 @@ (ref.null any) ) (func $return_anyref2 (result anyref) - (local $local_externref anyref) - (local.get $local_externref) + (local $local_eqref eqref) + (local.get $local_eqref) ) (func $return_anyref3 (result anyref) - (global.get $global_externref) + (global.get $global_eqref) ) (func $return_anyref4 (result anyref) - (ref.null any) + (ref.null eq) ) (func $return_anyref5 (result anyref) (local $local_funcref funcref) @@ -699,10 +701,10 @@ (func $return_anyref8 (result anyref) (ref.func $foo) ) - (func $returns_externref (result anyref) - (local $local_externref anyref) + (func $returns_eqref (result eqref) + (local $local_eqref eqref) (return - (local.get $local_externref) + (local.get $local_eqref) ) ) (func $returns_funcref (result funcref) @@ -718,10 +720,10 @@ ) ) (func $returns_anyref2 (result anyref) - (local $local_externref anyref) + (local $local_eqref eqref) (local $local_funcref funcref) (return - (local.get $local_externref) + (local.get $local_eqref) ) ) (func $ref-user diff --git a/test/reference-types.wast.fromBinary.noDebugInfo b/test/reference-types.wast.fromBinary.noDebugInfo index 42ad4026a..5caa085c9 100644 --- a/test/reference-types.wast.fromBinary.noDebugInfo +++ b/test/reference-types.wast.fromBinary.noDebugInfo @@ -3,16 +3,18 @@ (type $anyref_=>_none (func (param anyref))) (type $funcref_=>_none (func (param funcref))) (type $none_=>_funcref (func (result funcref))) + (type $eqref_=>_none (func (param eqref))) (type $none_=>_none (func)) + (type $none_=>_eqref (func (result eqref))) (type $i32_=>_none (func (param i32))) - (type $anyref_=>_funcref (func (param anyref) (result funcref))) - (import "env" "import_global" (global $gimport$0 anyref)) - (import "env" "import_func" (func $fimport$0 (param anyref) (result funcref))) - (global $global$0 (mut anyref) (ref.null any)) + (type $eqref_=>_funcref (func (param eqref) (result funcref))) + (import "env" "import_global" (global $gimport$0 eqref)) + (import "env" "import_func" (func $fimport$0 (param eqref) (result funcref))) + (global $global$0 (mut eqref) (ref.null eq)) (global $global$1 (mut funcref) (ref.null func)) (global $global$2 (mut funcref) (ref.func $3)) (global $global$3 (mut anyref) (ref.null any)) - (global $global$4 (mut anyref) (ref.null any)) + (global $global$4 (mut anyref) (ref.null eq)) (global $global$5 (mut anyref) (ref.null func)) (global $global$6 (mut anyref) (ref.func $3)) (table $0 3 3 funcref) @@ -21,7 +23,7 @@ (tag $tag$0 (param i32)) (export "export_func" (func $fimport$0)) (export "export_global" (global $gimport$0)) - (func $0 (param $0 anyref) + (func $0 (param $0 eqref) (nop) ) (func $1 (param $0 funcref) @@ -34,9 +36,9 @@ (nop) ) (func $4 - (local $0 anyref) - (local $1 anyref) - (local $2 funcref) + (local $0 eqref) + (local $1 funcref) + (local $2 anyref) (local.set $0 (local.get $0) ) @@ -44,48 +46,48 @@ (global.get $global$0) ) (local.set $0 - (ref.null any) + (ref.null eq) ) - (local.set $2 - (local.get $2) + (local.set $1 + (local.get $1) ) - (local.set $2 + (local.set $1 (global.get $global$1) ) - (local.set $2 + (local.set $1 (ref.null func) ) - (local.set $2 + (local.set $1 (ref.func $3) ) - (local.set $1 - (local.get $1) + (local.set $2 + (local.get $2) ) - (local.set $1 + (local.set $2 (global.get $global$3) ) - (local.set $1 + (local.set $2 (ref.null any) ) - (local.set $1 + (local.set $2 (local.get $0) ) - (local.set $1 + (local.set $2 (global.get $global$0) ) - (local.set $1 - (ref.null any) + (local.set $2 + (ref.null eq) ) - (local.set $1 - (local.get $2) + (local.set $2 + (local.get $1) ) - (local.set $1 + (local.set $2 (global.get $global$1) ) - (local.set $1 + (local.set $2 (ref.null func) ) - (local.set $1 + (local.set $2 (ref.func $3) ) (global.set $global$0 @@ -95,13 +97,13 @@ (local.get $0) ) (global.set $global$0 - (ref.null any) + (ref.null eq) ) (global.set $global$1 (global.get $global$1) ) (global.set $global$1 - (local.get $2) + (local.get $1) ) (global.set $global$1 (ref.null func) @@ -113,7 +115,7 @@ (global.get $global$3) ) (global.set $global$3 - (local.get $1) + (local.get $2) ) (global.set $global$3 (ref.null any) @@ -125,13 +127,13 @@ (local.get $0) ) (global.set $global$3 - (ref.null any) + (ref.null eq) ) (global.set $global$3 (global.get $global$1) ) (global.set $global$3 - (local.get $2) + (local.get $1) ) (global.set $global$3 (ref.null func) @@ -146,10 +148,10 @@ (global.get $global$0) ) (call $0 - (ref.null any) + (ref.null eq) ) (call $1 - (local.get $2) + (local.get $1) ) (call $1 (global.get $global$1) @@ -161,7 +163,7 @@ (ref.func $3) ) (call $2 - (local.get $1) + (local.get $2) ) (call $2 (global.get $global$3) @@ -176,10 +178,10 @@ (global.get $global$0) ) (call $2 - (ref.null any) + (ref.null eq) ) (call $2 - (local.get $2) + (local.get $1) ) (call $2 (global.get $global$1) @@ -190,20 +192,20 @@ (call $2 (ref.func $3) ) - (call_indirect $0 (type $anyref_=>_none) + (call_indirect $0 (type $eqref_=>_none) (local.get $0) (i32.const 0) ) - (call_indirect $0 (type $anyref_=>_none) + (call_indirect $0 (type $eqref_=>_none) (global.get $global$0) (i32.const 0) ) - (call_indirect $0 (type $anyref_=>_none) - (ref.null any) + (call_indirect $0 (type $eqref_=>_none) + (ref.null eq) (i32.const 0) ) (call_indirect $0 (type $funcref_=>_none) - (local.get $2) + (local.get $1) (i32.const 1) ) (call_indirect $0 (type $funcref_=>_none) @@ -219,7 +221,7 @@ (i32.const 1) ) (call_indirect $0 (type $anyref_=>_none) - (local.get $1) + (local.get $2) (i32.const 3) ) (call_indirect $0 (type $anyref_=>_none) @@ -239,11 +241,11 @@ (i32.const 3) ) (call_indirect $0 (type $anyref_=>_none) - (ref.null any) + (ref.null eq) (i32.const 3) ) (call_indirect $0 (type $anyref_=>_none) - (local.get $2) + (local.get $1) (i32.const 3) ) (call_indirect $0 (type $anyref_=>_none) @@ -259,7 +261,7 @@ (i32.const 3) ) (drop - (block $label$1 (result anyref) + (block $label$1 (result eqref) (br_if $label$1 (local.get $0) (i32.const 1) @@ -267,7 +269,7 @@ ) ) (drop - (block $label$2 (result anyref) + (block $label$2 (result eqref) (br_if $label$2 (global.get $global$0) (i32.const 1) @@ -275,9 +277,9 @@ ) ) (drop - (block $label$3 (result anyref) + (block $label$3 (result eqref) (br_if $label$3 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -285,7 +287,7 @@ (drop (block $label$4 (result funcref) (br_if $label$4 - (local.get $2) + (local.get $1) (i32.const 1) ) ) @@ -317,7 +319,7 @@ (drop (block $label$8 (result anyref) (br_if $label$8 - (local.get $1) + (local.get $2) (i32.const 1) ) ) @@ -349,7 +351,7 @@ (drop (block $label$12 (result anyref) (br_if $label$12 - (local.get $2) + (local.get $1) (i32.const 1) ) ) @@ -357,7 +359,7 @@ (drop (block $label$13 (result anyref) (br_if $label$13 - (ref.null any) + (ref.null eq) (i32.const 1) ) ) @@ -379,23 +381,23 @@ ) ) (drop - (loop $label$16 (result anyref) + (loop $label$16 (result eqref) (local.get $0) ) ) (drop - (loop $label$17 (result anyref) + (loop $label$17 (result eqref) (global.get $global$0) ) ) (drop - (loop $label$18 (result anyref) - (ref.null any) + (loop $label$18 (result eqref) + (ref.null eq) ) ) (drop (loop $label$19 (result funcref) - (local.get $2) + (local.get $1) ) ) (drop @@ -415,7 +417,7 @@ ) (drop (loop $label$23 (result anyref) - (local.get $1) + (local.get $2) ) ) (drop @@ -440,12 +442,12 @@ ) (drop (loop $label$28 (result anyref) - (ref.null any) + (ref.null eq) ) ) (drop (loop $label$29 (result anyref) - (local.get $2) + (local.get $1) ) ) (drop @@ -464,23 +466,23 @@ ) ) (drop - (if (result anyref) + (if (result eqref) (i32.const 1) (local.get $0) - (ref.null any) + (ref.null eq) ) ) (drop (if (result funcref) (i32.const 1) - (local.get $2) + (local.get $1) (ref.null func) ) ) (drop (if (result anyref) (i32.const 1) - (local.get $1) + (local.get $2) (ref.null any) ) ) @@ -488,13 +490,13 @@ (if (result anyref) (i32.const 1) (local.get $0) - (local.get $2) + (local.get $1) ) ) (drop (if (result anyref) (i32.const 1) - (ref.null any) + (ref.null eq) (ref.null func) ) ) @@ -502,11 +504,11 @@ (if (result anyref) (i32.const 1) (ref.func $3) - (ref.null any) + (ref.null eq) ) ) (drop - (try $label$47 (result anyref) + (try $label$47 (result eqref) (do (local.get $0) ) @@ -514,7 +516,7 @@ (drop (pop i32) ) - (ref.null any) + (ref.null eq) ) ) ) @@ -558,15 +560,15 @@ ) ) (drop - (select (result anyref) + (select (result eqref) (local.get $0) - (ref.null any) + (ref.null eq) (i32.const 1) ) ) (drop (select (result funcref) - (local.get $2) + (local.get $1) (ref.null func) (i32.const 1) ) @@ -581,13 +583,13 @@ (drop (select (result anyref) (local.get $0) - (local.get $2) + (local.get $1) (i32.const 1) ) ) (drop (select (result anyref) - (local.get $2) + (local.get $1) (local.get $0) (i32.const 1) ) @@ -604,12 +606,12 @@ ) (drop (ref.is_null - (ref.null any) + (ref.null eq) ) ) (drop (ref.is_null - (local.get $2) + (local.get $1) ) ) (drop @@ -629,7 +631,7 @@ ) (drop (ref.is_null - (local.get $1) + (local.get $2) ) ) (drop @@ -643,15 +645,15 @@ ) ) ) - (func $5 (result anyref) - (local $0 anyref) + (func $5 (result eqref) + (local $0 eqref) (local.get $0) ) - (func $6 (result anyref) + (func $6 (result eqref) (global.get $global$0) ) - (func $7 (result anyref) - (ref.null any) + (func $7 (result eqref) + (ref.null eq) ) (func $8 (result funcref) (local $0 funcref) @@ -677,14 +679,14 @@ (ref.null any) ) (func $15 (result anyref) - (local $0 anyref) + (local $0 eqref) (local.get $0) ) (func $16 (result anyref) (global.get $global$0) ) (func $17 (result anyref) - (ref.null any) + (ref.null eq) ) (func $18 (result anyref) (local $0 funcref) @@ -699,8 +701,8 @@ (func $21 (result anyref) (ref.func $3) ) - (func $22 (result anyref) - (local $0 anyref) + (func $22 (result eqref) + (local $0 eqref) (return (local.get $0) ) @@ -718,7 +720,7 @@ ) ) (func $25 (result anyref) - (local $0 anyref) + (local $0 eqref) (local $1 funcref) (return (local.get $0) diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 5c22886fb..03862d4cc 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -343,7 +343,7 @@ class TargetFeaturesSectionTest(utils.BinaryenTestCase): self.roundtrip(filename) self.check_features(filename, ['reference-types', 'gc']) disassembly = self.disassemble(filename) - self.assertIn('anyref', disassembly) + self.assertIn('externref', disassembly) self.assertIn('eqref', disassembly) def test_superset(self): |