diff options
55 files changed, 341 insertions, 512 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 43407c611..655f2aa8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,8 @@ Current Trunk has been removed. - `ref.is_func`, `ref.is_data`, and `ref.is_i31` have been removed from the C and JS APIs and `RefIs` has been replaced with `RefIsNull`. +- Types `Data` and `Dataref` have been replaced with types `Struct` and + `Structref` in the C and JS APIs. v111 ---- diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index e452f82d6..6572cda49 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -581,8 +581,6 @@ instructions = [ ("br_on_cast_static_fail", "makeBrOnCast(s, std::nullopt, true)"), ("br_on_func", "makeBrOnCast(s, Type(HeapType::func, NonNullable))"), ("br_on_non_func", "makeBrOnCast(s, Type(HeapType::func, NonNullable), true)"), - ("br_on_data", "makeBrOnCast(s, Type(HeapType::data, NonNullable))"), - ("br_on_non_data", "makeBrOnCast(s, Type(HeapType::data, NonNullable), true)"), ("br_on_i31", "makeBrOnCast(s, Type(HeapType::i31, NonNullable))"), ("br_on_non_i31", "makeBrOnCast(s, Type(HeapType::i31, NonNullable), true)"), ("struct.new", "makeStructNew(s, false)"), @@ -603,11 +601,9 @@ instructions = [ ("array.len", "makeArrayLen(s)"), ("array.copy", "makeArrayCopy(s)"), ("ref.is_func", "makeRefTest(s, Type(HeapType::func, NonNullable))"), - ("ref.is_data", "makeRefTest(s, Type(HeapType::data, NonNullable))"), ("ref.is_i31", "makeRefTest(s, Type(HeapType::i31, NonNullable))"), ("ref.as_non_null", "makeRefAs(s, RefAsNonNull)"), ("ref.as_func", "makeRefCast(s, Type(HeapType::func, NonNullable))"), - ("ref.as_data", "makeRefCast(s, Type(HeapType::data, NonNullable))"), ("ref.as_i31", "makeRefCast(s, Type(HeapType::i31, NonNullable))"), ("extern.internalize", "makeRefAs(s, ExternInternalize)"), ("extern.externalize", "makeRefAs(s, ExternExternalize)"), diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index e37270f61..f195e6c59 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -85,7 +85,7 @@ BinaryenLiteral toBinaryenLiteral(Literal x) { WASM_UNREACHABLE("TODO: extern literals"); case HeapType::eq: case HeapType::func: - case HeapType::data: + case HeapType::struct_: case HeapType::array: WASM_UNREACHABLE("invalid type"); case HeapType::string: @@ -138,7 +138,7 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) { WASM_UNREACHABLE("TODO: extern literals"); case HeapType::eq: case HeapType::func: - case HeapType::data: + case HeapType::struct_: case HeapType::array: WASM_UNREACHABLE("invalid type"); case HeapType::string: @@ -199,8 +199,8 @@ BinaryenType BinaryenTypeEqref(void) { BinaryenType BinaryenTypeI31ref(void) { return Type(HeapType::i31, Nullable).getID(); } -BinaryenType BinaryenTypeDataref(void) { - return Type(HeapType::data, Nullable).getID(); +BinaryenType BinaryenTypeStructref(void) { + return Type(HeapType::struct_, Nullable).getID(); } BinaryenType BinaryenTypeArrayref(void) { return Type(HeapType::array, Nullable).getID(); @@ -284,8 +284,8 @@ BinaryenHeapType BinaryenHeapTypeEq() { BinaryenHeapType BinaryenHeapTypeI31() { return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::i31); } -BinaryenHeapType BinaryenHeapTypeData() { - return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::data); +BinaryenHeapType BinaryenHeapTypeStruct() { + return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::struct_); } BinaryenHeapType BinaryenHeapTypeArray() { return static_cast<BinaryenHeapType>(HeapType::BasicHeapType::array); diff --git a/src/binaryen-c.h b/src/binaryen-c.h index b9f78e2a7..cd5bd6735 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -104,7 +104,7 @@ BINARYEN_API BinaryenType BinaryenTypeExternref(void); BINARYEN_API BinaryenType BinaryenTypeAnyref(void); BINARYEN_API BinaryenType BinaryenTypeEqref(void); BINARYEN_API BinaryenType BinaryenTypeI31ref(void); -BINARYEN_API BinaryenType BinaryenTypeDataref(void); +BINARYEN_API BinaryenType BinaryenTypeStructref(void); BINARYEN_API BinaryenType BinaryenTypeArrayref(void); BINARYEN_API BinaryenType BinaryenTypeStringref(void); BINARYEN_API BinaryenType BinaryenTypeStringviewWTF8(void); @@ -146,7 +146,7 @@ BINARYEN_API BinaryenHeapType BinaryenHeapTypeFunc(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeAny(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeEq(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeI31(void); -BINARYEN_API BinaryenHeapType BinaryenHeapTypeData(void); +BINARYEN_API BinaryenHeapType BinaryenHeapTypeStruct(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeArray(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeString(void); BINARYEN_API BinaryenHeapType BinaryenHeapTypeStringviewWTF8(void); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index dbf3b71bf..b44329388 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -124,9 +124,6 @@ switch (buf[0]) { default: goto parse_error; } } - case 'd': - if (op == "br_on_data"sv) { return makeBrOnCast(s, Type(HeapType::data, NonNullable)); } - goto parse_error; case 'f': if (op == "br_on_func"sv) { return makeBrOnCast(s, Type(HeapType::func, NonNullable)); } goto parse_error; @@ -137,9 +134,6 @@ switch (buf[0]) { switch (buf[7]) { case 'o': { switch (buf[10]) { - case 'd': - if (op == "br_on_non_data"sv) { return makeBrOnCast(s, Type(HeapType::data, NonNullable), true); } - goto parse_error; case 'f': if (op == "br_on_non_func"sv) { return makeBrOnCast(s, Type(HeapType::func, NonNullable), true); } goto parse_error; @@ -2999,9 +2993,6 @@ switch (buf[0]) { switch (buf[4]) { case 'a': { switch (buf[7]) { - case 'd': - if (op == "ref.as_data"sv) { return makeRefCast(s, Type(HeapType::data, NonNullable)); } - goto parse_error; case 'f': if (op == "ref.as_func"sv) { return makeRefCast(s, Type(HeapType::func, NonNullable)); } goto parse_error; @@ -3049,9 +3040,6 @@ switch (buf[0]) { goto parse_error; case 'i': { switch (buf[7]) { - case 'd': - if (op == "ref.is_data"sv) { return makeRefTest(s, Type(HeapType::data, NonNullable)); } - goto parse_error; case 'f': if (op == "ref.is_func"sv) { return makeRefTest(s, Type(HeapType::func, NonNullable)); } goto parse_error; @@ -3766,13 +3754,6 @@ switch (buf[0]) { default: goto parse_error; } } - case 'd': - if (op == "br_on_data"sv) { - auto ret = makeBrOnCast(ctx, pos, Type(HeapType::data, NonNullable)); - CHECK_ERR(ret); - return *ret; - } - goto parse_error; case 'f': if (op == "br_on_func"sv) { auto ret = makeBrOnCast(ctx, pos, Type(HeapType::func, NonNullable)); @@ -3791,13 +3772,6 @@ switch (buf[0]) { switch (buf[7]) { case 'o': { switch (buf[10]) { - case 'd': - if (op == "br_on_non_data"sv) { - auto ret = makeBrOnCast(ctx, pos, Type(HeapType::data, NonNullable), true); - CHECK_ERR(ret); - return *ret; - } - goto parse_error; case 'f': if (op == "br_on_non_func"sv) { auto ret = makeBrOnCast(ctx, pos, Type(HeapType::func, NonNullable), true); @@ -8597,13 +8571,6 @@ switch (buf[0]) { switch (buf[4]) { case 'a': { switch (buf[7]) { - case 'd': - if (op == "ref.as_data"sv) { - auto ret = makeRefCast(ctx, pos, Type(HeapType::data, NonNullable)); - CHECK_ERR(ret); - return *ret; - } - goto parse_error; case 'f': if (op == "ref.as_func"sv) { auto ret = makeRefCast(ctx, pos, Type(HeapType::func, NonNullable)); @@ -8687,13 +8654,6 @@ switch (buf[0]) { goto parse_error; case 'i': { switch (buf[7]) { - case 'd': - if (op == "ref.is_data"sv) { - auto ret = makeRefTest(ctx, pos, Type(HeapType::data, NonNullable)); - CHECK_ERR(ret); - return *ret; - } - goto parse_error; case 'f': if (op == "ref.is_func"sv) { auto ret = makeRefTest(ctx, pos, Type(HeapType::func, NonNullable)); diff --git a/src/ir/subtypes.h b/src/ir/subtypes.h index bc14c1d4f..c895828f1 100644 --- a/src/ir/subtypes.h +++ b/src/ir/subtypes.h @@ -113,7 +113,7 @@ struct SubTypes { for (auto type : types) { HeapType basic; if (type.isStruct()) { - basic = HeapType::data; + basic = HeapType::struct_; } else if (type.isArray()) { basic = HeapType::array; } else { @@ -123,9 +123,8 @@ struct SubTypes { depths[basic] = std::max(depths[basic], depths[type] + 1); } - depths[HeapType::data] = - std::max(depths[HeapType::data], depths[HeapType::array] + 1); - depths[HeapType::eq] = std::max(Index(1), depths[HeapType::data] + 1); + depths[HeapType::eq] = + std::max(depths[HeapType::struct_], depths[HeapType::array]) + 1; depths[HeapType::any] = depths[HeapType::eq] + 1; return depths; diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index da121e23a..86b063c0e 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -38,7 +38,7 @@ function initializeConstants() { ['anyref', 'Anyref'], ['eqref', 'Eqref'], ['i31ref', 'I31ref'], - ['dataref', 'Dataref'], + ['structref', 'Structref'], ['stringref', 'Stringref'], ['stringview_wtf8', 'StringviewWTF8'], ['stringview_wtf16', 'StringviewWTF16'], @@ -2302,9 +2302,9 @@ function wrapModule(module, self = {}) { } }; - self['dataref'] = { + self['structref'] = { 'pop'() { - return Module['_BinaryenPop'](module, Module['dataref']); + return Module['_BinaryenPop'](module, Module['structref']); } }; diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index e0d9a46a3..38e88fde5 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -105,8 +105,8 @@ bool maybePrintRefShorthand(std::ostream& o, Type type) { case HeapType::i31: o << "i31ref"; return true; - case HeapType::data: - o << "dataref"; + case HeapType::struct_: + o << "structref"; return true; case HeapType::array: o << "arrayref"; @@ -2099,9 +2099,6 @@ struct PrintExpressionContents case HeapType::func: printMedium(o, "ref.is_func"); return; - case HeapType::data: - printMedium(o, "ref.is_data"); - return; case HeapType::i31: printMedium(o, "ref.is_i31"); return; @@ -2129,9 +2126,6 @@ struct PrintExpressionContents case HeapType::func: printMedium(o, "ref.as_func"); return; - case HeapType::data: - printMedium(o, "ref.as_data"); - return; case HeapType::i31: printMedium(o, "ref.as_i31"); return; @@ -2167,10 +2161,6 @@ struct PrintExpressionContents printMedium(o, "br_on_func "); printName(curr->name, o); return; - case HeapType::data: - printMedium(o, "br_on_data "); - printName(curr->name, o); - return; case HeapType::i31: printMedium(o, "br_on_i31 "); printName(curr->name, o); @@ -2196,10 +2186,6 @@ struct PrintExpressionContents printMedium(o, "br_on_non_func "); printName(curr->name, o); return; - case HeapType::data: - printMedium(o, "br_on_non_data "); - printName(curr->name, o); - return; case HeapType::i31: printMedium(o, "br_on_non_i31 "); printName(curr->name, o); diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index 18568271b..98f9ea733 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -2041,7 +2041,18 @@ Expression* TranslateToFuzzReader::makeConstBasicRef(Type type) { // Choose a subtype we can materialize a constant for. We cannot // materialize non-nullable refs to func or i31 in global contexts. Nullability nullability = getSubType(type.getNullability()); - HeapType subtype = oneIn(2) ? HeapType::i31 : HeapType::data; + HeapType subtype; + switch (upTo(3)) { + case 0: + subtype = HeapType::i31; + break; + case 1: + subtype = HeapType::struct_; + break; + case 2: + subtype = HeapType::array; + break; + } return makeConst(Type(subtype, nullability)); } case HeapType::eq: { @@ -2055,10 +2066,16 @@ Expression* TranslateToFuzzReader::makeConstBasicRef(Type type) { auto nullability = getSubType(type.getNullability()); // i31.new is not allowed in initializer expressions. HeapType subtype; - if (funcContext) { - subtype = pick(HeapType::i31, HeapType::data); - } else { - subtype = HeapType::data; + switch (upTo(3)) { + case 0: + subtype = HeapType::i31; + break; + case 1: + subtype = HeapType::struct_; + break; + case 2: + subtype = HeapType::array; + break; } return makeConst(Type(subtype, nullability)); } @@ -2069,17 +2086,15 @@ Expression* TranslateToFuzzReader::makeConstBasicRef(Type type) { } return builder.makeI31New(makeConst(Type::i32)); } - case HeapType::data: + case HeapType::struct_: { assert(wasm.features.hasGC()); // TODO: Construct nontrivial types. For now just create a hard coded - // struct or array. - if (oneIn(2)) { - // Use a local static to avoid creating a fresh nominal types in - // --nominal mode. - static HeapType trivialStruct = HeapType(Struct()); - return builder.makeStructNew(trivialStruct, std::vector<Expression*>{}); - } - [[fallthrough]]; + // struct. + // Use a local static to avoid creating a fresh nominal types in + // --nominal mode. + static HeapType trivialStruct = HeapType(Struct()); + return builder.makeStructNew(trivialStruct, std::vector<Expression*>{}); + } case HeapType::array: { // Use a local static to avoid creating a fresh nominal types in // --nominal mode. @@ -3051,8 +3066,8 @@ Type TranslateToFuzzReader::getSingleConcreteType() { Type(HeapType::eq, NonNullable), Type(HeapType::i31, Nullable), // Type(HeapType::i31, NonNullable), - Type(HeapType::data, Nullable), - Type(HeapType::data, NonNullable), + Type(HeapType::struct_, Nullable), + Type(HeapType::struct_, NonNullable), Type(HeapType::array, Nullable), Type(HeapType::array, NonNullable))); } @@ -3068,8 +3083,10 @@ Type TranslateToFuzzReader::getReferenceType() { Type(HeapType::eq, NonNullable), Type(HeapType::i31, Nullable), Type(HeapType::i31, NonNullable), - Type(HeapType::data, Nullable), - Type(HeapType::data, NonNullable))); + Type(HeapType::struct_, Nullable), + Type(HeapType::struct_, NonNullable), + Type(HeapType::array, Nullable), + Type(HeapType::array, NonNullable))); } Type TranslateToFuzzReader::getEqReferenceType() { @@ -3079,8 +3096,10 @@ Type TranslateToFuzzReader::getEqReferenceType() { Type(HeapType::eq, NonNullable), Type(HeapType::i31, Nullable), Type(HeapType::i31, NonNullable), - Type(HeapType::data, Nullable), - Type(HeapType::data, NonNullable))); + Type(HeapType::struct_, Nullable), + Type(HeapType::struct_, NonNullable), + Type(HeapType::array, Nullable), + Type(HeapType::array, NonNullable))); } Type TranslateToFuzzReader::getMVPType() { @@ -3172,7 +3191,7 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) { return pick(HeapType::any, HeapType::eq, HeapType::i31, - HeapType::data, + HeapType::struct_, HeapType::array, HeapType::none); case HeapType::eq: @@ -3181,14 +3200,14 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) { assert(wasm.features.hasGC()); return pick(HeapType::eq, HeapType::i31, - HeapType::data, + HeapType::struct_, HeapType::array, HeapType::none); case HeapType::i31: return pick(HeapType::i31, HeapType::none); - case HeapType::data: + case HeapType::struct_: // TODO: nontrivial types as well. - return pick(HeapType::data, HeapType::array, HeapType::none); + return pick(HeapType::struct_, HeapType::none); case HeapType::array: return pick(HeapType::array, HeapType::none); case HeapType::string: diff --git a/src/tools/fuzzing/heap-types.cpp b/src/tools/fuzzing/heap-types.cpp index 7d7b4cb8d..8b9d824d1 100644 --- a/src/tools/fuzzing/heap-types.cpp +++ b/src/tools/fuzzing/heap-types.cpp @@ -158,7 +158,7 @@ struct HeapTypeGeneratorImpl { HeapType::any, HeapType::eq, HeapType::i31, - HeapType::data, + HeapType::struct_, HeapType::array); } @@ -273,7 +273,7 @@ struct HeapTypeGeneratorImpl { } else if (rand.oneIn(2)) { return HeapType::none; } else { - return HeapType::data; + return HeapType::struct_; } } @@ -339,7 +339,7 @@ struct HeapTypeGeneratorImpl { return pickSubEq(); case HeapType::i31: return HeapType::i31; - case HeapType::data: + case HeapType::struct_: return pickSubStruct(); case HeapType::array: return pickSubArray(); @@ -466,18 +466,16 @@ struct HeapTypeGeneratorImpl { } [[fallthrough]]; case HeapType::eq: - switch (rand.upTo(4)) { + switch (rand.upTo(3)) { case 0: return HeapType::i31; case 1: - return HeapType::data; - case 2: return StructKind{}; - case 3: + case 2: return ArrayKind{}; } WASM_UNREACHABLE("unexpected index"); - case HeapType::data: + case HeapType::struct_: return StructKind{}; case HeapType::array: return ArrayKind{}; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index b2e1ef0c6..afb48106e 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -373,7 +373,7 @@ enum EncodedType { // integer reference type i31ref = -0x16, // 0x6a // gc and string reference types - dataref = -0x19, // 0x67 + structref = -0x19, // 0x67 arrayref = -0x1a, // 0x66 stringref = -0x1c, // 0x64 stringview_wtf8 = -0x1d, // 0x63 @@ -399,14 +399,14 @@ enum EncodedType { }; enum EncodedHeapType { - func = -0x10, // 0x70 - ext = -0x11, // 0x6f - any = -0x12, // 0x6e - eq = -0x13, // 0x6d - i31 = -0x16, // 0x6a - data = -0x19, // 0x67 - array = -0x1a, // 0x66 - string = -0x1c, // 0x64 + func = -0x10, // 0x70 + ext = -0x11, // 0x6f + any = -0x12, // 0x6e + eq = -0x13, // 0x6d + i31 = -0x16, // 0x6a + struct_ = -0x19, // 0x67 + array = -0x1a, // 0x66 + string = -0x1c, // 0x64 // stringview/iter constants are identical to type, and cannot be duplicated // here as that would be a compiler error, so add _heap suffixes. See // https://github.com/WebAssembly/stringref/issues/12 @@ -1131,16 +1131,12 @@ enum ASTNodes { BrOnCastFailNull = 0x4b, RefCastNop = 0x4c, RefIsFunc = 0x50, - RefIsData = 0x51, RefIsI31 = 0x52, RefAsFunc = 0x58, - RefAsData = 0x59, RefAsI31 = 0x5a, BrOnFunc = 0x60, - BrOnData = 0x61, BrOnI31 = 0x62, BrOnNonFunc = 0x63, - BrOnNonData = 0x64, BrOnNonI31 = 0x65, ExternInternalize = 0x70, ExternExternalize = 0x71, diff --git a/src/wasm-type.h b/src/wasm-type.h index cfd57dd02..a359ea794 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -144,7 +144,7 @@ public: // │ anyref ║ x │ │ x │ x │ f? n │ │ f_unc // │ eqref ║ x │ │ x │ x │ n │ │ n_ullable // │ i31ref ║ x │ │ x │ x │ n │ │ - // │ dataref ║ x │ │ x │ x │ n │ │ + // │ structref ║ x │ │ x │ x │ n │ │ // ├─ Compound ──╫───┼───┼───┼───┤───────┤ │ // │ Ref ║ │ x │ x │ x │ f? n? │◄┘ // │ Tuple ║ │ x │ │ x │ │ @@ -323,7 +323,7 @@ public: any, eq, i31, - data, + struct_, array, string, stringview_wtf8, diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 7890c7a42..34f3d250d 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -125,7 +125,7 @@ Literal::Literal(const Literal& other) : type(other.type) { WASM_UNREACHABLE("TODO: extern literals"); case HeapType::eq: case HeapType::func: - case HeapType::data: + case HeapType::struct_: case HeapType::array: WASM_UNREACHABLE("invalid type"); case HeapType::string: @@ -574,7 +574,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { WASM_UNREACHABLE("TODO: extern literals"); case HeapType::eq: case HeapType::func: - case HeapType::data: + case HeapType::struct_: case HeapType::array: WASM_UNREACHABLE("invalid type"); case HeapType::string: diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 767e0c2ab..abd51fcef 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1408,8 +1408,8 @@ void WasmBinaryWriter::writeType(Type type) { case HeapType::i31: o << S32LEB(BinaryConsts::EncodedType::i31ref); return; - case HeapType::data: - o << S32LEB(BinaryConsts::EncodedType::dataref); + case HeapType::struct_: + o << S32LEB(BinaryConsts::EncodedType::structref); return; case HeapType::array: o << S32LEB(BinaryConsts::EncodedType::arrayref); @@ -1517,8 +1517,8 @@ void WasmBinaryWriter::writeHeapType(HeapType type) { case HeapType::i31: ret = BinaryConsts::EncodedHeapType::i31; break; - case HeapType::data: - ret = BinaryConsts::EncodedHeapType::data; + case HeapType::struct_: + ret = BinaryConsts::EncodedHeapType::struct_; break; case HeapType::array: ret = BinaryConsts::EncodedHeapType::array; @@ -1887,8 +1887,8 @@ bool WasmBinaryBuilder::getBasicType(int32_t code, Type& out) { case BinaryConsts::EncodedType::i31ref: out = Type(HeapType::i31, Nullable); return true; - case BinaryConsts::EncodedType::dataref: - out = Type(HeapType::data, Nullable); + case BinaryConsts::EncodedType::structref: + out = Type(HeapType::struct_, Nullable); return true; case BinaryConsts::EncodedType::arrayref: out = Type(HeapType::array, Nullable); @@ -1936,8 +1936,8 @@ bool WasmBinaryBuilder::getBasicHeapType(int64_t code, HeapType& out) { case BinaryConsts::EncodedHeapType::i31: out = HeapType::i31; return true; - case BinaryConsts::EncodedHeapType::data: - out = HeapType::data; + case BinaryConsts::EncodedHeapType::struct_: + out = HeapType::struct_; return true; case BinaryConsts::EncodedHeapType::array: out = HeapType::array; @@ -2240,7 +2240,13 @@ void WasmBinaryBuilder::readTypes() { "The only allowed trivial supertype for functions is func"); } } else { - if (basicSuper != HeapType::data) { + // Check for "struct" here even if we are parsing an array definition. + // This is the old nonstandard "struct_subtype" or "array_subtype" + // form of type definitions that used the old "data" type as the + // supertype placeholder when there was no nontrivial supertype. + // "data" no longer exists, but "struct" has the same encoding it used + // to have. + if (basicSuper != HeapType::struct_) { throwError("The only allowed trivial supertype for structs and " "arrays is data"); } @@ -4024,14 +4030,12 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) { break; } if (opcode == BinaryConsts::RefIsFunc || - opcode == BinaryConsts::RefIsData || opcode == BinaryConsts::RefIsI31) { visitRefIs((curr = allocator.alloc<RefTest>())->cast<RefTest>(), opcode); break; } if (opcode == BinaryConsts::RefAsFunc || - opcode == BinaryConsts::RefAsData || opcode == BinaryConsts::RefAsI31) { visitRefAsCast((curr = allocator.alloc<RefCast>())->cast<RefCast>(), opcode); @@ -6608,9 +6612,6 @@ void WasmBinaryBuilder::visitRefIs(RefTest* curr, uint8_t code) { case BinaryConsts::RefIsFunc: curr->castType = Type(HeapType::func, NonNullable); break; - case BinaryConsts::RefIsData: - curr->castType = Type(HeapType::data, NonNullable); - break; case BinaryConsts::RefIsI31: curr->castType = Type(HeapType::i31, NonNullable); break; @@ -6920,9 +6921,6 @@ void WasmBinaryBuilder::visitRefAsCast(RefCast* curr, uint32_t code) { case BinaryConsts::RefAsFunc: curr->type = Type(HeapType::func, NonNullable); break; - case BinaryConsts::RefAsData: - curr->type = Type(HeapType::data, NonNullable); - break; case BinaryConsts::RefAsI31: curr->type = Type(HeapType::i31, NonNullable); break; @@ -6985,14 +6983,6 @@ bool WasmBinaryBuilder::maybeVisitBrOn(Expression*& out, uint32_t code) { op = BrOnCastFail; castType = Type(HeapType::func, NonNullable); break; - case BinaryConsts::BrOnData: - op = BrOnCast; - castType = Type(HeapType::data, NonNullable); - break; - case BinaryConsts::BrOnNonData: - op = BrOnCastFail; - castType = Type(HeapType::data, NonNullable); - break; case BinaryConsts::BrOnI31: op = BrOnCast; castType = Type(HeapType::i31, NonNullable); diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 03dba223b..1087eedc6 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -1190,9 +1190,8 @@ Type SExpressionWasmBuilder::stringToType(std::string_view str, if (str.substr(0, 6) == "i31ref" && (prefix || str.size() == 6)) { return Type(HeapType::i31, Nullable); } - if ((str.substr(0, 7) == "dataref" && (prefix || str.size() == 7)) || - (str.substr(0, 9) == "structref" && (prefix || str.size() == 9))) { - return Type(HeapType::data, Nullable); + if (str.substr(0, 9) == "structref" && (prefix || str.size() == 9)) { + return Type(HeapType::struct_, Nullable); } if (str.substr(0, 8) == "arrayref" && (prefix || str.size() == 8)) { return Type(HeapType::array, Nullable); @@ -1242,9 +1241,8 @@ HeapType SExpressionWasmBuilder::stringToHeapType(std::string_view str, if (str.substr(0, 3) == "i31" && (prefix || str.size() == 3)) { return HeapType::i31; } - if ((str.substr(0, 4) == "data" && (prefix || str.size() == 4)) || - (str.substr(0, 6) == "struct" && (prefix || str.size() == 6))) { - return HeapType::data; + if (str.substr(0, 6) == "struct" && (prefix || str.size() == 6)) { + return HeapType::struct_; } if (str.substr(0, 5) == "array" && (prefix || str.size() == 5)) { return HeapType::array; diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index c4e1a863c..35ef12993 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2017,9 +2017,6 @@ void BinaryInstWriter::visitRefTest(RefTest* curr) { case HeapType::func: o << U32LEB(BinaryConsts::RefIsFunc); return; - case HeapType::data: - o << U32LEB(BinaryConsts::RefIsData); - return; case HeapType::i31: o << U32LEB(BinaryConsts::RefIsI31); return; @@ -2048,9 +2045,6 @@ void BinaryInstWriter::visitRefCast(RefCast* curr) { case HeapType::func: o << U32LEB(BinaryConsts::RefAsFunc); return; - case HeapType::data: - o << U32LEB(BinaryConsts::RefAsData); - return; case HeapType::i31: o << U32LEB(BinaryConsts::RefAsI31); return; @@ -2087,10 +2081,6 @@ void BinaryInstWriter::visitBrOn(BrOn* curr) { o << U32LEB(BinaryConsts::BrOnFunc); o << U32LEB(getBreakIndex(curr->name)); return; - case HeapType::data: - o << U32LEB(BinaryConsts::BrOnData); - o << U32LEB(getBreakIndex(curr->name)); - return; case HeapType::i31: o << U32LEB(BinaryConsts::BrOnI31); o << U32LEB(getBreakIndex(curr->name)); @@ -2117,10 +2107,6 @@ void BinaryInstWriter::visitBrOn(BrOn* curr) { o << U32LEB(BinaryConsts::BrOnNonFunc); o << U32LEB(getBreakIndex(curr->name)); return; - case HeapType::data: - o << U32LEB(BinaryConsts::BrOnNonData); - o << U32LEB(getBreakIndex(curr->name)); - return; case HeapType::i31: o << U32LEB(BinaryConsts::BrOnNonI31); o << U32LEB(getBreakIndex(curr->name)); diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index b65debc73..d06bfcbe7 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -486,7 +486,7 @@ HeapType::BasicHeapType getBasicHeapSupertype(HeapType type) { case HeapTypeInfo::SignatureKind: return HeapType::func; case HeapTypeInfo::StructKind: - return HeapType::data; + return HeapType::struct_; case HeapTypeInfo::ArrayKind: return HeapType::array; } @@ -518,18 +518,19 @@ std::optional<HeapType> getBasicHeapTypeLUB(HeapType::BasicHeapType a, case HeapType::any: return {HeapType::any}; case HeapType::eq: - if (b == HeapType::i31 || b == HeapType::data || b == HeapType::array) { + if (b == HeapType::i31 || b == HeapType::struct_ || + b == HeapType::array) { return {HeapType::eq}; } return {HeapType::any}; case HeapType::i31: - if (b == HeapType::data || b == HeapType::array) { + if (b == HeapType::struct_ || b == HeapType::array) { return {HeapType::eq}; } return {HeapType::any}; - case HeapType::data: + case HeapType::struct_: if (b == HeapType::array) { - return {HeapType::data}; + return {HeapType::eq}; } return {HeapType::any}; case HeapType::array: @@ -1014,7 +1015,7 @@ FeatureSet Type::getFeatures() const { case HeapType::any: case HeapType::eq: case HeapType::i31: - case HeapType::data: + case HeapType::struct_: case HeapType::array: return FeatureSet::ReferenceTypes | FeatureSet::GC; case HeapType::string: @@ -1266,7 +1267,7 @@ bool HeapType::isFunction() const { bool HeapType::isData() const { if (isBasic()) { - return id == data; + return id == struct_ || id == array; } else { return getHeapTypeInfo(*this)->isData(); } @@ -1304,7 +1305,7 @@ bool HeapType::isBottom() const { case any: case eq: case i31: - case data: + case struct_: case array: case string: case stringview_wtf8: @@ -1359,11 +1360,11 @@ size_t HeapType::getDepth() const { if (isFunction()) { depth++; } else if (isStruct()) { - // specific struct types <: data <: eq <: any + // specific struct types <: struct <: eq <: any depth += 3; } else if (isArray()) { - // specific array types <: array <: data <: eq <: any - depth += 4; + // specific array types <: array <: eq <: any + depth += 3; } } else { // Some basic types have supers. @@ -1376,16 +1377,14 @@ size_t HeapType::getDepth() const { depth++; break; case HeapType::i31: - case HeapType::data: + case HeapType::struct_: + case HeapType::array: case HeapType::string: case HeapType::stringview_wtf8: case HeapType::stringview_wtf16: case HeapType::stringview_iter: depth += 2; break; - case HeapType::array: - depth += 3; - break; case HeapType::none: case HeapType::nofunc: case HeapType::noext: @@ -1406,7 +1405,7 @@ HeapType::BasicHeapType HeapType::getBottom() const { case any: case eq: case i31: - case data: + case struct_: case array: case string: case stringview_wtf8: @@ -1673,12 +1672,11 @@ bool SubTyper::isSubType(HeapType a, HeapType b) { case HeapType::any: return a.getBottom() == HeapType::none; case HeapType::eq: - return a == HeapType::i31 || a == HeapType::data || - a == HeapType::array || a == HeapType::none || a.isData(); + return a == HeapType::i31 || a == HeapType::none || a.isData(); case HeapType::i31: return a == HeapType::none; - case HeapType::data: - return a == HeapType::array || a == HeapType::none || a.isData(); + case HeapType::struct_: + return a == HeapType::none || a.isStruct(); case HeapType::array: return a == HeapType::none || a.isArray(); case HeapType::string: @@ -1805,8 +1803,8 @@ std::ostream& TypePrinter::print(Type type) { return os << "eqref"; case HeapType::i31: return os << "i31ref"; - case HeapType::data: - return os << "dataref"; + case HeapType::struct_: + return os << "structref"; case HeapType::array: return os << "arrayref"; case HeapType::string: @@ -1851,8 +1849,8 @@ std::ostream& TypePrinter::print(HeapType type) { return os << "eq"; case HeapType::i31: return os << "i31"; - case HeapType::data: - return os << "data"; + case HeapType::struct_: + return os << "struct"; case HeapType::array: return os << "array"; case HeapType::string: diff --git a/src/wasm/wat-parser.cpp b/src/wasm/wat-parser.cpp index c2d06ae90..66bba8862 100644 --- a/src/wasm/wat-parser.cpp +++ b/src/wasm/wat-parser.cpp @@ -491,7 +491,7 @@ struct NullTypeParserCtx { HeapTypeT makeExtern() { return Ok{}; } HeapTypeT makeEq() { return Ok{}; } HeapTypeT makeI31() { return Ok{}; } - HeapTypeT makeData() { return Ok{}; } + HeapTypeT makeStructType() { return Ok{}; } HeapTypeT makeArrayType() { return Ok{}; } TypeT makeI32() { return Ok{}; } @@ -575,7 +575,7 @@ template<typename Ctx> struct TypeParserCtx { HeapTypeT makeExtern() { return HeapType::ext; } HeapTypeT makeEq() { return HeapType::eq; } HeapTypeT makeI31() { return HeapType::i31; } - HeapTypeT makeData() { return HeapType::data; } + HeapTypeT makeStructType() { return HeapType::struct_; } HeapTypeT makeArrayType() { return HeapType::array; } TypeT makeI32() { return Type::i32; } @@ -2449,8 +2449,8 @@ template<typename Ctx> Result<typename Ctx::HeapTypeT> heaptype(Ctx& ctx) { if (ctx.in.takeKeyword("i31"sv)) { return ctx.makeI31(); } - if (ctx.in.takeKeyword("data"sv)) { - return ctx.makeData(); + if (ctx.in.takeKeyword("struct"sv)) { + return ctx.makeStructType(); } if (ctx.in.takeKeyword("array"sv)) { return ctx.makeArrayType(); @@ -2465,7 +2465,7 @@ template<typename Ctx> Result<typename Ctx::HeapTypeT> heaptype(Ctx& ctx) { // | 'anyref' => anyref // | 'eqref' => eqref // | 'i31ref' => i31ref -// | 'dataref' => dataref +// | 'structref' => structref // | 'arrayref' => arrayref // | '(' ref null? t:heaptype ')' => ref null? t template<typename Ctx> MaybeResult<typename Ctx::TypeT> reftype(Ctx& ctx) { @@ -2484,8 +2484,8 @@ template<typename Ctx> MaybeResult<typename Ctx::TypeT> reftype(Ctx& ctx) { if (ctx.in.takeKeyword("i31ref"sv)) { return ctx.makeRefType(ctx.makeI31(), Nullable); } - if (ctx.in.takeKeyword("dataref"sv)) { - return ctx.makeRefType(ctx.makeData(), Nullable); + if (ctx.in.takeKeyword("structref"sv)) { + return ctx.makeRefType(ctx.makeStructType(), Nullable); } if (ctx.in.takeKeyword("arrayref"sv)) { return ctx.in.err("arrayref not yet supported"); diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 0de23883a..1a4b2452d 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -658,7 +658,7 @@ function test_core() { module.anyref.pop(), module.eqref.pop(), module.i31ref.pop(), - module.dataref.pop(), + module.structref.pop(), module.stringref.pop(), module.stringview_wtf8.pop(), module.stringview_wtf16.pop(), diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 4798c8592..0605ef4cc 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -2179,7 +2179,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop i31ref) ) (drop - (pop dataref) + (pop structref) ) (drop (pop stringref) @@ -4283,7 +4283,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (pop i31ref) ) (drop - (pop dataref) + (pop structref) ) (drop (pop stringref) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 45af52e21..b2b35da16 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -263,12 +263,12 @@ void test_types() { BinaryenTypeExpand(i31ref, &valueType); assert(valueType == i31ref); - BinaryenType dataref = BinaryenTypeDataref(); - printf("BinaryenTypeDataref: (ptr)\n"); - assert(dataref == BinaryenTypeDataref()); - assert(BinaryenTypeArity(dataref) == 1); - BinaryenTypeExpand(dataref, &valueType); - assert(valueType == dataref); + BinaryenType structref = BinaryenTypeStructref(); + printf("BinaryenTypeStructref: (ptr)\n"); + assert(structref == BinaryenTypeStructref()); + assert(BinaryenTypeArity(structref) == 1); + BinaryenTypeExpand(structref, &valueType); + assert(valueType == structref); BinaryenType arrayref = BinaryenTypeArrayref(); printf("BinaryenTypeArrayref: (ptr)\n"); @@ -348,7 +348,7 @@ void test_types() { printf("BinaryenHeapTypeAny: %zd\n", BinaryenHeapTypeAny()); printf("BinaryenHeapTypeEq: %zd\n", BinaryenHeapTypeEq()); printf("BinaryenHeapTypeI31: %zd\n", BinaryenHeapTypeI31()); - printf("BinaryenHeapTypeData: %zd\n", BinaryenHeapTypeData()); + printf("BinaryenHeapTypeStruct: %zd\n", BinaryenHeapTypeStruct()); printf("BinaryenHeapTypeArray: %zd\n", BinaryenHeapTypeArray()); printf("BinaryenHeapTypeString: %zd\n", BinaryenHeapTypeString()); printf("BinaryenHeapTypeStringviewWTF8: %zd\n", @@ -2201,7 +2201,7 @@ void test_typebuilder() { assert(BinaryenHeapTypeIsStruct(structHeapType)); assert(!BinaryenHeapTypeIsArray(structHeapType)); assert(!BinaryenHeapTypeIsBottom(structHeapType)); - assert(BinaryenHeapTypeIsSubType(structHeapType, BinaryenHeapTypeData())); + assert(BinaryenHeapTypeIsSubType(structHeapType, BinaryenHeapTypeStruct())); BinaryenType structType = BinaryenTypeFromHeapType(structHeapType, true); assert(BinaryenStructTypeGetNumFields(structHeapType) == 1); assert(BinaryenStructTypeGetFieldType(structHeapType, 0) == structType); @@ -2245,7 +2245,8 @@ void test_typebuilder() { assert(BinaryenHeapTypeIsStruct(subStructHeapType)); assert(!BinaryenHeapTypeIsArray(subStructHeapType)); assert(!BinaryenHeapTypeIsBottom(subStructHeapType)); - assert(BinaryenHeapTypeIsSubType(subStructHeapType, BinaryenHeapTypeData())); + assert( + BinaryenHeapTypeIsSubType(subStructHeapType, BinaryenHeapTypeStruct())); assert(BinaryenHeapTypeIsSubType(subStructHeapType, structHeapType)); BinaryenType subStructType = BinaryenTypeFromHeapType(subStructHeapType, true); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 6e4af6cf0..510060317 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -10,7 +10,7 @@ BinaryenTypeExternref: (ptr) BinaryenTypeAnyref: (ptr) BinaryenTypeEqref: (ptr) BinaryenTypeI31ref: (ptr) -BinaryenTypeDataref: (ptr) +BinaryenTypeStructref: (ptr) BinaryenTypeArrayref: (ptr) BinaryenTypeStringref: (ptr) BinaryenTypeStringviewWTF8: (ptr) @@ -28,7 +28,7 @@ BinaryenHeapTypeFunc: 1 BinaryenHeapTypeAny: 2 BinaryenHeapTypeEq: 3 BinaryenHeapTypeI31: 4 -BinaryenHeapTypeData: 5 +BinaryenHeapTypeStruct: 5 BinaryenHeapTypeArray: 6 BinaryenHeapTypeString: 7 BinaryenHeapTypeStringviewWTF8: 8 diff --git a/test/example/type-builder-nominal.cpp b/test/example/type-builder-nominal.cpp index 66dccead3..a3e8695ac 100644 --- a/test/example/type-builder-nominal.cpp +++ b/test/example/type-builder-nominal.cpp @@ -329,52 +329,6 @@ void test_subtypes() { }; { - // Basic Types - for (auto other : {HeapType::eq, - HeapType::any, - HeapType::eq, - HeapType::i31, - HeapType::data}) { - assert(LUB(HeapType::any, other) == HeapType::any); - } - assert(LUB(HeapType::i31, HeapType::data) == HeapType::eq); - } - - { - // Identity - std::vector<HeapType> built; - { - TypeBuilder builder(3); - builder[0] = Signature(Type::none, Type::none); - builder[1] = Struct{}; - builder[2] = Array(Field(Type::i32, Mutable)); - built = *builder.build(); - } - assert(LUB(built[0], built[0]) == built[0]); - assert(LUB(built[1], built[1]) == built[1]); - assert(LUB(built[2], built[2]) == built[2]); - } - - { - // No subtype declarations mean no subtypes - std::vector<HeapType> built; - { - TypeBuilder builder(5); - Type structRef0 = builder.getTempRefType(builder[0], Nullable); - Type structRef1 = builder.getTempRefType(builder[1], Nullable); - builder[0] = Struct{}; - builder[1] = Struct{}; - builder[2] = Signature(Type::none, anyref); - builder[3] = Signature(Type::none, structRef0); - builder[4] = Signature(Type::none, structRef1); - built = *builder.build(); - } - assert(LUB(built[0], built[1]) == HeapType::data); - assert(LUB(built[2], built[3]) == HeapType::func); - assert(LUB(built[2], built[4]) == HeapType::func); - } - - { // Subtype declarations, but still no subtypes std::vector<HeapType> built; { @@ -385,7 +339,7 @@ void test_subtypes() { builder[2] = Struct{}; built = *builder.build(); } - assert(LUB(built[0], built[2]) == HeapType::data); + assert(LUB(built[0], built[2]) == HeapType::struct_); } { diff --git a/test/gc.wast.from-wast b/test/gc.wast.from-wast index 1cf0bca7c..40b870dca 100644 --- a/test/gc.wast.from-wast +++ b/test/gc.wast.from-wast @@ -1,6 +1,6 @@ (module - (type $i31ref_dataref_=>_none (func (param i31ref dataref))) - (type $i31ref_ref|i31|_dataref_ref|data|_=>_none (func (param i31ref (ref i31) dataref (ref data)))) + (type $i31ref_structref_=>_none (func (param i31ref structref))) + (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global_anyref (mut anyref) (ref.null none)) (global $global_eqref (mut eqref) (ref.null none)) (global $global_i31ref (mut i31ref) (i31.new @@ -13,7 +13,7 @@ (global $global_eqref2 (mut eqref) (i31.new (i32.const 0) )) - (func $test (type $i31ref_dataref_=>_none) (param $local_i31ref i31ref) (param $local_structref dataref) + (func $test (type $i31ref_structref_=>_none) (param $local_i31ref i31ref) (param $local_structref structref) (local $local_i32 i32) (local $local_anyref anyref) (local $local_eqref eqref) @@ -148,7 +148,7 @@ ) ) ) - (func $test-variants (type $i31ref_ref|i31|_dataref_ref|data|_=>_none) (param $local_i31refnull i31ref) (param $local_i31refnonnull (ref i31)) (param $local_structrefnull dataref) (param $local_structrefnonnull (ref data)) + (func $test-variants (type $i31ref_ref|i31|_structref_ref|struct|_=>_none) (param $local_i31refnull i31ref) (param $local_i31refnonnull (ref i31)) (param $local_structrefnull structref) (param $local_structrefnonnull (ref struct)) (nop) ) ) diff --git a/test/gc.wast.fromBinary b/test/gc.wast.fromBinary index ca56f5538..d37e4b741 100644 --- a/test/gc.wast.fromBinary +++ b/test/gc.wast.fromBinary @@ -1,6 +1,6 @@ (module - (type $i31ref_dataref_=>_none (func (param i31ref dataref))) - (type $i31ref_ref|i31|_dataref_ref|data|_=>_none (func (param i31ref (ref i31) dataref (ref data)))) + (type $i31ref_structref_=>_none (func (param i31ref structref))) + (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global_anyref (mut anyref) (ref.null none)) (global $global_eqref (mut eqref) (ref.null none)) (global $global_i31ref (mut i31ref) (i31.new @@ -13,7 +13,7 @@ (global $global_eqref2 (mut eqref) (i31.new (i32.const 0) )) - (func $test (type $i31ref_dataref_=>_none) (param $local_i31ref i31ref) (param $local_structref dataref) + (func $test (type $i31ref_structref_=>_none) (param $local_i31ref i31ref) (param $local_structref structref) (local $local_i32 i32) (local $local_anyref anyref) (local $local_eqref eqref) @@ -148,7 +148,7 @@ ) ) ) - (func $test-variants (type $i31ref_ref|i31|_dataref_ref|data|_=>_none) (param $local_i31refnull i31ref) (param $local_i31refnonnull (ref i31)) (param $local_structrefnull dataref) (param $local_structrefnonnull (ref data)) + (func $test-variants (type $i31ref_ref|i31|_structref_ref|struct|_=>_none) (param $local_i31refnull i31ref) (param $local_i31refnonnull (ref i31)) (param $local_structrefnull structref) (param $local_structrefnonnull (ref struct)) (nop) ) ) diff --git a/test/gc.wast.fromBinary.noDebugInfo b/test/gc.wast.fromBinary.noDebugInfo index e51c6c4c1..b9cc6b04a 100644 --- a/test/gc.wast.fromBinary.noDebugInfo +++ b/test/gc.wast.fromBinary.noDebugInfo @@ -1,6 +1,6 @@ (module - (type $i31ref_dataref_=>_none (func (param i31ref dataref))) - (type $i31ref_ref|i31|_dataref_ref|data|_=>_none (func (param i31ref (ref i31) dataref (ref data)))) + (type $i31ref_structref_=>_none (func (param i31ref structref))) + (type $i31ref_ref|i31|_structref_ref|struct|_=>_none (func (param i31ref (ref i31) structref (ref struct)))) (global $global$0 (mut anyref) (ref.null none)) (global $global$1 (mut eqref) (ref.null none)) (global $global$2 (mut i31ref) (i31.new @@ -13,7 +13,7 @@ (global $global$5 (mut eqref) (i31.new (i32.const 0) )) - (func $0 (type $i31ref_dataref_=>_none) (param $0 i31ref) (param $1 dataref) + (func $0 (type $i31ref_structref_=>_none) (param $0 i31ref) (param $1 structref) (local $2 i32) (local $3 anyref) (local $4 eqref) @@ -148,7 +148,7 @@ ) ) ) - (func $1 (type $i31ref_ref|i31|_dataref_ref|data|_=>_none) (param $0 i31ref) (param $1 (ref i31)) (param $2 dataref) (param $3 (ref data)) + (func $1 (type $i31ref_ref|i31|_structref_ref|struct|_=>_none) (param $0 i31ref) (param $1 (ref i31)) (param $2 structref) (param $3 (ref struct)) (nop) ) ) diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp index ea2a0c0f0..c6b7d000c 100644 --- a/test/gtest/possible-contents.cpp +++ b/test/gtest/possible-contents.cpp @@ -74,7 +74,7 @@ protected: Type anyref = Type(HeapType::any, Nullable); Type funcref = Type(HeapType::func, Nullable); Type i31ref = Type(HeapType::i31, Nullable); - Type dataref = Type(HeapType::data, Nullable); + Type structref = Type(HeapType::struct_, Nullable); PossibleContents none = PossibleContents::none(); @@ -104,7 +104,7 @@ protected: PossibleContents exactI32 = PossibleContents::exactType(Type::i32); PossibleContents exactAnyref = PossibleContents::exactType(anyref); PossibleContents exactFuncref = PossibleContents::exactType(funcref); - PossibleContents exactDataref = PossibleContents::exactType(dataref); + PossibleContents exactStructref = PossibleContents::exactType(structref); PossibleContents exactI31ref = PossibleContents::exactType(i31ref); PossibleContents exactNonNullAnyref = PossibleContents::exactType(Type(HeapType::any, NonNullable)); @@ -494,7 +494,7 @@ TEST_F(PossibleContentsTest, TestIntersectWithCombinations) { exactI32, exactAnyref, exactFuncref, - exactDataref, + exactStructref, exactI31ref, exactNonNullAnyref, exactNonNullFuncref, @@ -591,36 +591,36 @@ TEST_F(PossibleContentsTest, TestStructCones) { assertCombination(exactA, exactB, PossibleContents::coneType(nullA, 1)); assertCombination(exactA, exactC, PossibleContents::coneType(nullA, 1)); assertCombination(exactA, exactD, PossibleContents::coneType(nullA, 2)); - assertCombination(exactA, exactE, PossibleContents::coneType(dataref, 1)); + assertCombination(exactA, exactE, PossibleContents::coneType(structref, 1)); assertCombination( - exactA, exactDataref, PossibleContents::coneType(dataref, 1)); + exactA, exactStructref, PossibleContents::coneType(structref, 1)); assertCombination(exactB, exactB, exactB); assertCombination(exactB, exactC, PossibleContents::coneType(nullA, 1)); assertCombination(exactB, exactD, PossibleContents::coneType(nullA, 2)); - assertCombination(exactB, exactE, PossibleContents::coneType(dataref, 2)); + assertCombination(exactB, exactE, PossibleContents::coneType(structref, 2)); assertCombination( - exactB, exactDataref, PossibleContents::coneType(dataref, 2)); + exactB, exactStructref, PossibleContents::coneType(structref, 2)); assertCombination(exactC, exactC, exactC); assertCombination(exactC, exactD, PossibleContents::coneType(nullC, 1)); - assertCombination(exactC, exactE, PossibleContents::coneType(dataref, 2)); + assertCombination(exactC, exactE, PossibleContents::coneType(structref, 2)); assertCombination( - exactC, exactDataref, PossibleContents::coneType(dataref, 2)); + exactC, exactStructref, PossibleContents::coneType(structref, 2)); assertCombination(exactD, exactD, exactD); - assertCombination(exactD, exactE, PossibleContents::coneType(dataref, 3)); + assertCombination(exactD, exactE, PossibleContents::coneType(structref, 3)); assertCombination( - exactD, exactDataref, PossibleContents::coneType(dataref, 3)); + exactD, exactStructref, PossibleContents::coneType(structref, 3)); assertCombination(exactE, exactE, exactE); assertCombination( - exactE, exactDataref, PossibleContents::coneType(dataref, 1)); + exactE, exactStructref, PossibleContents::coneType(structref, 1)); - assertCombination(exactDataref, exactDataref, exactDataref); + assertCombination(exactStructref, exactStructref, exactStructref); assertCombination( - exactDataref, exactAnyref, PossibleContents::coneType(anyref, 2)); + exactStructref, exactAnyref, PossibleContents::coneType(anyref, 2)); // Combinations of cones. assertCombination(PossibleContents::coneType(nullA, 5), @@ -640,11 +640,11 @@ TEST_F(PossibleContentsTest, TestStructCones) { assertCombination(PossibleContents::coneType(nullA, 5), PossibleContents::coneType(nullE, 7), - PossibleContents::coneType(dataref, 8)); + PossibleContents::coneType(structref, 8)); assertCombination(PossibleContents::coneType(nullB, 4), - PossibleContents::coneType(dataref, 1), - PossibleContents::coneType(dataref, 6)); + PossibleContents::coneType(structref, 1), + PossibleContents::coneType(structref, 6)); // Combinations of cones and exact types. assertCombination(exactA, @@ -658,18 +658,18 @@ TEST_F(PossibleContentsTest, TestStructCones) { PossibleContents::coneType(nullA, 3)); assertCombination(exactA, PossibleContents::coneType(nullE, 2), - PossibleContents::coneType(dataref, 3)); + PossibleContents::coneType(structref, 3)); assertCombination(exactA, - PossibleContents::coneType(dataref, 1), - PossibleContents::coneType(dataref, 1)); + PossibleContents::coneType(structref, 1), + PossibleContents::coneType(structref, 1)); assertCombination(exactA, - PossibleContents::coneType(dataref, 2), - PossibleContents::coneType(dataref, 2)); + PossibleContents::coneType(structref, 2), + PossibleContents::coneType(structref, 2)); - assertCombination(exactDataref, + assertCombination(exactStructref, PossibleContents::coneType(nullB, 3), - PossibleContents::coneType(dataref, 5)); + PossibleContents::coneType(structref, 5)); // Full cones. assertCombination(PossibleContents::fullConeType(nullA), @@ -694,7 +694,7 @@ TEST_F(PossibleContentsTest, TestStructCones) { PossibleContents::fullConeType(nullA)); assertCombination(PossibleContents::fullConeType(nullA), PossibleContents::fullConeType(nullE), - PossibleContents::fullConeType(dataref)); + PossibleContents::fullConeType(structref)); // Intersections. Test with non-nullable types to avoid the null being a // possible intersection. @@ -902,7 +902,7 @@ TEST_F(PossibleContentsTest, TestOracleManyTypes) { auto bodyContents = oracle.getContents(ResultLocation{wasm->getFunction("foo"), 0}); ASSERT_TRUE(bodyContents.isConeType()); - EXPECT_EQ(bodyContents.getType().getHeapType(), HeapType::data); + EXPECT_EQ(bodyContents.getType().getHeapType(), HeapType::struct_); EXPECT_EQ(bodyContents.getCone().depth, Index(1)); } diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index 0dba0a10c..d26b8bb97 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -500,7 +500,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { HeapType any = HeapType::any; HeapType eq = HeapType::eq; HeapType i31 = HeapType::i31; - HeapType data = HeapType::data; + HeapType struct_ = HeapType::struct_; HeapType array = HeapType::array; HeapType string = HeapType::string; HeapType stringview_wtf8 = HeapType::stringview_wtf8; @@ -546,7 +546,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(ext, any, {}); assertLUB(ext, eq, {}); assertLUB(ext, i31, {}); - assertLUB(ext, data, {}); + assertLUB(ext, struct_, {}); assertLUB(ext, array, {}); assertLUB(ext, string, {}); assertLUB(ext, stringview_wtf8, {}); @@ -563,7 +563,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(func, any, {}); assertLUB(func, eq, {}); assertLUB(func, i31, {}); - assertLUB(func, data, {}); + assertLUB(func, struct_, {}); assertLUB(func, array, {}); assertLUB(func, string, {}); assertLUB(func, stringview_wtf8, {}); @@ -579,7 +579,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(any, any, any); assertLUB(any, eq, any); assertLUB(any, i31, any); - assertLUB(any, data, any); + assertLUB(any, struct_, any); assertLUB(any, array, any); assertLUB(any, string, any); assertLUB(any, stringview_wtf8, any); @@ -594,7 +594,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(eq, eq, eq); assertLUB(eq, i31, eq); - assertLUB(eq, data, eq); + assertLUB(eq, struct_, eq); assertLUB(eq, array, eq); assertLUB(eq, string, any); assertLUB(eq, stringview_wtf8, any); @@ -608,7 +608,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(eq, defArray, eq); assertLUB(i31, i31, i31); - assertLUB(i31, data, eq); + assertLUB(i31, struct_, eq); assertLUB(i31, array, eq); assertLUB(i31, string, any); assertLUB(i31, stringview_wtf8, any); @@ -621,18 +621,18 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(i31, defStruct, eq); assertLUB(i31, defArray, eq); - assertLUB(data, data, data); - assertLUB(data, array, data); - assertLUB(data, string, any); - assertLUB(data, stringview_wtf8, any); - assertLUB(data, stringview_wtf16, any); - assertLUB(data, stringview_iter, any); - assertLUB(data, none, data); - assertLUB(data, noext, {}); - assertLUB(data, nofunc, {}); - assertLUB(data, defFunc, {}); - assertLUB(data, defStruct, data); - assertLUB(data, defArray, data); + assertLUB(struct_, struct_, struct_); + assertLUB(struct_, array, eq); + assertLUB(struct_, string, any); + assertLUB(struct_, stringview_wtf8, any); + assertLUB(struct_, stringview_wtf16, any); + assertLUB(struct_, stringview_iter, any); + assertLUB(struct_, none, struct_); + assertLUB(struct_, noext, {}); + assertLUB(struct_, nofunc, {}); + assertLUB(struct_, defFunc, {}); + assertLUB(struct_, defStruct, struct_); + assertLUB(struct_, defArray, eq); assertLUB(array, array, array); assertLUB(array, string, any); @@ -643,7 +643,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(array, noext, {}); assertLUB(array, nofunc, {}); assertLUB(array, defFunc, {}); - assertLUB(array, defStruct, data); + assertLUB(array, defStruct, eq); assertLUB(array, defArray, array); assertLUB(string, string, string); @@ -707,7 +707,7 @@ TEST_F(IsorecursiveTest, TestHeapTypeRelations) { assertLUB(defFunc, defArray, {}); assertLUB(defStruct, defStruct, defStruct); - assertLUB(defStruct, defArray, data); + assertLUB(defStruct, defArray, eq); assertLUB(defArray, defArray, defArray); @@ -979,8 +979,9 @@ TEST_F(NominalTest, TestMaxStructDepths) { EXPECT_EQ(maxDepths[B], Index(0)); EXPECT_EQ(maxDepths[A], Index(1)); - EXPECT_EQ(maxDepths[HeapType::data], Index(2)); + EXPECT_EQ(maxDepths[HeapType::struct_], Index(2)); EXPECT_EQ(maxDepths[HeapType::eq], Index(3)); + EXPECT_EQ(maxDepths[HeapType::any], Index(4)); } TEST_F(NominalTest, TestMaxArrayDepths) { @@ -999,8 +1000,8 @@ TEST_F(NominalTest, TestMaxArrayDepths) { EXPECT_EQ(maxDepths[A], Index(0)); EXPECT_EQ(maxDepths[HeapType::array], Index(1)); - EXPECT_EQ(maxDepths[HeapType::data], Index(2)); - EXPECT_EQ(maxDepths[HeapType::eq], Index(3)); + EXPECT_EQ(maxDepths[HeapType::eq], Index(2)); + EXPECT_EQ(maxDepths[HeapType::any], Index(3)); } // Test .depth() helper. @@ -1020,14 +1021,14 @@ TEST_F(NominalTest, TestDepth) { C = built[2]; } - // any :> eq :> data :> array :> specific array types + // any :> eq :> array :> specific array types EXPECT_EQ(HeapType(HeapType::any).getDepth(), 0U); EXPECT_EQ(HeapType(HeapType::eq).getDepth(), 1U); - EXPECT_EQ(HeapType(HeapType::data).getDepth(), 2U); - EXPECT_EQ(HeapType(HeapType::array).getDepth(), 3U); + EXPECT_EQ(HeapType(HeapType::array).getDepth(), 2U); + EXPECT_EQ(HeapType(HeapType::struct_).getDepth(), 2U); EXPECT_EQ(A.getDepth(), 3U); EXPECT_EQ(B.getDepth(), 4U); - EXPECT_EQ(C.getDepth(), 4U); + EXPECT_EQ(C.getDepth(), 3U); // Signature types are subtypes of func. EXPECT_EQ(HeapType(HeapType::func).getDepth(), 0U); diff --git a/test/heap-types.wast b/test/heap-types.wast index f64dd8814..243863946 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -182,13 +182,12 @@ (unreachable) ) (func $ref.is_X (param $x anyref) - (if (ref.is_data (local.get $x)) (unreachable)) + (if (ref.is_null (local.get $x)) (unreachable)) (if (ref.is_i31 (local.get $x)) (unreachable)) ) (func $ref.as_X (param $x anyref) (param $f funcref) (drop (ref.as_non_null (local.get $x))) (drop (ref.as_func (local.get $f))) - (drop (ref.as_data (local.get $x))) (drop (ref.as_i31 (local.get $x))) ) (func $br_on_X (param $x anyref) diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index 703759720..213a45b5a 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -178,7 +178,7 @@ ) (func $ref.is_X (type $anyref_=>_none) (param $x anyref) (if - (ref.is_data + (ref.is_null (local.get $x) ) (unreachable) @@ -202,11 +202,6 @@ ) ) (drop - (ref.as_data - (local.get $x) - ) - ) - (drop (ref.as_i31 (local.get $x) ) diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 8e42051bc..80981535c 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -176,7 +176,7 @@ ) (func $ref.is_X (type $anyref_=>_none) (param $x anyref) (if - (ref.is_data + (ref.is_null (local.get $x) ) (unreachable) @@ -200,11 +200,6 @@ ) ) (drop - (ref.as_data - (local.get $x) - ) - ) - (drop (ref.as_i31 (local.get $x) ) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index 3c7203066..6c37eba77 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -176,7 +176,7 @@ ) (func $2 (type $anyref_=>_none) (param $0 anyref) (if - (ref.is_data + (ref.is_null (local.get $0) ) (unreachable) @@ -200,11 +200,6 @@ ) ) (drop - (ref.as_data - (local.get $0) - ) - ) - (drop (ref.as_i31 (local.get $0) ) diff --git a/test/lit/cast-to-basic.wast b/test/lit/cast-to-basic.wast index 9433c3ba1..23adb3968 100644 --- a/test/lit/cast-to-basic.wast +++ b/test/lit/cast-to-basic.wast @@ -6,7 +6,7 @@ (module ;; CHECK: (func $test (type $none_=>_i32) (result i32) - ;; CHECK-NEXT: (ref.is_data + ;; CHECK-NEXT: (ref.test struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -18,7 +18,7 @@ ;; CHECK: (func $cast (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast null data + ;; CHECK-NEXT: (ref.cast null struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -33,9 +33,9 @@ ;; CHECK: (func $br (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $label$1 (result dataref) + ;; CHECK-NEXT: (block $label$1 (result structref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_data $label$1 + ;; CHECK-NEXT: (br_on_cast $label$1 struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -58,9 +58,9 @@ ;; CHECK: (func $br-null (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $label$1 (result dataref) + ;; CHECK-NEXT: (block $label$1 (result structref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast $label$1 null data + ;; CHECK-NEXT: (br_on_cast $label$1 null struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -83,9 +83,9 @@ ;; CHECK: (func $br-fail-null (type $none_=>_none) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $label$1 (result dataref) + ;; CHECK-NEXT: (block $label$1 (result structref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (br_on_cast_fail $label$1 null data + ;; CHECK-NEXT: (br_on_cast_fail $label$1 null struct ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/coalesce-locals-gc.wast b/test/lit/passes/coalesce-locals-gc.wast index 8cc585d7b..29dffb5bd 100644 --- a/test/lit/passes/coalesce-locals-gc.wast +++ b/test/lit/passes/coalesce-locals-gc.wast @@ -8,23 +8,23 @@ ;; testcases. (module - ;; CHECK: (type $A (struct (field dataref))) + ;; CHECK: (type $A (struct (field structref))) ;; CHECK: (type $array (array (mut i8))) (type $array (array (mut i8))) (type $A (struct_subtype (field (ref null struct)) data)) - ;; CHECK: (type $B (struct_subtype (field (ref data)) $A)) + ;; CHECK: (type $B (struct_subtype (field (ref struct)) $A)) (type $B (struct_subtype (field (ref struct)) $A)) ;; CHECK: (global $global (ref null $array) (ref.null none)) (global $global (ref null $array) (ref.null $array)) - ;; CHECK: (func $test-dead-get-non-nullable (type $ref|data|_=>_none) (param $0 (ref data)) + ;; CHECK: (func $test-dead-get-non-nullable (type $ref|struct|_=>_none) (param $0 (ref struct)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block (result (ref data)) + ;; CHECK-NEXT: (block (result (ref struct)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -174,7 +174,7 @@ ) ) - ;; CHECK: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_dataref) (param $0 (ref null $A)) (param $1 (ref null $B)) (result dataref) + ;; CHECK: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_structref) (param $0 (ref null $A)) (param $1 (ref null $B)) (result structref) ;; CHECK-NEXT: (struct.get $A 0 ;; CHECK-NEXT: (block (result (ref null $A)) ;; CHECK-NEXT: (local.get $1) @@ -195,7 +195,7 @@ ) ) - ;; CHECK: (func $remove-tee-refinalize-2 (type $ref?|$A|_ref?|$B|_=>_dataref) (param $0 (ref null $A)) (param $1 (ref null $B)) (result dataref) + ;; CHECK: (func $remove-tee-refinalize-2 (type $ref?|$A|_ref?|$B|_=>_structref) (param $0 (ref null $A)) (param $1 (ref null $B)) (result structref) ;; CHECK-NEXT: (struct.get $A 0 ;; CHECK-NEXT: (block (result (ref null $A)) ;; CHECK-NEXT: (local.get $1) diff --git a/test/lit/passes/dae-gc-refine-params.wast b/test/lit/passes/dae-gc-refine-params.wast index c41feb4ac..29a666196 100644 --- a/test/lit/passes/dae-gc-refine-params.wast +++ b/test/lit/passes/dae-gc-refine-params.wast @@ -468,11 +468,11 @@ ) ;; CHECK: (func $unused-and-refinable (type $none_=>_none) - ;; CHECK-NEXT: (local $0 dataref) + ;; CHECK-NEXT: (local $0 structref) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) ;; NOMNL: (func $unused-and-refinable (type $none_=>_none) - ;; NOMNL-NEXT: (local $0 dataref) + ;; NOMNL-NEXT: (local $0 structref) ;; NOMNL-NEXT: (nop) ;; NOMNL-NEXT: ) (func $unused-and-refinable (param $0 structref) @@ -500,7 +500,7 @@ ) ;; CHECK: (func $non-nullable-fixup (type $ref|${}|_=>_none) (param $0 (ref ${})) - ;; CHECK-NEXT: (local $1 dataref) + ;; CHECK-NEXT: (local $1 structref) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) @@ -509,7 +509,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $non-nullable-fixup (type $ref|${}|_=>_none) (param $0 (ref ${})) - ;; NOMNL-NEXT: (local $1 dataref) + ;; NOMNL-NEXT: (local $1 structref) ;; NOMNL-NEXT: (local.set $1 ;; NOMNL-NEXT: (local.get $0) ;; NOMNL-NEXT: ) diff --git a/test/lit/passes/dae-gc-refine-return.wast b/test/lit/passes/dae-gc-refine-return.wast index a2e858a17..0db6ab551 100644 --- a/test/lit/passes/dae-gc-refine-return.wast +++ b/test/lit/passes/dae-gc-refine-return.wast @@ -230,7 +230,7 @@ ;; CHECK: (func $refine-return-many-lub (type $none_=>_eqref) (result eqref) ;; CHECK-NEXT: (local $temp anyref) ;; CHECK-NEXT: (local $i31 i31ref) - ;; CHECK-NEXT: (local $struct dataref) + ;; CHECK-NEXT: (local $struct structref) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $refine-return-many-lub) ;; CHECK-NEXT: ) @@ -251,7 +251,7 @@ ;; NOMNL: (func $refine-return-many-lub (type $none_=>_eqref) (result eqref) ;; NOMNL-NEXT: (local $temp anyref) ;; NOMNL-NEXT: (local $i31 i31ref) - ;; NOMNL-NEXT: (local $struct dataref) + ;; NOMNL-NEXT: (local $struct structref) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $refine-return-many-lub) ;; NOMNL-NEXT: ) @@ -291,7 +291,7 @@ ;; CHECK: (func $refine-return-many-lub-2 (type $none_=>_eqref) (result eqref) ;; CHECK-NEXT: (local $temp anyref) ;; CHECK-NEXT: (local $i31 i31ref) - ;; CHECK-NEXT: (local $struct dataref) + ;; CHECK-NEXT: (local $struct structref) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $refine-return-many-lub-2) ;; CHECK-NEXT: ) @@ -312,7 +312,7 @@ ;; NOMNL: (func $refine-return-many-lub-2 (type $none_=>_eqref) (result eqref) ;; NOMNL-NEXT: (local $temp anyref) ;; NOMNL-NEXT: (local $i31 i31ref) - ;; NOMNL-NEXT: (local $struct dataref) + ;; NOMNL-NEXT: (local $struct structref) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $refine-return-many-lub-2) ;; NOMNL-NEXT: ) diff --git a/test/lit/passes/gufa-extern.wast b/test/lit/passes/gufa-extern.wast index 9d71357aa..c8b593e4b 100644 --- a/test/lit/passes/gufa-extern.wast +++ b/test/lit/passes/gufa-extern.wast @@ -8,7 +8,7 @@ ;; CHECK: (func $externals (type $externref_anyref_=>_none) (param $ext externref) (param $any anyref) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.as_data + ;; CHECK-NEXT: (ref.cast struct ;; CHECK-NEXT: (extern.internalize ;; CHECK-NEXT: (local.get $ext) ;; CHECK-NEXT: ) @@ -24,7 +24,7 @@ ;; We must not turn these into unreachable code, as the function is ;; exported. (drop - (ref.as_data + (ref.cast struct (extern.internalize (local.get $ext) ) @@ -58,7 +58,7 @@ ;; This is not exported, so the params are dead code, and can be turned ;; unreachable. (drop - (ref.as_data + (ref.cast struct (extern.internalize (local.get $ext) ) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index 987758fe5..2ae05fb90 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -88,10 +88,10 @@ ) ) - ;; CHECK: (func $locals-with-multiple-assignments (type $dataref_=>_none) (param $struct dataref) + ;; CHECK: (func $locals-with-multiple-assignments (type $structref_=>_none) (param $struct structref) ;; CHECK-NEXT: (local $x eqref) ;; CHECK-NEXT: (local $y (ref i31)) - ;; CHECK-NEXT: (local $z dataref) + ;; CHECK-NEXT: (local $z structref) ;; CHECK-NEXT: (local $w (ref func)) ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (i31.new diff --git a/test/lit/passes/optimize-casts.wast b/test/lit/passes/optimize-casts.wast index 21a173fad..6faca88d7 100644 --- a/test/lit/passes/optimize-casts.wast +++ b/test/lit/passes/optimize-casts.wast @@ -92,7 +92,7 @@ ) ) - ;; CHECK: (func $ref.cast (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $ref.cast (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 @@ -124,7 +124,7 @@ ) ) - ;; CHECK: (func $not-past-set (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $not-past-set (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 @@ -161,7 +161,7 @@ ) ) - ;; CHECK: (func $best (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $best (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (local $2 (ref $B)) ;; CHECK-NEXT: (drop @@ -206,7 +206,7 @@ ) ) - ;; CHECK: (func $best-2 (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $best-2 (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $B)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 @@ -248,12 +248,12 @@ ) ) - ;; CHECK: (func $fallthrough (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $fallthrough (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (local $1 (ref $A)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.tee $1 ;; CHECK-NEXT: (ref.cast $A - ;; CHECK-NEXT: (block (result (ref data)) + ;; CHECK-NEXT: (block (result (ref struct)) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -277,7 +277,7 @@ ) ) - ;; CHECK: (func $past-basic-block (type $ref|data|_=>_none) (param $x (ref data)) + ;; CHECK: (func $past-basic-block (type $ref|struct|_=>_none) (param $x (ref struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.cast $A ;; CHECK-NEXT: (local.get $x) @@ -308,9 +308,9 @@ ) ) - ;; CHECK: (func $multiple (type $ref|data|_ref|data|_=>_none) (param $x (ref data)) (param $y (ref data)) - ;; CHECK-NEXT: (local $a (ref data)) - ;; CHECK-NEXT: (local $b (ref data)) + ;; CHECK: (func $multiple (type $ref|struct|_ref|struct|_=>_none) (param $x (ref struct)) (param $y (ref struct)) + ;; CHECK-NEXT: (local $a (ref struct)) + ;; CHECK-NEXT: (local $b (ref struct)) ;; CHECK-NEXT: (local $4 (ref $A)) ;; CHECK-NEXT: (local $5 (ref $A)) ;; CHECK-NEXT: (local.set $a @@ -388,7 +388,7 @@ ) ) - ;; CHECK: (func $get (type $none_=>_ref|data|) (result (ref data)) + ;; CHECK: (func $get (type $none_=>_ref|struct|) (result (ref struct)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $get (result (ref struct)) diff --git a/test/lit/passes/optimize-instructions-call_ref.wast b/test/lit/passes/optimize-instructions-call_ref.wast index ed308ca3a..ed849c7d8 100644 --- a/test/lit/passes/optimize-instructions-call_ref.wast +++ b/test/lit/passes/optimize-instructions-call_ref.wast @@ -16,7 +16,7 @@ ;; CHECK: (type $i32_=>_none (func (param i32))) - ;; CHECK: (type $struct_=>_none (func (param (ref data)))) + ;; CHECK: (type $struct_=>_none (func (param (ref struct)))) (type $struct_=>_none (func (param (ref struct)))) ;; CHECK: (type $i32_i32_i32_ref|$i32_i32_=>_none|_=>_none (func (param i32 i32 i32 (ref $i32_i32_=>_none)))) @@ -124,10 +124,10 @@ ) ) - ;; CHECK: (func $fallthrough-non-nullable (type $struct_=>_none) (param $x (ref data)) - ;; CHECK-NEXT: (local $1 dataref) + ;; CHECK: (func $fallthrough-non-nullable (type $struct_=>_none) (param $x (ref struct)) + ;; CHECK-NEXT: (local $1 structref) ;; CHECK-NEXT: (call $fallthrough-non-nullable - ;; CHECK-NEXT: (block (result (ref data)) + ;; CHECK-NEXT: (block (result (ref struct)) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) diff --git a/test/lit/passes/optimize-instructions-gc-tnh.wast b/test/lit/passes/optimize-instructions-gc-tnh.wast index 502590cde..2e9479ff5 100644 --- a/test/lit/passes/optimize-instructions-gc-tnh.wast +++ b/test/lit/passes/optimize-instructions-gc-tnh.wast @@ -18,7 +18,7 @@ ;; NO_TNH-NEXT: (ref.cast $struct ;; NO_TNH-NEXT: (local.get $a) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.as_data + ;; NO_TNH-NEXT: (ref.cast struct ;; NO_TNH-NEXT: (local.get $b) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -29,7 +29,7 @@ (ref.eq ;; When traps can happen we can still improve this by removing and ;; combining redundant casts. - (ref.as_data + (ref.cast struct (ref.as_non_null (ref.cast null $struct (local.get $a) @@ -37,8 +37,8 @@ ) ) ;; Note that we can remove the non-null casts here in both modes, as the - ;; ref.as_data also checks for null. - (ref.as_data + ;; ref.cast struct also checks for null. + (ref.cast struct (ref.as_non_null (ref.as_non_null (local.get $b) @@ -59,7 +59,7 @@ ;; NO_TNH-NEXT: (ref.cast null $struct ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (ref.as_data + ;; NO_TNH-NEXT: (ref.cast struct ;; NO_TNH-NEXT: (local.get $any) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) @@ -73,7 +73,7 @@ (local.get $any) ;; *Not* an eqref! ) (ref.as_non_null - (ref.as_data + (ref.cast struct (ref.as_non_null (local.get $any) ;; *Not* an eqref! ) @@ -105,7 +105,7 @@ (ref.is_null (ref.cast $struct (ref.as_non_null - (ref.as_data + (ref.cast struct (local.get $a) ) ) @@ -417,7 +417,7 @@ ) ) - ;; TNH: (func $set-get-cast (type $dataref_=>_none) (param $ref dataref) + ;; TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; TNH-NEXT: (drop ;; TNH-NEXT: (struct.get $struct 0 ;; TNH-NEXT: (ref.cast $struct @@ -441,7 +441,7 @@ ;; TNH-NEXT: ) ;; TNH-NEXT: ) ;; TNH-NEXT: ) - ;; NO_TNH: (func $set-get-cast (type $dataref_=>_none) (param $ref dataref) + ;; NO_TNH: (func $set-get-cast (type $structref_=>_none) (param $ref structref) ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (struct.get $struct 0 ;; NO_TNH-NEXT: (ref.cast $struct @@ -465,7 +465,7 @@ ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) - (func $set-get-cast (param $ref (ref null data)) + (func $set-get-cast (param $ref (ref null struct)) ;; A nullable cast flowing into a place that traps on null can become a ;; non-nullable cast. (drop diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index 631697e27..3ecd83d03 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -14,14 +14,12 @@ (field $i64 (mut i64)) )) - ;; CHECK: (type $array (array (mut i8))) - ;; CHECK: (type $A (struct (field i32))) - ;; NOMNL: (type $array (array (mut i8))) - ;; NOMNL: (type $A (struct (field i32))) (type $A (struct (field i32))) + ;; CHECK: (type $array (array (mut i8))) + ;; NOMNL: (type $array (array (mut i8))) (type $array (array (mut i8))) ;; CHECK: (type $B (struct_subtype (field i32) (field i32) (field f32) $A)) @@ -3045,27 +3043,17 @@ ) ) - ;; CHECK: (func $as_of_unreachable (type $none_=>_ref|data|) (result (ref data)) - ;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (unreachable) - ;; CHECK-NEXT: ) + ;; CHECK: (func $as_of_unreachable (type $none_=>_ref|$A|) (result (ref $A)) + ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) - ;; NOMNL: (func $as_of_unreachable (type $none_=>_ref|data|) (result (ref data)) - ;; NOMNL-NEXT: (block ;; (replaces something unreachable we can't emit) - ;; NOMNL-NEXT: (drop - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (unreachable) - ;; NOMNL-NEXT: ) + ;; NOMNL: (func $as_of_unreachable (type $none_=>_ref|$A|) (result (ref $A)) + ;; NOMNL-NEXT: (unreachable) ;; NOMNL-NEXT: ) - (func $as_of_unreachable (result (ref data)) + (func $as_of_unreachable (result (ref $A)) ;; The cast will definitely fail, so we can turn it into an unreachable. The ;; ref.as must then ignore the unreachable input and not error on trying to ;; infer anything about it. - (ref.as_data + (ref.as_non_null (ref.cast $A (ref.null none) ) diff --git a/test/lit/passes/precompute-gc-immutable.wast b/test/lit/passes/precompute-gc-immutable.wast index 5b0d4dffd..2c03bfa7a 100644 --- a/test/lit/passes/precompute-gc-immutable.wast +++ b/test/lit/passes/precompute-gc-immutable.wast @@ -739,7 +739,7 @@ ;; data that is filled with vtables of different types. On usage, we do a ;; cast of the vtable type. - ;; CHECK: (type $itable (array dataref)) + ;; CHECK: (type $itable (array structref)) (type $itable (array (ref null struct))) ;; CHECK: (type $object (struct (field (ref $itable)))) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index b4c529f74..02dc55cbd 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -62,10 +62,10 @@ ) ) - ;; CHECK: (func $br_on-if (type $ref|data|_=>_none) (param $0 (ref data)) + ;; CHECK: (func $br_on-if (type $ref|struct|_=>_none) (param $0 (ref struct)) ;; CHECK-NEXT: (block $label ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (select (result (ref data)) + ;; CHECK-NEXT: (select (result (ref struct)) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const 0) diff --git a/test/lit/passes/rse-gc.wast b/test/lit/passes/rse-gc.wast index 2455ced7d..66b8ee677 100644 --- a/test/lit/passes/rse-gc.wast +++ b/test/lit/passes/rse-gc.wast @@ -2,12 +2,12 @@ ;; RUN: wasm-opt %s --rse -all -S -o - | filecheck %s (module - ;; CHECK: (type $A (struct (field dataref))) + ;; CHECK: (type $A (struct (field structref))) (type $A (struct (field (ref null struct)))) ;; $B is a subtype of $A, and its field has a more refined type (it is non- ;; nullable). - ;; CHECK: (type $B (struct_subtype (field (ref data)) $A)) + ;; CHECK: (type $B (struct_subtype (field (ref struct)) $A)) (type $B (struct_subtype (field (ref struct)) $A)) ;; CHECK: (func $test (type $none_=>_none) diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index 1d631881c..d814e8194 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -359,7 +359,7 @@ ;; CHECK: (type $sig-2 (func (param eqref (ref $struct)))) - ;; CHECK: (type $sig-1 (func (param dataref anyref))) + ;; CHECK: (type $sig-1 (func (param structref anyref))) (type $sig-1 (func_subtype (param anyref) (param anyref) func)) (type $sig-2 (func_subtype (param anyref) (param anyref) func)) @@ -367,7 +367,7 @@ ;; CHECK: (elem declare func $func-2) - ;; CHECK: (func $func-1 (type $sig-1) (param $x dataref) (param $y anyref) + ;; CHECK: (func $func-1 (type $sig-1) (param $x structref) (param $y anyref) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $func-1 (type $sig-1) (param $x anyref) (param $y anyref) @@ -381,7 +381,7 @@ ;; CHECK: (func $caller (type $none_=>_none) ;; CHECK-NEXT: (local $any anyref) - ;; CHECK-NEXT: (local $struct dataref) + ;; CHECK-NEXT: (local $struct structref) ;; CHECK-NEXT: (local $i31 i31ref) ;; CHECK-NEXT: (call $func-1 ;; CHECK-NEXT: (struct.new_default $struct) @@ -737,14 +737,14 @@ ;; Do not modify the types used on imported functions (until the spec and VM ;; support becomes stable). (module - ;; CHECK: (type $dataref_=>_none (func (param dataref))) + ;; CHECK: (type $structref_=>_none (func (param structref))) ;; CHECK: (type $none_=>_none (func)) ;; CHECK: (type $struct (struct )) (type $struct (struct)) - ;; CHECK: (import "a" "b" (func $import (param dataref))) + ;; CHECK: (import "a" "b" (func $import (param structref))) (import "a" "b" (func $import (param (ref null struct)))) ;; CHECK: (func $test (type $none_=>_none) diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 001074b69..38a7d79d8 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -5,14 +5,14 @@ ;; RUN: | filecheck %s --check-prefix=NOMNL (module - ;; CHECK: (type $A (struct (field dataref))) + ;; CHECK: (type $A (struct (field structref))) - ;; CHECK: (type $B (struct_subtype (field (ref data)) $A)) + ;; CHECK: (type $B (struct_subtype (field (ref struct)) $A)) ;; CHECK: (type $struct (struct (field (mut i32)))) - ;; NOMNL: (type $A (struct (field dataref))) + ;; NOMNL: (type $A (struct (field structref))) - ;; NOMNL: (type $B (struct_subtype (field (ref data)) $A)) + ;; NOMNL: (type $B (struct_subtype (field (ref struct)) $A)) ;; NOMNL: (type $struct (struct (field (mut i32)))) (type $struct (struct (field (mut i32)))) @@ -703,12 +703,12 @@ ;; Helper function for the above. ) - ;; CHECK: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_dataref) (param $a (ref null $A)) (param $b (ref null $B)) (result dataref) + ;; CHECK: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_structref) (param $a (ref null $A)) (param $b (ref null $B)) (result structref) ;; CHECK-NEXT: (struct.get $B 0 ;; CHECK-NEXT: (local.get $b) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_dataref) (param $a (ref null $A)) (param $b (ref null $B)) (result dataref) + ;; NOMNL: (func $remove-tee-refinalize (type $ref?|$A|_ref?|$B|_=>_structref) (param $a (ref null $A)) (param $b (ref null $B)) (result structref) ;; NOMNL-NEXT: (struct.get $B 0 ;; NOMNL-NEXT: (local.get $b) ;; NOMNL-NEXT: ) diff --git a/test/lit/passes/vacuum-gc.wast b/test/lit/passes/vacuum-gc.wast index c131bef20..6e70425a2 100644 --- a/test/lit/passes/vacuum-gc.wast +++ b/test/lit/passes/vacuum-gc.wast @@ -12,11 +12,6 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.as_data - ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (ref.as_i31 ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) @@ -31,11 +26,6 @@ ) ) (drop - (ref.as_data - (local.get $x) - ) - ) - (drop (ref.as_i31 (local.get $x) ) @@ -84,12 +74,12 @@ ) ) - ;; CHECK: (func $ref.cast.null.block (type $ref|${}|_=>_dataref) (param $ref (ref ${})) (result dataref) + ;; CHECK: (func $ref.cast.null.block (type $ref|${}|_=>_structref) (param $ref (ref ${})) (result structref) ;; CHECK-NEXT: (ref.cast ${} ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $ref.cast.null.block (param $ref (ref ${})) (result (ref null data)) + (func $ref.cast.null.block (param $ref (ref ${})) (result (ref null struct)) ;; We can vacuum away the block, which will make this ref.cast null operate ;; on a non-nullable input. That is, we are refining the input to the cast. ;; The cast must be updated properly following that, to be a non-nullable diff --git a/test/lit/passes/vacuum-tnh.wast b/test/lit/passes/vacuum-tnh.wast index 40aac16c1..6b0907989 100644 --- a/test/lit/passes/vacuum-tnh.wast +++ b/test/lit/passes/vacuum-tnh.wast @@ -27,11 +27,6 @@ ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: ) ;; NO_TNH-NEXT: (drop - ;; NO_TNH-NEXT: (ref.as_data - ;; NO_TNH-NEXT: (local.get $y) - ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: ) - ;; NO_TNH-NEXT: (drop ;; NO_TNH-NEXT: (ref.as_i31 ;; NO_TNH-NEXT: (local.get $y) ;; NO_TNH-NEXT: ) @@ -56,11 +51,6 @@ ;; Other ref.as* as well. (drop - (ref.as_data - (local.get $y) - ) - ) - (drop (ref.as_i31 (local.get $y) ) diff --git a/test/lit/structref.wast b/test/lit/structref.wast index f4f2fb281..6edf5f86e 100644 --- a/test/lit/structref.wast +++ b/test/lit/structref.wast @@ -4,7 +4,7 @@ ;; Check that `struct` is correctly parsed as an alias for `data`. (module - ;; CHECK: (func $foo (type $dataref_ref|data|_=>_none) (param $x dataref) (param $y (ref data)) + ;; CHECK: (func $foo (type $structref_ref|struct|_=>_none) (param $x structref) (param $y (ref struct)) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $foo (param $x structref) (param $y (ref struct)) 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 fb11af060..97d1b637d 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,49 +1,42 @@ total - [exports] : 8 - [funcs] : 11 + [exports] : 10 + [funcs] : 14 [globals] : 6 [imports] : 5 [memories] : 1 [memory-data] : 22 - [table-data] : 7 + [table-data] : 6 [tables] : 1 [tags] : 0 - [total] : 748 - [vars] : 19 + [total] : 610 + [vars] : 52 ArrayInit : 5 - AtomicFence : 1 - AtomicRMW : 1 - Binary : 84 - Block : 90 - Break : 14 - Call : 19 - CallIndirect : 2 - CallRef : 2 - Const : 176 - Drop : 5 - GlobalGet : 58 - GlobalSet : 25 - I31Get : 2 - I31New : 4 - If : 39 - Load : 22 - LocalGet : 31 - LocalSet : 21 - Loop : 14 - MemoryCopy : 1 - MemoryFill : 1 - Nop : 17 - RefAs : 4 - RefEq : 2 - RefFunc : 9 - RefIsNull : 1 + AtomicFence : 4 + AtomicRMW : 2 + Binary : 66 + Block : 78 + Break : 9 + Call : 21 + CallRef : 1 + Const : 146 + Drop : 9 + GlobalGet : 46 + GlobalSet : 22 + I31New : 3 + If : 28 + Load : 13 + LocalGet : 20 + LocalSet : 17 + Loop : 8 + Nop : 16 + RefFunc : 8 + RefIsNull : 2 RefNull : 5 - Return : 29 - SIMDExtract : 3 - SIMDReplace : 1 - Select : 3 - Store : 5 - StructNew : 2 + Return : 28 + SIMDExtract : 1 + Select : 1 + Store : 4 + StructNew : 6 TupleExtract : 1 - TupleMake : 6 - Unary : 43 + TupleMake : 7 + Unary : 33 diff --git a/test/spec/array.wast b/test/spec/array.wast index c30365030..6e7b8cddb 100644 --- a/test/spec/array.wast +++ b/test/spec/array.wast @@ -8,7 +8,7 @@ (type (array f32)) (type (array f64)) (type (array anyref)) - (type (array (ref data))) + (type (array (ref struct))) (type (array (ref 0))) (type (array (ref null 1))) (type (array (mut i8))) @@ -18,7 +18,7 @@ (type (array (mut i32))) (type (array (mut i64))) (type (array (mut anyref))) - (type (array (mut (ref data)))) + (type (array (mut (ref struct)))) (type (array (mut (ref 0)))) (type (array (mut (ref null i31)))) ) diff --git a/test/spec/ref_cast.wast b/test/spec/ref_cast.wast index b81671e30..f1cfbe24b 100644 --- a/test/spec/ref_cast.wast +++ b/test/spec/ref_cast.wast @@ -6,14 +6,14 @@ (type $t2' (struct_subtype (field i32) (field i32) $t2)) (type $t3 (struct_subtype (field i32) (field i32) $t2)) - (global $tab.0 (mut (ref null data)) (ref.null data)) - (global $tab.1 (mut (ref null data)) (ref.null data)) - (global $tab.2 (mut (ref null data)) (ref.null data)) - (global $tab.3 (mut (ref null data)) (ref.null data)) - (global $tab.4 (mut (ref null data)) (ref.null data)) - (global $tab.10 (mut (ref null data)) (ref.null data)) - (global $tab.11 (mut (ref null data)) (ref.null data)) - (global $tab.12 (mut (ref null data)) (ref.null data)) + (global $tab.0 (mut (ref null struct)) (ref.null struct)) + (global $tab.1 (mut (ref null struct)) (ref.null struct)) + (global $tab.2 (mut (ref null struct)) (ref.null struct)) + (global $tab.3 (mut (ref null struct)) (ref.null struct)) + (global $tab.4 (mut (ref null struct)) (ref.null struct)) + (global $tab.10 (mut (ref null struct)) (ref.null struct)) + (global $tab.11 (mut (ref null struct)) (ref.null struct)) + (global $tab.12 (mut (ref null struct)) (ref.null struct)) (func $init (global.set $tab.0 (struct.new_default $t0)) @@ -29,7 +29,7 @@ (func (export "test-sub") (call $init) - (drop (ref.cast null $t0 (ref.null data))) + (drop (ref.cast null $t0 (ref.null struct))) (drop (ref.cast null $t0 (struct.new_default $t0))) (drop (ref.cast null $t0 (global.get $tab.0))) (drop (ref.cast null $t0 (global.get $tab.1))) @@ -42,19 +42,19 @@ (drop (ref.cast $t0 (global.get $tab.3))) (drop (ref.cast $t0 (global.get $tab.4))) - (drop (ref.cast null $t1 (ref.null data))) + (drop (ref.cast null $t1 (ref.null struct))) (drop (ref.cast null $t1 (struct.new_default $t1))) (drop (ref.cast null $t1 (global.get $tab.1))) (drop (ref.cast null $t1 (global.get $tab.2))) (drop (ref.cast $t1 (global.get $tab.1))) (drop (ref.cast $t1 (global.get $tab.2))) - (drop (ref.cast null $t2 (ref.null data))) + (drop (ref.cast null $t2 (ref.null struct))) (drop (ref.cast null $t2 (struct.new_default $t2))) (drop (ref.cast null $t2 (global.get $tab.2))) (drop (ref.cast $t2 (global.get $tab.2))) - (drop (ref.cast null $t3 (ref.null data))) + (drop (ref.cast null $t3 (ref.null struct))) (drop (ref.cast null $t3 (struct.new_default $t3))) (drop (ref.cast null $t3 (global.get $tab.3))) (drop (ref.cast $t3 (global.get $tab.3))) diff --git a/test/spec/ref_eq.wast b/test/spec/ref_eq.wast index f170bcc06..a5224834c 100644 --- a/test/spec/ref_eq.wast +++ b/test/spec/ref_eq.wast @@ -8,4 +8,4 @@ ) ;; All nulls compare equal, regardless of their type. -(assert_return (invoke "compare" (ref.null data) (ref.null eq)) (i32.const 1)) +(assert_return (invoke "compare" (ref.null none) (ref.null eq)) (i32.const 1)) diff --git a/test/spec/ref_test.wast b/test/spec/ref_test.wast index bb6479548..b0bb1df3d 100644 --- a/test/spec/ref_test.wast +++ b/test/spec/ref_test.wast @@ -141,7 +141,7 @@ (assert_return (invoke "ref_test_struct" (i32.const 2)) (i32.const 1)) (assert_return (invoke "ref_test_struct" (i32.const 3)) (i32.const 0)) (assert_return (invoke "ref_test_struct" (i32.const 4)) (i32.const 2)) -(assert_return (invoke "ref_test_struct" (i32.const 5)) (i32.const 2)) ;; TOOD: expect 0 once struct is not an alias for data +(assert_return (invoke "ref_test_struct" (i32.const 5)) (i32.const 0)) ;; (assert_return (invoke "ref_test_struct" (i32.const 6)) (i32.const 0)) ;; (assert_return (invoke "ref_test_struct" (i32.const 7)) (i32.const 1)) |