diff options
Diffstat (limited to 'test')
32 files changed, 473 insertions, 931 deletions
diff --git a/test/example/stack-utils.cpp b/test/example/stack-utils.cpp index c54040251..f8824e5cb 100644 --- a/test/example/stack-utils.cpp +++ b/test/example/stack-utils.cpp @@ -250,7 +250,7 @@ void test_signature_composition() { } void test_signature_subtype() { - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); Type anyref = Type(HeapType::any, Nullable); std::cout << ";; Test stack signature subtyping\n"; @@ -263,7 +263,7 @@ void test_signature_subtype() { } // Covariance of results { - StackSignature a(Type::none, funcref, StackSignature::Fixed); + StackSignature a(Type::none, eqref, StackSignature::Fixed); StackSignature b(Type::none, anyref, StackSignature::Fixed); assert(StackSignature::isSubType(a, b)); assert(!StackSignature::isSubType(b, a)); @@ -271,7 +271,7 @@ void test_signature_subtype() { // Contravariance of params { StackSignature a(anyref, Type::none, StackSignature::Fixed); - StackSignature b(funcref, Type::none, StackSignature::Fixed); + StackSignature b(eqref, Type::none, StackSignature::Fixed); assert(StackSignature::isSubType(a, b)); assert(!StackSignature::isSubType(b, a)); } @@ -358,7 +358,7 @@ void test_signature_subtype() { } void test_signature_lub() { - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); Type anyref = Type(HeapType::any, Nullable); std::cout << ";; Test stack signature lub\n"; @@ -399,26 +399,25 @@ void test_signature_lub() { } { StackSignature a{Type::none, anyref, StackSignature::Polymorphic}; - StackSignature b{Type::none, funcref, StackSignature::Polymorphic}; + StackSignature b{Type::none, eqref, StackSignature::Polymorphic}; assert(StackSignature::haveLeastUpperBound(a, b)); assert(StackSignature::getLeastUpperBound(a, b) == (StackSignature{Type::none, anyref, StackSignature::Polymorphic})); } { StackSignature a{anyref, Type::none, StackSignature::Polymorphic}; - StackSignature b{funcref, Type::none, StackSignature::Polymorphic}; + StackSignature b{eqref, Type::none, StackSignature::Polymorphic}; // assert(StackSignature::haveLeastUpperBound(a, b)); // assert(StackSignature::getLeastUpperBound(a, b) == - // (StackSignature{funcref, Type::none, + // (StackSignature{eqref, Type::none, // StackSignature::Polymorphic})); } { - StackSignature a{ - {Type::i32, funcref}, funcref, StackSignature::Polymorphic}; - StackSignature b{funcref, {Type::f32, anyref}, StackSignature::Polymorphic}; + StackSignature a{{Type::i32, eqref}, eqref, StackSignature::Polymorphic}; + StackSignature b{eqref, {Type::f32, anyref}, StackSignature::Polymorphic}; assert(StackSignature::haveLeastUpperBound(a, b)); assert(StackSignature::getLeastUpperBound(a, b) == - (StackSignature{{Type::i32, funcref}, + (StackSignature{{Type::i32, eqref}, {Type::f32, anyref}, StackSignature::Polymorphic})); } diff --git a/test/example/type-builder-nominal.cpp b/test/example/type-builder-nominal.cpp index 13224f55e..66dccead3 100644 --- a/test/example/type-builder-nominal.cpp +++ b/test/example/type-builder-nominal.cpp @@ -307,7 +307,7 @@ void test_subtypes() { std::cout << ";; Test subtyping\n"; Type anyref = Type(HeapType::any, Nullable); - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); auto LUB = [&](HeapType a, HeapType b) { Type refA = Type(a, Nullable); @@ -330,14 +330,13 @@ void test_subtypes() { { // Basic Types - for (auto other : {HeapType::func, + for (auto other : {HeapType::eq, HeapType::any, HeapType::eq, HeapType::i31, HeapType::data}) { assert(LUB(HeapType::any, other) == HeapType::any); } - assert(LUB(HeapType::eq, HeapType::func) == HeapType::any); assert(LUB(HeapType::i31, HeapType::data) == HeapType::eq); } @@ -430,7 +429,7 @@ void test_subtypes() { { TypeBuilder builder(2); builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(funcref, Immutable)}); + builder[1] = Struct({Field(eqref, Immutable)}); builder[1].subTypeOf(builder[0]); built = *builder.build(); } diff --git a/test/example/type-builder.cpp b/test/example/type-builder.cpp index 41c556878..7da2f8f03 100644 --- a/test/example/type-builder.cpp +++ b/test/example/type-builder.cpp @@ -223,6 +223,7 @@ void test_recursive() { void test_lub() { std::cout << ";; Test LUBs\n"; + Type ext = Type(HeapType::ext, Nullable); Type func = Type(HeapType::func, Nullable); Type any = Type(HeapType::any, Nullable); Type eq = Type(HeapType::eq, Nullable); @@ -247,10 +248,11 @@ void test_lub() { { // Basic Types - for (auto other : {func, any, eq, i31, data}) { + for (auto other : {any, eq, i31, data}) { assert(LUB(any, other) == any); + assert(LUB(func, other) == Type::none); + assert(LUB(ext, other) == Type::none); } - assert(LUB(eq, func) == any); assert(LUB(i31, data) == eq); } @@ -314,17 +316,17 @@ void test_lub() { { // Immutable fields are covariant - Type a(Array(Field(eq, Immutable)), Nullable); - Type b(Array(Field(func, Immutable)), Nullable); - Type lub(Array(Field(any, Immutable)), Nullable); + Type a(Array(Field(data, Immutable)), Nullable); + Type b(Array(Field(i31, Immutable)), Nullable); + Type lub(Array(Field(eq, Immutable)), Nullable); assert(LUB(a, b) == lub); } { // Depth subtyping - Type a(Struct({Field(eq, Immutable)}), Nullable); - Type b(Struct({Field(func, Immutable)}), Nullable); - Type lub(Struct({Field(any, Immutable)}), Nullable); + Type a(Struct({Field(data, Immutable)}), Nullable); + Type b(Struct({Field(i31, Immutable)}), Nullable); + Type lub(Struct({Field(eq, Immutable)}), Nullable); assert(LUB(a, b) == lub); } @@ -348,11 +350,11 @@ void test_lub() { { // Width and depth subtyping with different suffixes - Type a(Struct({Field(eq, Immutable), Field(Type::i64, Immutable)}), + Type a(Struct({Field(data, Immutable), Field(Type::i64, Immutable)}), Nullable); - Type b(Struct({Field(func, Immutable), Field(Type::f32, Immutable)}), + Type b(Struct({Field(i31, Immutable), Field(Type::f32, Immutable)}), Nullable); - Type lub(Struct({Field(any, Immutable)}), Nullable); + Type lub(Struct({Field(eq, Immutable)}), Nullable); assert(LUB(a, b) == lub); } @@ -368,9 +370,9 @@ void test_lub() { { // Nested structs - Type innerA(Struct({Field(eq, Immutable)}), Nullable); - Type innerB(Struct({Field(func, Immutable)}), Nullable); - Type innerLub(Struct({Field(any, Immutable)}), Nullable); + Type innerA(Struct({Field(data, Immutable)}), Nullable); + Type innerB(Struct({Field(i31, Immutable)}), Nullable); + Type innerLub(Struct({Field(eq, Immutable)}), Nullable); Type a(Struct({Field(innerA, Immutable)}), Nullable); Type b(Struct({Field(innerB, Immutable)}), Nullable); Type lub(Struct({Field(innerLub, Immutable)}), Nullable); @@ -382,15 +384,15 @@ void test_lub() { TypeBuilder builder(2); Type tempA = builder.getTempRefType(builder[0], Nullable); Type tempB = builder.getTempRefType(builder[1], Nullable); - builder[0] = Struct({Field(tempB, Immutable), Field(eq, Immutable)}); - builder[1] = Struct({Field(tempA, Immutable), Field(func, Immutable)}); + builder[0] = Struct({Field(tempB, Immutable), Field(data, Immutable)}); + builder[1] = Struct({Field(tempA, Immutable), Field(i31, Immutable)}); auto built = *builder.build(); Type a(built[0], Nullable); Type b(built[1], Nullable); TypeBuilder lubBuilder(1); Type tempLub = builder.getTempRefType(lubBuilder[0], Nullable); - lubBuilder[0] = Struct({Field(tempLub, Immutable), Field(any, Immutable)}); + lubBuilder[0] = Struct({Field(tempLub, Immutable), Field(eq, Immutable)}); built = *lubBuilder.build(); Type lub(built[0], Nullable); diff --git a/test/exception-handling.wast b/test/exception-handling.wast index 93dbe41ba..d37cc322b 100644 --- a/test/exception-handling.wast +++ b/test/exception-handling.wast @@ -2,7 +2,7 @@ (tag $e-i32 (param i32)) (tag $e-i64 (param i64)) (tag $e-i32-i64 (param i32 i64)) - (tag $e-funcref (param funcref)) + (tag $e-eqref (param (ref null eq))) (tag $e-empty) (func $foo) @@ -330,7 +330,7 @@ (try (do) - (catch $e-funcref + (catch $e-eqref (drop (pop anyref) ;; pop can be supertype ) diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast index be14cda0f..b5926ca09 100644 --- a/test/exception-handling.wast.from-wast +++ b/test/exception-handling.wast.from-wast @@ -3,11 +3,11 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (type $funcref_=>_none (func (param funcref))) + (type $eqref_=>_none (func (param eqref))) (tag $e-i32 (param i32)) (tag $e-i64 (param i64)) (tag $e-i32-i64 (param i32 i64)) - (tag $e-funcref (param funcref)) + (tag $e-eqref (param eqref)) (tag $e-empty (param)) (func $foo (nop) @@ -372,7 +372,7 @@ (do (nop) ) - (catch $e-funcref + (catch $e-eqref (drop (pop anyref) ) diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary index 5642a4f2d..74e8f4d4a 100644 --- a/test/exception-handling.wast.fromBinary +++ b/test/exception-handling.wast.fromBinary @@ -3,11 +3,11 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (type $funcref_=>_none (func (param funcref))) + (type $eqref_=>_none (func (param eqref))) (tag $tag$0 (param i32)) (tag $tag$1 (param i64)) (tag $tag$2 (param i32 i64)) - (tag $tag$3 (param funcref)) + (tag $tag$3 (param eqref)) (tag $tag$4 (param)) (func $foo (nop) @@ -403,7 +403,7 @@ ) (catch $tag$3 (drop - (pop funcref) + (pop eqref) ) ) ) diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo index 08d31f361..c3f2a8307 100644 --- a/test/exception-handling.wast.fromBinary.noDebugInfo +++ b/test/exception-handling.wast.fromBinary.noDebugInfo @@ -3,11 +3,11 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) - (type $funcref_=>_none (func (param funcref))) + (type $eqref_=>_none (func (param eqref))) (tag $tag$0 (param i32)) (tag $tag$1 (param i64)) (tag $tag$2 (param i32 i64)) - (tag $tag$3 (param funcref)) + (tag $tag$3 (param eqref)) (tag $tag$4 (param)) (func $0 (nop) @@ -403,7 +403,7 @@ ) (catch $tag$3 (drop - (pop funcref) + (pop eqref) ) ) ) diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp index 90c6cac51..27ab5b8fb 100644 --- a/test/gtest/possible-contents.cpp +++ b/test/gtest/possible-contents.cpp @@ -65,6 +65,7 @@ protected: Type anyref = Type(HeapType::any, Nullable); Type funcref = Type(HeapType::func, Nullable); + Type i31ref = Type(HeapType::i31, Nullable); PossibleContents none = PossibleContents::none(); @@ -75,6 +76,8 @@ protected: PossibleContents::literal(Literal::makeNull(HeapType::any)); PossibleContents funcNull = PossibleContents::literal(Literal::makeNull(HeapType::func)); + PossibleContents i31Null = + PossibleContents::literal(Literal::makeNull(HeapType::i31)); PossibleContents i32Global1 = PossibleContents::global("i32Global1", Type::i32); @@ -89,10 +92,13 @@ protected: PossibleContents exactI32 = PossibleContents::exactType(Type::i32); PossibleContents exactAnyref = PossibleContents::exactType(anyref); PossibleContents exactFuncref = PossibleContents::exactType(funcref); + PossibleContents exactI31ref = PossibleContents::exactType(i31ref); PossibleContents exactNonNullAnyref = PossibleContents::exactType(Type(HeapType::any, NonNullable)); PossibleContents exactNonNullFuncref = PossibleContents::exactType(Type(HeapType::func, NonNullable)); + PossibleContents exactNonNullI31ref = + PossibleContents::exactType(Type(HeapType::i31, NonNullable)); PossibleContents exactFuncSignatureType = PossibleContents::exactType( Type(Signature(Type::none, Type::none), Nullable)); @@ -183,7 +189,10 @@ TEST_F(PossibleContentsTest, TestCombinations) { assertCombination(anyNull, exactAnyref, exactAnyref); // Two nulls go to the lub. - assertCombination(anyNull, funcNull, anyNull); + assertCombination(anyNull, i31Null, anyNull); + + // Incompatible nulls go to Many. + assertCombination(anyNull, funcNull, many); assertCombination(exactNonNullAnyref, exactNonNullAnyref, exactNonNullAnyref); @@ -191,13 +200,12 @@ TEST_F(PossibleContentsTest, TestCombinations) { // null be a nullable type - but keeps the heap type of the other (since the // type of the null does not matter, all nulls compare equal). assertCombination(anyNull, exactNonNullAnyref, exactAnyref); - assertCombination(anyNull, exactNonNullFuncref, exactFuncref); + assertCombination(anyNull, exactNonNullI31ref, exactI31ref); // Funcrefs // A function reference + a null becomes an exact type (of that sig), plus // nullability. - assertCombination(nonNullFunc, anyNull, exactFuncSignatureType); assertCombination(nonNullFunc, funcNull, exactFuncSignatureType); assertCombination(exactFuncSignatureType, funcNull, exactFuncSignatureType); assertCombination( @@ -211,7 +219,7 @@ TEST_F(PossibleContentsTest, TestCombinations) { // Globals vs nulls. assertCombination(anyGlobal, anyNull, many); - assertCombination(anyGlobal, funcNull, many); + assertCombination(anyGlobal, i31Null, many); } TEST_F(PossibleContentsTest, TestOracleMinimal) { diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp index 563ea0933..4b282ea7c 100644 --- a/test/gtest/type-builder.cpp +++ b/test/gtest/type-builder.cpp @@ -500,16 +500,19 @@ TEST_F(IsorecursiveTest, CanonicalizeBasicTypes) { } // Test SubTypes utility code. -TEST_F(NominalTest, testSubTypes) { +TEST_F(NominalTest, TestSubTypes) { Type anyref = Type(HeapType::any, Nullable); - Type funcref = Type(HeapType::func, Nullable); + Type eqref = Type(HeapType::eq, Nullable); // Build type types, the second of which is a subtype. TypeBuilder builder(2); builder[0] = Struct({Field(anyref, Immutable)}); - builder[1] = Struct({Field(funcref, Immutable)}); + builder[1] = Struct({Field(eqref, Immutable)}); builder[1].subTypeOf(builder[0]); - auto built = *builder.build(); + + auto result = builder.build(); + ASSERT_TRUE(result); + auto built = *result; // Build a tiny wasm module that uses the types, so that we can test the // SubTypes utility code. diff --git a/test/lit/passes/dae-gc-refine-return.wast b/test/lit/passes/dae-gc-refine-return.wast index a349fbdfd..f0a6fa18e 100644 --- a/test/lit/passes/dae-gc-refine-return.wast +++ b/test/lit/passes/dae-gc-refine-return.wast @@ -9,18 +9,16 @@ ;; CHECK: (type ${i32} (struct (field i32))) - ;; CHECK: (type ${i32_i64} (struct (field i32) (field i64))) - ;; CHECK: (type ${i32_f32} (struct (field i32) (field f32))) ;; NOMNL: (type ${} (struct_subtype data)) ;; NOMNL: (type ${i32} (struct_subtype (field i32) ${})) - ;; NOMNL: (type ${i32_i64} (struct_subtype (field i32) (field i64) ${i32})) - ;; NOMNL: (type ${i32_f32} (struct_subtype (field i32) (field f32) ${i32})) (type ${i32_f32} (struct_subtype (field i32) (field f32) ${i32})) + ;; CHECK: (type ${i32_i64} (struct (field i32) (field i64))) + ;; NOMNL: (type ${i32_i64} (struct_subtype (field i32) (field i64) ${i32})) (type ${i32_i64} (struct_subtype (field i32) (field i64) ${i32})) (type ${i32} (struct_subtype (field i32) ${})) @@ -82,47 +80,47 @@ ) ;; Refine the return type based on the value flowing out. - ;; CHECK: (func $refine-return-flow (result funcref) + ;; CHECK: (func $refine-return-flow (result (ref null i31)) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $refine-return-flow) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-flow (type $none_=>_funcref) (result funcref) + ;; NOMNL: (func $refine-return-flow (type $none_=>_ref?|i31|) (result (ref null i31)) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $refine-return-flow) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) (func $refine-return-flow (result anyref) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local.set $temp (call $refine-return-flow)) - (local.get $func) + (local.get $i31) ) - ;; CHECK: (func $call-refine-return-flow (result funcref) + ;; CHECK: (func $call-refine-return-flow (result (ref null i31)) ;; CHECK-NEXT: (local $temp anyref) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $call-refine-return-flow) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (if (result funcref) + ;; CHECK-NEXT: (if (result (ref null i31)) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (call $refine-return-flow) ;; CHECK-NEXT: (call $refine-return-flow) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $call-refine-return-flow (type $none_=>_funcref) (result funcref) + ;; NOMNL: (func $call-refine-return-flow (type $none_=>_ref?|i31|) (result (ref null i31)) ;; NOMNL-NEXT: (local $temp anyref) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $call-refine-return-flow) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (if (result funcref) + ;; NOMNL-NEXT: (if (result (ref null i31)) ;; NOMNL-NEXT: (i32.const 1) ;; NOMNL-NEXT: (call $refine-return-flow) ;; NOMNL-NEXT: (call $refine-return-flow) @@ -143,104 +141,104 @@ ) ;; Refine the return type based on a return. - ;; CHECK: (func $refine-return-return (result funcref) + ;; CHECK: (func $refine-return-return (result (ref null i31)) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $refine-return-return) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-return (type $none_=>_funcref) (result funcref) + ;; NOMNL: (func $refine-return-return (type $none_=>_ref?|i31|) (result (ref null i31)) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $refine-return-return) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $refine-return-return (result anyref) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local.set $temp (call $refine-return-return)) - (return (local.get $func)) + (return (local.get $i31)) ) ;; Refine the return type based on multiple values. - ;; CHECK: (func $refine-return-many (result funcref) + ;; CHECK: (func $refine-return-many (result (ref null i31)) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (call $refine-return-many) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-many (type $none_=>_funcref) (result funcref) + ;; NOMNL: (func $refine-return-many (type $none_=>_ref?|i31|) (result (ref null i31)) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (call $refine-return-many) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if ;; NOMNL-NEXT: (i32.const 1) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if ;; NOMNL-NEXT: (i32.const 2) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) (func $refine-return-many (result anyref) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local.set $temp (call $refine-return-many)) (if (i32.const 1) - (return (local.get $func)) + (return (local.get $i31)) ) (if (i32.const 2) - (return (local.get $func)) + (return (local.get $i31)) ) - (local.get $func) + (local.get $i31) ) - ;; CHECK: (func $refine-return-many-blocked (result anyref) + ;; CHECK: (func $refine-return-many-lub (result eqref) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local $data (ref null data)) ;; CHECK-NEXT: (local.set $temp - ;; CHECK-NEXT: (call $refine-return-many-blocked) + ;; CHECK-NEXT: (call $refine-return-many-lub) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if @@ -249,19 +247,19 @@ ;; CHECK-NEXT: (local.get $data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-many-blocked (type $none_=>_anyref) (result anyref) + ;; NOMNL: (func $refine-return-many-lub (type $none_=>_eqref) (result eqref) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local $data (ref null data)) ;; NOMNL-NEXT: (local.set $temp - ;; NOMNL-NEXT: (call $refine-return-many-blocked) + ;; NOMNL-NEXT: (call $refine-return-many-lub) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if ;; NOMNL-NEXT: (i32.const 1) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if @@ -270,168 +268,118 @@ ;; NOMNL-NEXT: (local.get $data) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) - (func $refine-return-many-blocked (result anyref) + (func $refine-return-many-lub (result anyref) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local $data (ref null data)) - (local.set $temp (call $refine-return-many-blocked)) + (local.set $temp (call $refine-return-many-lub)) (if (i32.const 1) - (return (local.get $func)) + (return (local.get $i31)) ) (if (i32.const 2) - ;; The refined return value is blocked by this return. + ;; The refined return type has to be a supertype of data. (return (local.get $data)) ) - (local.get $func) + (local.get $i31) ) - ;; CHECK: (func $refine-return-many-blocked-2 (result anyref) + ;; CHECK: (func $refine-return-many-lub-2 (result eqref) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local $data (ref null data)) ;; CHECK-NEXT: (local.set $temp - ;; CHECK-NEXT: (call $refine-return-many-blocked-2) + ;; CHECK-NEXT: (call $refine-return-many-lub-2) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.get $data) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-many-blocked-2 (type $none_=>_anyref) (result anyref) + ;; NOMNL: (func $refine-return-many-lub-2 (type $none_=>_eqref) (result eqref) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local $data (ref null data)) ;; NOMNL-NEXT: (local.set $temp - ;; NOMNL-NEXT: (call $refine-return-many-blocked-2) + ;; NOMNL-NEXT: (call $refine-return-many-lub-2) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if ;; NOMNL-NEXT: (i32.const 1) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (if ;; NOMNL-NEXT: (i32.const 2) ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (local.get $data) ;; NOMNL-NEXT: ) - (func $refine-return-many-blocked-2 (result anyref) + (func $refine-return-many-lub-2 (result anyref) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local $data (ref null data)) - (local.set $temp (call $refine-return-many-blocked-2)) + (local.set $temp (call $refine-return-many-lub-2)) (if (i32.const 1) - (return (local.get $func)) + (return (local.get $i31)) ) (if (i32.const 2) - (return (local.get $func)) + (return (local.get $i31)) ) - ;; The refined return value is blocked by this value. + ;; The refined return type has to be a supertype of data. (local.get $data) ) - ;; CHECK: (func $refine-return-many-middle (result (ref null ${i32})) - ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local ${i32_i64} (ref null ${i32_i64})) - ;; CHECK-NEXT: (local ${i32_f32} (ref null ${i32_f32})) - ;; CHECK-NEXT: (local.set $temp - ;; CHECK-NEXT: (call $refine-return-many-middle) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (if - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get ${i32_i64}) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (return - ;; CHECK-NEXT: (local.get ${i32_f32}) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-many-middle (type $none_=>_ref?|${i32}|) (result (ref null ${i32})) - ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local ${i32_i64} (ref null ${i32_i64})) - ;; NOMNL-NEXT: (local ${i32_f32} (ref null ${i32_f32})) - ;; NOMNL-NEXT: (local.set $temp - ;; NOMNL-NEXT: (call $refine-return-many-middle) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (if - ;; NOMNL-NEXT: (i32.const 1) - ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get ${i32_i64}) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: (return - ;; NOMNL-NEXT: (local.get ${i32_f32}) - ;; NOMNL-NEXT: ) - ;; NOMNL-NEXT: ) - (func $refine-return-many-middle (result anyref) - (local $temp anyref) - (local ${i32_i64} (ref null ${i32_i64})) - (local ${i32_f32} (ref null ${i32_f32})) - - (local.set $temp (call $refine-return-many-middle)) - - ;; Return two different struct types, with an LUB that is not equal to either - ;; of them. - (if - (i32.const 1) - (return (local.get ${i32_i64})) - ) - (return (local.get ${i32_f32})) - ) - ;; We can refine the return types of tuples. - ;; CHECK: (func $refine-return-tuple (result funcref i32) + ;; CHECK: (func $refine-return-tuple (result (ref null i31) i32) ;; CHECK-NEXT: (local $temp anyref) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (local.set $temp ;; CHECK-NEXT: (tuple.extract 0 ;; CHECK-NEXT: (call $refine-return-tuple) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (tuple.make - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $refine-return-tuple (type $none_=>_funcref_i32) (result funcref i32) + ;; NOMNL: (func $refine-return-tuple (type $none_=>_ref?|i31|_i32) (result (ref null i31) i32) ;; NOMNL-NEXT: (local $temp anyref) - ;; NOMNL-NEXT: (local $func funcref) + ;; NOMNL-NEXT: (local $i31 (ref null i31)) ;; NOMNL-NEXT: (local.set $temp ;; NOMNL-NEXT: (tuple.extract 0 ;; NOMNL-NEXT: (call $refine-return-tuple) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (tuple.make - ;; NOMNL-NEXT: (local.get $func) + ;; NOMNL-NEXT: (local.get $i31) ;; NOMNL-NEXT: (i32.const 1) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $refine-return-tuple (result anyref i32) (local $temp anyref) - (local $func funcref) + (local $i31 (ref null i31)) (local.set $temp (tuple.extract 0 @@ -440,7 +388,7 @@ ) (tuple.make - (local.get $func) + (local.get $i31) (i32.const 1) ) ) diff --git a/test/lit/passes/dae-gc.wast b/test/lit/passes/dae-gc.wast index ea4cce506..7740d8345 100644 --- a/test/lit/passes/dae-gc.wast +++ b/test/lit/passes/dae-gc.wast @@ -164,7 +164,7 @@ ) ) - ;; CHECK: (func $bar (param $0 (ref null $none_=>_none)) + ;; CHECK: (func $bar (param $0 (ref null i31)) ;; CHECK-NEXT: (local $1 anyref) ;; CHECK-NEXT: (local.set $1 ;; CHECK-NEXT: (ref.null any) @@ -178,7 +178,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; NOMNL: (func $bar (type $ref?|none_->_none|_=>_none) (param $0 (ref null $none_=>_none)) + ;; NOMNL: (func $bar (type $ref?|i31|_=>_none) (param $0 (ref null i31)) ;; NOMNL-NEXT: (local $1 anyref) ;; NOMNL-NEXT: (local.set $1 ;; NOMNL-NEXT: (ref.null any) @@ -200,18 +200,22 @@ ;; CHECK: (func $call-bar ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (ref.null $none_=>_none) + ;; CHECK-NEXT: (ref.null i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (ref.func $a) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; NOMNL: (func $call-bar (type $none_=>_none) ;; NOMNL-NEXT: (call $bar - ;; NOMNL-NEXT: (ref.null $none_=>_none) + ;; NOMNL-NEXT: (ref.null i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: (call $bar - ;; NOMNL-NEXT: (ref.func $a) + ;; NOMNL-NEXT: (i31.new + ;; NOMNL-NEXT: (i32.const 0) + ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $call-bar @@ -219,12 +223,12 @@ ;; we can optimize (to the LUB of the nulls). However, mixing a null with a ;; reference stops us in the second param. (call $bar - (ref.null func) - (ref.null func) + (ref.null i31) + (ref.null data) ) (call $bar (ref.null any) - (ref.func $a) + (i31.new (i32.const 0)) ) ) diff --git a/test/lit/passes/global-refining.wast b/test/lit/passes/global-refining.wast index 633d88e5f..4e92880b3 100644 --- a/test/lit/passes/global-refining.wast +++ b/test/lit/passes/global-refining.wast @@ -6,40 +6,42 @@ ;; a null, so we have nothing concrete to improve with (though we could use ;; the type of the null perhaps, TODO). The second is a ref.func which lets ;; us refine. - ;; CHECK: (type $none_=>_none (func_subtype func)) - - ;; CHECK: (global $func-null-init (mut anyref) (ref.null func)) - (global $func-null-init (mut anyref) (ref.null func)) - ;; CHECK: (global $func-func-init (mut (ref $none_=>_none)) (ref.func $foo)) - (global $func-func-init (mut anyref) (ref.func $foo)) - ;; CHECK: (func $foo (type $none_=>_none) + ;; CHECK: (type $foo_t (func_subtype func)) + (type $foo_t (func)) + + ;; CHECK: (global $func-null-init (mut funcref) (ref.null $foo_t)) + (global $func-null-init (mut funcref) (ref.null $foo_t)) + ;; CHECK: (global $func-func-init (mut (ref $foo_t)) (ref.func $foo)) + (global $func-func-init (mut funcref) (ref.func $foo)) + ;; CHECK: (func $foo (type $foo_t) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) - (func $foo) + (func $foo (type $foo_t)) ) (module ;; Globals with later assignments of null. The global with a function in its ;; init will update the null to allow it to refine. - ;; CHECK: (type $none_=>_none (func_subtype func)) + ;; CHECK: (type $foo_t (func_subtype func)) + (type $foo_t (func)) - ;; CHECK: (global $func-null-init (mut anyref) (ref.null func)) - (global $func-null-init (mut anyref) (ref.null func)) - ;; CHECK: (global $func-func-init (mut (ref null $none_=>_none)) (ref.func $foo)) - (global $func-func-init (mut anyref) (ref.func $foo)) + ;; CHECK: (global $func-null-init (mut funcref) (ref.null $foo_t)) + (global $func-null-init (mut funcref) (ref.null $foo_t)) + ;; CHECK: (global $func-func-init (mut (ref null $foo_t)) (ref.func $foo)) + (global $func-func-init (mut funcref) (ref.func $foo)) - ;; CHECK: (func $foo (type $none_=>_none) + ;; CHECK: (func $foo (type $foo_t) ;; CHECK-NEXT: (global.set $func-null-init - ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: (ref.null func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $func-func-init - ;; CHECK-NEXT: (ref.null $none_=>_none) + ;; CHECK-NEXT: (ref.null $foo_t) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $foo - (global.set $func-null-init (ref.null any)) - (global.set $func-func-init (ref.null any)) + (func $foo (type $foo_t) + (global.set $func-null-init (ref.null func)) + (global.set $func-func-init (ref.null $foo_t)) ) ) @@ -50,9 +52,9 @@ ;; CHECK: (type $none_=>_none (func_subtype func)) ;; CHECK: (global $func-null-init (mut (ref null $none_=>_none)) (ref.null $none_=>_none)) - (global $func-null-init (mut anyref) (ref.null func)) + (global $func-null-init (mut funcref) (ref.null func)) ;; CHECK: (global $func-func-init (mut (ref $none_=>_none)) (ref.func $foo)) - (global $func-func-init (mut anyref) (ref.func $foo)) + (global $func-func-init (mut funcref) (ref.func $foo)) ;; CHECK: (elem declare func $foo) @@ -76,44 +78,39 @@ ;; CHECK: (type $none_=>_none (func_subtype func)) - ;; CHECK: (type $i32_=>_none (func_subtype (param i32) func)) + ;; CHECK: (type $struct (struct_subtype data)) + (type $struct (struct)) + ;; CHECK: (type $array (array_subtype i8 data)) + (type $array (array i8)) - ;; CHECK: (global $global (mut funcref) (ref.null func)) + ;; CHECK: (global $global (mut eqref) (ref.null eq)) (global $global (mut anyref) (ref.null any)) - ;; CHECK: (elem declare func $bar $foo) - ;; CHECK: (func $foo (type $none_=>_none) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (ref.func $foo) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (ref.func $bar) + ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null eq) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null i31) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (global.set $global - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null $array) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $foo - (global.set $global (ref.func $foo)) - (global.set $global (ref.func $bar)) - (global.set $global (ref.null func)) - ;; These nulls will be updated. + (global.set $global (i31.new (i32.const 0))) + (global.set $global (struct.new_default $struct)) (global.set $global (ref.null eq)) - (global.set $global (ref.null data)) - ) - - ;; CHECK: (func $bar (type $i32_=>_none) (param $x i32) - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ) - (func $bar (param $x i32) - ;; A function with a different signature, whose reference is also assigned - ;; to the global. + ;; These nulls will be updated. + (global.set $global (ref.null i31)) + (global.set $global (ref.null $array)) ) ) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 08cb6a166..603dc514c 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -2453,8 +2453,6 @@ ;; CHECK: (import "a" "b" (func $import (result i32))) (import "a" "b" (func $import (result i32))) - ;; CHECK: (elem declare func $test) - ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (unreachable) @@ -2526,17 +2524,14 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block (result (ref null $struct)) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (ref.cast_static $struct - ;; CHECK-NEXT: (select (result anyref) - ;; CHECK-NEXT: (ref.null $struct) - ;; CHECK-NEXT: (ref.func $test) - ;; CHECK-NEXT: (call $import) - ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (ref.cast_static $struct + ;; CHECK-NEXT: (select (result eqref) + ;; CHECK-NEXT: (ref.null $struct) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $import) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.null $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop @@ -2563,14 +2558,14 @@ ) ) ) - ;; A null or a func will reach the cast; only the null can actually pass - ;; through (a func would fail the cast). Given that, we can infer a null for + ;; A null or an i31 will reach the cast; only the null can actually pass + ;; through (an i31 would fail the cast). Given that, we can infer a null for ;; the value of the cast. (drop (ref.cast_static $struct (select (ref.null $struct) - (ref.func $test) + (i31.new (i32.const 0)) (call $import) ) ) @@ -2773,21 +2768,21 @@ ;; array.copy between types. (module - ;; CHECK: (type $none_=>_none (func_subtype func)) - ;; CHECK: (type $bytes (array_subtype (mut anyref) data)) (type $bytes (array (mut anyref))) ;; CHECK: (type $chars (array_subtype (mut anyref) data)) (type $chars (array (mut anyref))) - ;; CHECK: (elem declare func $test) + ;; CHECK: (type $none_=>_none (func_subtype func)) ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (local $bytes (ref null $bytes)) ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes ;; CHECK-NEXT: (array.init_static $bytes - ;; CHECK-NEXT: (ref.func $test) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $chars @@ -2803,14 +2798,9 @@ ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block (result (ref $none_=>_none)) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.get $bytes - ;; CHECK-NEXT: (local.get $bytes) - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.func $test) + ;; CHECK-NEXT: (array.get $bytes + ;; CHECK-NEXT: (local.get $bytes) + ;; CHECK-NEXT: (i32.const 0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop @@ -2829,7 +2819,7 @@ ;; there. (local.set $bytes (array.init_static $bytes - (ref.func $test) + (i31.new (i32.const 0)) ) ) (local.set $chars @@ -2870,14 +2860,14 @@ ;; CHECK: (type $none_=>_none (func_subtype func)) - ;; CHECK: (elem declare func $test) - ;; CHECK: (func $test (type $none_=>_none) ;; CHECK-NEXT: (local $bytes (ref null $bytes)) ;; CHECK-NEXT: (local $chars (ref null $chars)) ;; CHECK-NEXT: (local.set $bytes ;; CHECK-NEXT: (array.init_static $bytes - ;; CHECK-NEXT: (ref.func $test) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $chars @@ -2915,7 +2905,7 @@ (local $chars (ref null $chars)) (local.set $bytes (array.init_static $bytes - (ref.func $test) + (i31.new (i32.const 0)) ) ) (local.set $chars diff --git a/test/lit/passes/inlining_splitting.wast b/test/lit/passes/inlining_splitting.wast index 546e31b37..76062f0c0 100644 --- a/test/lit/passes/inlining_splitting.wast +++ b/test/lit/passes/inlining_splitting.wast @@ -1216,7 +1216,7 @@ ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (block $__inlined_func$byn-split-inlineable-B$multi-if0 (result anyref) ;; CHECK-NEXT: (local.set $1 - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (block (result anyref) ;; CHECK-NEXT: (if @@ -1246,7 +1246,7 @@ ;; CHECK-NEXT: ) (func $call-multi-if (drop (call $multi-if (ref.null any))) - (drop (call $multi-if (ref.null func))) + (drop (call $multi-if (ref.null data))) ) ;; CHECK: (func $too-many-ifs (param $x anyref) (result anyref) @@ -1325,13 +1325,13 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $too-many-ifs - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $call-too-many-ifs (drop (call $too-many-ifs (ref.null any))) - (drop (call $too-many-ifs (ref.null func))) + (drop (call $too-many-ifs (ref.null data))) ) ) diff --git a/test/lit/passes/local-subtyping-nn.wast b/test/lit/passes/local-subtyping-nn.wast index 9b68a6480..24517fb08 100644 --- a/test/lit/passes/local-subtyping-nn.wast +++ b/test/lit/passes/local-subtyping-nn.wast @@ -45,7 +45,7 @@ ;; NOMNL-NEXT: ) (func $non-nullable (local $x (ref null $struct)) - (local $y anyref) + (local $y funcref) ;; x is assigned a value that is non-nullable. (local.set $x (ref.as_non_null (ref.null $struct)) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index 31e08cce0..98de29e27 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -9,6 +9,8 @@ ;; CHECK: (type ${i32} (struct (field i32))) (type ${i32} (struct_subtype (field i32) data)) + (type $array (array_subtype i8 data)) + ;; CHECK: (import "out" "i32" (func $i32 (result i32))) (import "out" "i32" (func $i32 (result i32))) ;; CHECK: (import "out" "i64" (func $i64 (result i64))) @@ -18,18 +20,26 @@ ;; not the optimal LUB. ;; CHECK: (func $refinalize (param $x i32) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (if (result (ref func)) + ;; CHECK-NEXT: (if (result i31ref) ;; CHECK-NEXT: (local.get $x) - ;; CHECK-NEXT: (ref.func $i32) - ;; CHECK-NEXT: (ref.func $i64) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (block $block (result (ref func)) + ;; CHECK-NEXT: (block $block (result i31ref) ;; CHECK-NEXT: (br $block - ;; CHECK-NEXT: (ref.func $i32) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (ref.func $i64) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -37,16 +47,16 @@ (drop (if (result anyref) (local.get $x) - (ref.func $i32) - (ref.func $i64) + (i31.new (i32.const 0)) + (i31.new (i32.const 1)) ) ) (drop (block $block (result anyref) (br $block - (ref.func $i32) + (i31.new (i32.const 0)) ) - (ref.func $i64) + (i31.new (i32.const 1)) ) ) ) @@ -54,9 +64,9 @@ ;; A simple case where a local has a single assignment that we can use as a ;; more specific type. A similar thing with a parameter, however, is not a ;; thing we can optimize. Also, ignore a local with zero assignments. - ;; CHECK: (func $simple-local-but-not-param (param $x anyref) + ;; CHECK: (func $simple-local-but-not-param (param $x funcref) ;; CHECK-NEXT: (local $y (ref null $none_=>_i32)) - ;; CHECK-NEXT: (local $unused anyref) + ;; CHECK-NEXT: (local $unused funcref) ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (ref.func $i32) ;; CHECK-NEXT: ) @@ -64,9 +74,9 @@ ;; CHECK-NEXT: (ref.func $i32) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $simple-local-but-not-param (param $x anyref) - (local $y anyref) - (local $unused anyref) + (func $simple-local-but-not-param (param $x funcref) + (local $y funcref) + (local $unused funcref) (local.set $x (ref.func $i32) ) @@ -75,28 +85,34 @@ ) ) - ;; CHECK: (func $locals-with-multiple-assignments - ;; CHECK-NEXT: (local $x funcref) - ;; CHECK-NEXT: (local $y (ref null $none_=>_i32)) - ;; CHECK-NEXT: (local $z (ref null $none_=>_i64)) + ;; CHECK: (func $locals-with-multiple-assignments (param $data (ref null data)) + ;; CHECK-NEXT: (local $x eqref) + ;; CHECK-NEXT: (local $y (ref null i31)) + ;; CHECK-NEXT: (local $z (ref null data)) ;; CHECK-NEXT: (local $w funcref) ;; CHECK-NEXT: (local.set $x - ;; CHECK-NEXT: (ref.func $i32) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $x - ;; CHECK-NEXT: (ref.func $i64) + ;; CHECK-NEXT: (local.get $data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y - ;; CHECK-NEXT: (ref.func $i32) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y - ;; CHECK-NEXT: (ref.func $i32) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $z - ;; CHECK-NEXT: (ref.func $i64) + ;; CHECK-NEXT: (local.get $data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $z - ;; CHECK-NEXT: (ref.func $i64) + ;; CHECK-NEXT: (local.get $data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $w ;; CHECK-NEXT: (ref.func $i32) @@ -105,30 +121,30 @@ ;; CHECK-NEXT: (ref.func $i64) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $locals-with-multiple-assignments + (func $locals-with-multiple-assignments (param $data (ref null data)) (local $x anyref) (local $y anyref) (local $z anyref) (local $w funcref) ;; x is assigned two different types with a new LUB possible (local.set $x - (ref.func $i32) + (i31.new (i32.const 0)) ) (local.set $x - (ref.func $i64) + (local.get $data) ) ;; y and z are assigned the same more specific type twice (local.set $y - (ref.func $i32) + (i31.new (i32.const 0)) ) (local.set $y - (ref.func $i32) + (i31.new (i32.const 1)) ) (local.set $z - (ref.func $i64) + (local.get $data) ) (local.set $z - (ref.func $i64) + (local.get $data) ) ;; w is assigned two different types *without* a new LUB possible, as it ;; already had the optimal LUB @@ -157,9 +173,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $multiple-iterations - (local $x anyref) - (local $y anyref) - (local $z anyref) + (local $x funcref) + (local $y funcref) + (local $z funcref) (local.set $x (ref.func $i32) ) @@ -191,9 +207,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $multiple-iterations-refinalize (param $i i32) - (local $x anyref) - (local $y anyref) - (local $z anyref) + (local $x funcref) + (local $y funcref) + (local $z funcref) (local.set $x (ref.func $i32) ) @@ -210,7 +226,7 @@ ) ;; CHECK: (func $nondefaultable - ;; CHECK-NEXT: (local $x (anyref anyref)) + ;; CHECK-NEXT: (local $x (funcref funcref)) ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (tuple.make ;; CHECK-NEXT: (ref.func $i32) @@ -219,7 +235,7 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $nondefaultable - (local $x (anyref anyref)) + (local $x (funcref funcref)) ;; This tuple is assigned non-nullable values, which means the subtype is ;; nondefaultable, and we must not apply it. (local.set $x @@ -243,10 +259,10 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $uses-default (param $i i32) - (local $x anyref) + (local $x funcref) (if (local.get $i) - ;; The only set to this local uses a more specific type than anyref. + ;; The only set to this local uses a more specific type than funcref. (local.set $x (ref.func $uses-default)) ) (drop @@ -373,9 +389,9 @@ (local.set $x (struct.new ${})) (local.set $x (ref.null data)) ;; Note that this func null is even of a type that is incompatible with the - ;; new lub (func vs data). Still, we can just update it along with the + ;; new lub (array vs struct). Still, we can just update it along with the ;; others. - (local.set $x (ref.null func)) + (local.set $x (ref.null $array)) ;; This null is equal to the LUB we'll find, and will not change. (local.set $x (ref.null ${})) ;; This null is more specific than the LUB we'll find, and will not change, diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast index 7a0eea294..e8db92523 100644 --- a/test/lit/passes/optimize-instructions-gc.wast +++ b/test/lit/passes/optimize-instructions-gc.wast @@ -63,22 +63,22 @@ ;; CHECK: (func $if-arms-subtype-nofold (result anyref) ;; CHECK-NEXT: (if (result anyref) ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (ref.null eq) - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null data) + ;; CHECK-NEXT: (ref.null i31) ;; 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 eq) - ;; NOMNL-NEXT: (ref.null func) + ;; NOMNL-NEXT: (ref.null data) + ;; NOMNL-NEXT: (ref.null i31) ;; NOMNL-NEXT: ) ;; NOMNL-NEXT: ) (func $if-arms-subtype-nofold (result anyref) (if (result anyref) (i32.const 0) - (ref.null eq) - (ref.null func) + (ref.null data) + (ref.null i31) ) ) diff --git a/test/lit/passes/remove-unused-brs-gc.wast b/test/lit/passes/remove-unused-brs-gc.wast index 666c941af..bdbf1bd07 100644 --- a/test/lit/passes/remove-unused-brs-gc.wast +++ b/test/lit/passes/remove-unused-brs-gc.wast @@ -11,7 +11,9 @@ ;; CHECK-NEXT: (block $any (result anyref) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (br $any - ;; CHECK-NEXT: (ref.func $br_on_non_data-1) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (ref.null any) @@ -22,9 +24,9 @@ (drop (block $any (result anyref) (drop - ;; A function is not data, and so we should branch. + ;; An i31 is not data, and so we should branch. (br_on_non_data $any - (ref.func $br_on_non_data-1) + (i31.new (i32.const 0)) ) ) (ref.null any) diff --git a/test/lit/passes/remove-unused-brs.wast b/test/lit/passes/remove-unused-brs.wast index fa25108f4..ddfbabe84 100644 --- a/test/lit/passes/remove-unused-brs.wast +++ b/test/lit/passes/remove-unused-brs.wast @@ -4,16 +4,11 @@ (module - ;; CHECK: (type $none_=>_i32 (func (result i32))) - (type $none_=>_i32 (func (result i32))) - ;; CHECK: (type $i32_=>_none (func (param i32))) - (type $i32_=>_none (func (param i32))) - ;; Regression test in which we need to calculate a proper LUB. ;; CHECK: (func $selectify-fresh-lub (param $x i32) (result anyref) - ;; CHECK-NEXT: (select (result funcref) - ;; CHECK-NEXT: (ref.null $none_=>_i32) - ;; CHECK-NEXT: (ref.null $i32_=>_none) + ;; CHECK-NEXT: (select (result eqref) + ;; CHECK-NEXT: (ref.null i31) + ;; CHECK-NEXT: (ref.null data) ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) @@ -21,10 +16,10 @@ (if (local.get $x) (return - (ref.null $none_=>_i32) + (ref.null i31) ) (return - (ref.null $i32_=>_none) + (ref.null data) ) ) ) diff --git a/test/lit/passes/signature-pruning.wast b/test/lit/passes/signature-pruning.wast index d58631ecb..319071e0f 100644 --- a/test/lit/passes/signature-pruning.wast +++ b/test/lit/passes/signature-pruning.wast @@ -747,8 +747,6 @@ ;; CHECK: (memory $0 1 1) - ;; CHECK: (elem declare func $foo) - ;; CHECK: (func $foo (type $sig-foo) ;; CHECK-NEXT: (local $0 anyref) ;; CHECK-NEXT: (local.set $0 @@ -765,7 +763,7 @@ (func $foo (type $sig-foo) (param $anyref anyref) (drop (local.get $anyref)) (call $foo (ref.null any)) - (call $foo (ref.null func)) + (call $foo (ref.null data)) ) ;; CHECK: (func $bar (type $sig-bar) (param $anyref anyref) @@ -773,17 +771,19 @@ ;; CHECK-NEXT: (local.get $anyref) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (ref.func $foo) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call $bar - ;; CHECK-NEXT: (ref.null func) + ;; CHECK-NEXT: (ref.null data) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $bar (type $sig-bar) (param $anyref anyref) (drop (local.get $anyref)) ;; Mixing a null with something else prevents optimization, of course. - (call $bar (ref.func $foo)) - (call $bar (ref.null func)) + (call $bar (i31.new (i32.const 0))) + (call $bar (ref.null data)) ) ) diff --git a/test/lit/passes/signature-refining.wast b/test/lit/passes/signature-refining.wast index c1ca742e5..67d076de7 100644 --- a/test/lit/passes/signature-refining.wast +++ b/test/lit/passes/signature-refining.wast @@ -203,8 +203,8 @@ ;; Define a field in the struct of the signature type that will be updated, ;; to check for proper validation after the update. - ;; CHECK: (type $sig (func_subtype (param (ref $struct)) func)) - (type $sig (func_subtype (param anyref) func)) + ;; CHECK: (type $sig (func_subtype (param (ref $struct) (ref $sig)) func)) + (type $sig (func_subtype (param anyref funcref) func)) ;; CHECK: (type $struct (struct_subtype (field (ref $sig)) data)) (type $struct (struct_subtype (field (ref $sig)) data)) @@ -213,33 +213,33 @@ ;; CHECK: (elem declare func $func) - ;; CHECK: (func $func (type $sig) (param $x (ref $struct)) + ;; CHECK: (func $func (type $sig) (param $x (ref $struct)) (param $f (ref $sig)) ;; CHECK-NEXT: (local $temp (ref null $sig)) - ;; CHECK-NEXT: (local $2 anyref) - ;; CHECK-NEXT: (local.set $2 - ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (local $3 funcref) + ;; CHECK-NEXT: (local.set $3 + ;; CHECK-NEXT: (local.get $f) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (block ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (local.get $2) + ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (local.set $2 + ;; CHECK-NEXT: (local.set $3 ;; CHECK-NEXT: (local.get $temp) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - (func $func (type $sig) (param $x anyref) + (func $func (type $sig) (param $x anyref) (param $f funcref) ;; Define a local of the signature type that is updated. (local $temp (ref null $sig)) ;; Do a local.get of the param, to verify its type is valid. (drop (local.get $x) ) - ;; Copy between the param and the local, to verify their types are still - ;; compatible after the update. Note that we will need to add a fixup local - ;; here, as $x's new type becomes too specific to be assigned the value - ;; here. - (local.set $x + ;; Copy from a funcref local to the formerly funcref param to verify their + ;; types are still compatible after the update. Note that we will need to + ;; add a fixup local here, as $f's new type becomes too specific to be + ;; assigned the value here. + (local.set $f (local.get $temp) ) ) @@ -249,6 +249,7 @@ ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (ref.func $func) ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (ref.func $func) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $caller @@ -256,6 +257,7 @@ (struct.new $struct (ref.func $func) ) + (ref.func $func) ) ) ) @@ -356,7 +358,7 @@ ;; CHECK: (type $sig-1 (func_subtype (param (ref null data) anyref) func)) (type $sig-1 (func_subtype (param anyref) (param anyref) func)) - ;; CHECK: (type $sig-2 (func_subtype (param anyref (ref $struct)) func)) + ;; CHECK: (type $sig-2 (func_subtype (param eqref (ref $struct)) func)) (type $sig-2 (func_subtype (param anyref) (param anyref) func)) ;; CHECK: (type $none_=>_none (func_subtype func)) @@ -369,7 +371,7 @@ (func $func-1 (type $sig-1) (param $x anyref) (param $y anyref) ) - ;; CHECK: (func $func-2 (type $sig-2) (param $x anyref) (param $y (ref $struct)) + ;; CHECK: (func $func-2 (type $sig-2) (param $x eqref) (param $y (ref $struct)) ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $func-2 (type $sig-2) (param $x anyref) (param $y anyref) @@ -378,7 +380,7 @@ ;; CHECK: (func $caller (type $none_=>_none) ;; CHECK-NEXT: (local $any anyref) ;; CHECK-NEXT: (local $data (ref null data)) - ;; CHECK-NEXT: (local $func funcref) + ;; CHECK-NEXT: (local $i31 (ref null i31)) ;; CHECK-NEXT: (call $func-1 ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: (local.get $data) @@ -392,7 +394,7 @@ ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (call_ref - ;; CHECK-NEXT: (local.get $func) + ;; CHECK-NEXT: (local.get $i31) ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: (ref.func $func-2) ;; CHECK-NEXT: ) @@ -400,7 +402,7 @@ (func $caller (local $any (ref null any)) (local $data (ref null data)) - (local $func (ref null func)) + (local $i31 (ref null i31)) (call $func-1 (struct.new $struct) @@ -415,7 +417,7 @@ (struct.new $struct) ) (call_ref - (local.get $func) + (local.get $i31) (struct.new $struct) (ref.func $func-2) ) diff --git a/test/lit/passes/type-refining.wast b/test/lit/passes/type-refining.wast index f2a44e79d..ce305e8cc 100644 --- a/test/lit/passes/type-refining.wast +++ b/test/lit/passes/type-refining.wast @@ -5,13 +5,11 @@ ;; A struct with three fields. The first will have no writes, the second one ;; write of the same type, and the last a write of a subtype, which will allow ;; us to specialize that one. - ;; CHECK: (type $struct (struct_subtype (field (mut anyref)) (field (mut anyref)) (field (mut (ref $ref|$struct|_=>_none))) data)) + ;; CHECK: (type $struct (struct_subtype (field (mut anyref)) (field (mut anyref)) (field (mut i31ref)) data)) (type $struct (struct_subtype (field (mut anyref)) (field (mut anyref)) (field (mut anyref)) data)) ;; CHECK: (type $ref|$struct|_=>_none (func_subtype (param (ref $struct)) func)) - ;; CHECK: (elem declare func $work) - ;; CHECK: (func $work (type $ref|$struct|_=>_none) (param $struct (ref $struct)) ;; CHECK-NEXT: (struct.set $struct 1 ;; CHECK-NEXT: (local.get $struct) @@ -19,7 +17,9 @@ ;; CHECK-NEXT: ) ;; CHECK-NEXT: (struct.set $struct 2 ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (ref.func $work) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.get $struct 2 @@ -34,7 +34,7 @@ ) (struct.set $struct 2 (local.get $struct) - (ref.func $work) + (i31.new (i32.const 0)) ) (drop ;; The type of this struct.get must be updated after the field's type @@ -51,20 +51,20 @@ ;; must keep the type nullable, unlike in the previous module, due to the ;; default value being null. - ;; CHECK: (type $struct (struct_subtype (field (mut (ref null $ref|$struct|_=>_none))) data)) + ;; CHECK: (type $struct (struct_subtype (field (mut (ref null i31))) data)) (type $struct (struct_subtype (field (mut anyref)) data)) ;; CHECK: (type $ref|$struct|_=>_none (func_subtype (param (ref $struct)) func)) - ;; CHECK: (elem declare func $work) - ;; CHECK: (func $work (type $ref|$struct|_=>_none) (param $struct (ref $struct)) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (struct.new_default $struct) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (struct.set $struct 0 ;; CHECK-NEXT: (local.get $struct) - ;; CHECK-NEXT: (ref.func $work) + ;; CHECK-NEXT: (i31.new + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $work (param $struct (ref $struct)) @@ -73,7 +73,7 @@ ) (struct.set $struct 0 (local.get $struct) - (ref.func $work) + (i31.new (i32.const 0)) ) ) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index c8ad3700a..a07e7e3d7 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -203,14 +203,16 @@ (local $x anyref) ;; set x to something that is not null, but also not data (local.set $x - (ref.func $a-void-func) + (i31.new + (i32.const 0) + ) ) (drop (block $any (result anyref) (drop (br_on_non_data $any (local.get $x)) ) - ;; $x refers to a function, so we will branch, and not log + ;; $x refers to an i31, so we will branch, and not log (call $log (i32.const 1)) (ref.null any) ) @@ -219,8 +221,8 @@ (func "br-on_non_null" (drop (block $non-null (result (ref any)) - (br_on_non_null $non-null (ref.func $a-void-func)) - ;; $x refers to a function, which is not null, so we will branch, and not + (br_on_non_null $non-null (i31.new (i32.const 0))) + ;; $x refers to an i31, which is not null, so we will branch, and not ;; log (call $log (i32.const 1)) (unreachable) diff --git a/test/passes/merge-locals_all-features.txt b/test/passes/merge-locals_all-features.txt index ebb9407fc..8be43b60d 100644 --- a/test/passes/merge-locals_all-features.txt +++ b/test/passes/merge-locals_all-features.txt @@ -459,8 +459,8 @@ ) (func $subtype-test (local $0 anyref) - (local $1 funcref) - (local $2 funcref) + (local $1 (ref null i31)) + (local $2 (ref null i31)) (local.set $0 (local.get $1) ) diff --git a/test/passes/merge-locals_all-features.wast b/test/passes/merge-locals_all-features.wast index 1cdac26ec..1b73c9a95 100644 --- a/test/passes/merge-locals_all-features.wast +++ b/test/passes/merge-locals_all-features.wast @@ -377,8 +377,8 @@ ) (func $subtype-test (local $0 anyref) - (local $1 funcref) - (local $2 funcref) + (local $1 (ref null i31)) + (local $2 (ref null i31)) (local.set $0 (local.get $1) ) diff --git a/test/passes/simplify-locals_all-features_disable-exception-handling.txt b/test/passes/simplify-locals_all-features_disable-exception-handling.txt index 5a4dff21a..f206cc42e 100644 --- a/test/passes/simplify-locals_all-features_disable-exception-handling.txt +++ b/test/passes/simplify-locals_all-features_disable-exception-handling.txt @@ -1866,7 +1866,7 @@ (module (type $none_=>_anyref (func (result anyref))) (func $subtype-test (result anyref) - (local $0 funcref) + (local $0 (ref null i31)) (local $1 anyref) (local $2 anyref) (block diff --git a/test/passes/simplify-locals_all-features_disable-exception-handling.wast b/test/passes/simplify-locals_all-features_disable-exception-handling.wast index 803d557f6..25b452511 100644 --- a/test/passes/simplify-locals_all-features_disable-exception-handling.wast +++ b/test/passes/simplify-locals_all-features_disable-exception-handling.wast @@ -1657,7 +1657,7 @@ ) (module (func $subtype-test (result anyref) - (local $0 funcref) + (local $0 (ref null i31)) (local $1 anyref) (local $2 anyref) (block 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 5e4beae81..d81ea0ccd 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,40 +1,42 @@ total - [exports] : 9 - [funcs] : 13 + [exports] : 5 + [funcs] : 8 [globals] : 6 [imports] : 5 [memories] : 1 [memory-data] : 22 - [table-data] : 4 + [table-data] : 2 [tables] : 1 - [tags] : 0 - [total] : 669 - [vars] : 20 - ArrayInit : 3 - AtomicCmpxchg : 2 - Binary : 75 - Block : 81 - Break : 8 - Call : 44 + [tags] : 2 + [total] : 495 + [vars] : 23 + ArrayInit : 2 + AtomicNotify : 1 + Binary : 64 + Block : 52 + Break : 7 + Call : 28 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 + Const : 126 + Drop : 3 + GlobalGet : 25 + GlobalSet : 12 + I31Get : 1 + I31New : 11 + If : 19 + Load : 22 + LocalGet : 33 + LocalSet : 20 + Loop : 4 + Nop : 5 + RefFunc : 3 RefNull : 4 - Return : 27 - Select : 1 + Return : 17 + SIMDExtract : 3 + Select : 3 Store : 1 - StructNew : 7 + StructNew : 1 TupleExtract : 1 - TupleMake : 6 - Unary : 35 + TupleMake : 11 + Unary : 13 + Unreachable : 2 diff --git a/test/reference-types.wast b/test/reference-types.wast index a7f84a93c..64f6e24b7 100644 --- a/test/reference-types.wast +++ b/test/reference-types.wast @@ -24,8 +24,6 @@ ;; Test subtype relationship in global initializer expressions (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)) @@ -50,10 +48,6 @@ (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_eqref (global.get $global_eqref)) @@ -71,10 +65,6 @@ (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_eqref (local.get $local_eqref)) @@ -92,10 +82,6 @@ (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_eqref) (local.get $local_eqref) (i32.const 0)) @@ -113,10 +99,6 @@ (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)) - (call_indirect (type $sig_anyref) (ref.func $foo) (i32.const 3)) ;; Test block return type (drop @@ -178,24 +160,9 @@ ) (drop (block (result anyref) - (br_if 0 (local.get $local_funcref) (i32.const 1)) - ) - ) - (drop - (block (result anyref) (br_if 0 (ref.null eq) (i32.const 1)) ) ) - (drop - (block (result anyref) - (br_if 0 (ref.null func) (i32.const 1)) - ) - ) - (drop - (block (result anyref) - (br_if 0 (ref.func $foo) (i32.const 1)) - ) - ) ;; Test loop return type (drop @@ -265,26 +232,6 @@ (ref.null eq) ) ) - (drop - (loop (result anyref) - (local.get $local_funcref) - ) - ) - (drop - (loop (result anyref) - (global.get $global_funcref) - ) - ) - (drop - (loop (result anyref) - (ref.null func) - ) - ) - (drop - (loop (result anyref) - (ref.func $foo) - ) - ) ;; Test if return type (drop @@ -314,20 +261,22 @@ (if (result anyref) (i32.const 1) (local.get $local_eqref) - (local.get $local_funcref) + (local.get $local_eqref) ) ) (drop (if (result anyref) (i32.const 1) (ref.null eq) - (ref.null func) + (ref.null i31) ) ) (drop (if (result anyref) (i32.const 1) - (ref.func $foo) + (i31.new + (i32.const 0) + ) (ref.null eq) ) ) @@ -364,14 +313,14 @@ ) (catch $e-i32 (drop (pop i32)) - (ref.func $foo) + (ref.null any) ) ) ) (drop (try (result anyref) (do - (ref.func $foo) + (ref.null eq) ) (catch $e-i32 (drop (pop i32)) @@ -407,14 +356,9 @@ (drop (select (result anyref) (local.get $local_eqref) - (local.get $local_funcref) - (i32.const 1) - ) - ) - (drop - (select (result anyref) - (local.get $local_funcref) - (local.get $local_eqref) + (i31.new + (i32.const 0) + ) (i32.const 1) ) ) @@ -478,19 +422,6 @@ (func $return_anyref4 (result anyref) (ref.null eq) ) - (func $return_anyref5 (result anyref) - (local $local_funcref funcref) - (local.get $local_funcref) - ) - (func $return_anyref6 (result anyref) - (global.get $global_funcref) - ) - (func $return_anyref7 (result anyref) - (ref.null func) - ) - (func $return_anyref8 (result anyref) - (ref.func $foo) - ) ;; Test returns (func $returns_eqref (result eqref) @@ -520,10 +451,6 @@ (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)) - (return (ref.null func)) ) (func $ref-user diff --git a/test/reference-types.wast.from-wast b/test/reference-types.wast.from-wast index 47f1b9893..121f3c6f4 100644 --- a/test/reference-types.wast.from-wast +++ b/test/reference-types.wast.from-wast @@ -15,8 +15,6 @@ (global $global_funcref_func (mut funcref) (ref.func $foo)) (global $global_anyref (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_eqref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) @@ -78,18 +76,6 @@ (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) - ) (global.set $global_eqref (global.get $global_eqref) ) @@ -129,18 +115,6 @@ (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) - ) (call $take_eqref (local.get $local_eqref) ) @@ -180,18 +154,6 @@ (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) - ) (call_indirect $0 (type $sig_eqref) (local.get $local_eqref) (i32.const 0) @@ -244,22 +206,6 @@ (ref.null eq) (i32.const 3) ) - (call_indirect $0 (type $sig_anyref) - (local.get $local_funcref) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (global.get $global_funcref) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (ref.null func) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (ref.func $foo) - (i32.const 3) - ) (drop (block $block (result eqref) (br_if $block @@ -351,121 +297,77 @@ (drop (block $block10 (result anyref) (br_if $block10 - (local.get $local_funcref) - (i32.const 1) - ) - ) - ) - (drop - (block $block11 (result anyref) - (br_if $block11 (ref.null eq) (i32.const 1) ) ) ) (drop - (block $block12 (result anyref) - (br_if $block12 - (ref.null func) - (i32.const 1) - ) - ) - ) - (drop - (block $block13 (result anyref) - (br_if $block13 - (ref.func $foo) - (i32.const 1) - ) - ) - ) - (drop (loop $loop-in (result eqref) (local.get $local_eqref) ) ) (drop - (loop $loop-in14 (result eqref) + (loop $loop-in11 (result eqref) (global.get $global_eqref) ) ) (drop - (loop $loop-in15 (result eqref) + (loop $loop-in12 (result eqref) (ref.null eq) ) ) (drop - (loop $loop-in16 (result funcref) + (loop $loop-in13 (result funcref) (local.get $local_funcref) ) ) (drop - (loop $loop-in17 (result funcref) + (loop $loop-in14 (result funcref) (global.get $global_funcref) ) ) (drop - (loop $loop-in18 (result funcref) + (loop $loop-in15 (result funcref) (ref.null func) ) ) (drop - (loop $loop-in19 (result funcref) + (loop $loop-in16 (result funcref) (ref.func $foo) ) ) (drop - (loop $loop-in20 (result anyref) + (loop $loop-in17 (result anyref) (local.get $local_anyref) ) ) (drop - (loop $loop-in21 (result anyref) + (loop $loop-in18 (result anyref) (global.get $global_anyref) ) ) (drop - (loop $loop-in22 (result anyref) + (loop $loop-in19 (result anyref) (ref.null any) ) ) (drop - (loop $loop-in23 (result anyref) + (loop $loop-in20 (result anyref) (local.get $local_eqref) ) ) (drop - (loop $loop-in24 (result anyref) + (loop $loop-in21 (result anyref) (global.get $global_eqref) ) ) (drop - (loop $loop-in25 (result anyref) + (loop $loop-in22 (result anyref) (ref.null eq) ) ) (drop - (loop $loop-in26 (result anyref) - (local.get $local_funcref) - ) - ) - (drop - (loop $loop-in27 (result anyref) - (global.get $global_funcref) - ) - ) - (drop - (loop $loop-in28 (result anyref) - (ref.null func) - ) - ) - (drop - (loop $loop-in29 (result anyref) - (ref.func $foo) - ) - ) - (drop (if (result eqref) (i32.const 1) (local.get $local_eqref) @@ -490,20 +392,22 @@ (if (result anyref) (i32.const 1) (local.get $local_eqref) - (local.get $local_funcref) + (local.get $local_eqref) ) ) (drop (if (result anyref) (i32.const 1) (ref.null eq) - (ref.null func) + (ref.null i31) ) ) (drop (if (result anyref) (i32.const 1) - (ref.func $foo) + (i31.new + (i32.const 0) + ) (ref.null eq) ) ) @@ -521,7 +425,7 @@ ) ) (drop - (try $try35 (result funcref) + (try $try28 (result funcref) (do (ref.func $foo) ) @@ -534,7 +438,7 @@ ) ) (drop - (try $try36 (result anyref) + (try $try29 (result anyref) (do (local.get $local_eqref) ) @@ -542,14 +446,14 @@ (drop (pop i32) ) - (ref.func $foo) + (ref.null any) ) ) ) (drop - (try $try37 (result anyref) + (try $try30 (result anyref) (do - (ref.func $foo) + (ref.null eq) ) (catch $e-i32 (drop @@ -583,14 +487,9 @@ (drop (select (result anyref) (local.get $local_eqref) - (local.get $local_funcref) - (i32.const 1) - ) - ) - (drop - (select (result anyref) - (local.get $local_funcref) - (local.get $local_eqref) + (i31.new + (i32.const 0) + ) (i32.const 1) ) ) @@ -688,19 +587,6 @@ (func $return_anyref4 (result anyref) (ref.null eq) ) - (func $return_anyref5 (result anyref) - (local $local_funcref funcref) - (local.get $local_funcref) - ) - (func $return_anyref6 (result anyref) - (global.get $global_funcref) - ) - (func $return_anyref7 (result anyref) - (ref.null func) - ) - (func $return_anyref8 (result anyref) - (ref.func $foo) - ) (func $returns_eqref (result eqref) (local $local_eqref eqref) (return @@ -752,18 +638,6 @@ (return (ref.null eq) ) - (return - (local.get $local_funcref) - ) - (return - (global.get $global_funcref) - ) - (return - (ref.func $foo) - ) - (return - (ref.null func) - ) ) (func $ref-user (drop diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary index 68ed3e63d..01523cab8 100644 --- a/test/reference-types.wast.fromBinary +++ b/test/reference-types.wast.fromBinary @@ -15,8 +15,6 @@ (global $global_funcref_func (mut funcref) (ref.func $foo)) (global $global_anyref (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_eqref $take_funcref $take_anyref) (elem declare func $foo $ref-taken-but-not-in-table) @@ -78,18 +76,6 @@ (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) - ) (global.set $global_eqref (global.get $global_eqref) ) @@ -129,18 +115,6 @@ (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) - ) (call $take_eqref (local.get $local_eqref) ) @@ -180,18 +154,6 @@ (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) - ) (call_indirect $0 (type $sig_eqref) (local.get $local_eqref) (i32.const 0) @@ -244,22 +206,6 @@ (ref.null eq) (i32.const 3) ) - (call_indirect $0 (type $sig_anyref) - (local.get $local_funcref) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (global.get $global_funcref) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (ref.null func) - (i32.const 3) - ) - (call_indirect $0 (type $sig_anyref) - (ref.func $foo) - (i32.const 3) - ) (drop (block $label$1 (result eqref) (br_if $label$1 @@ -351,121 +297,77 @@ (drop (block $label$12 (result anyref) (br_if $label$12 - (local.get $local_funcref) - (i32.const 1) - ) - ) - ) - (drop - (block $label$13 (result anyref) - (br_if $label$13 (ref.null eq) (i32.const 1) ) ) ) (drop - (block $label$14 (result anyref) - (br_if $label$14 - (ref.null func) - (i32.const 1) - ) - ) - ) - (drop - (block $label$15 (result anyref) - (br_if $label$15 - (ref.func $foo) - (i32.const 1) - ) - ) - ) - (drop - (loop $label$16 (result eqref) + (loop $label$13 (result eqref) (local.get $local_eqref) ) ) (drop - (loop $label$17 (result eqref) + (loop $label$14 (result eqref) (global.get $global_eqref) ) ) (drop - (loop $label$18 (result eqref) + (loop $label$15 (result eqref) (ref.null eq) ) ) (drop - (loop $label$19 (result funcref) + (loop $label$16 (result funcref) (local.get $local_funcref) ) ) (drop - (loop $label$20 (result funcref) + (loop $label$17 (result funcref) (global.get $global_funcref) ) ) (drop - (loop $label$21 (result funcref) + (loop $label$18 (result funcref) (ref.null func) ) ) (drop - (loop $label$22 (result funcref) + (loop $label$19 (result funcref) (ref.func $foo) ) ) (drop - (loop $label$23 (result anyref) + (loop $label$20 (result anyref) (local.get $local_anyref) ) ) (drop - (loop $label$24 (result anyref) + (loop $label$21 (result anyref) (global.get $global_anyref) ) ) (drop - (loop $label$25 (result anyref) + (loop $label$22 (result anyref) (ref.null any) ) ) (drop - (loop $label$26 (result anyref) + (loop $label$23 (result anyref) (local.get $local_eqref) ) ) (drop - (loop $label$27 (result anyref) + (loop $label$24 (result anyref) (global.get $global_eqref) ) ) (drop - (loop $label$28 (result anyref) + (loop $label$25 (result anyref) (ref.null eq) ) ) (drop - (loop $label$29 (result anyref) - (local.get $local_funcref) - ) - ) - (drop - (loop $label$30 (result anyref) - (global.get $global_funcref) - ) - ) - (drop - (loop $label$31 (result anyref) - (ref.null func) - ) - ) - (drop - (loop $label$32 (result anyref) - (ref.func $foo) - ) - ) - (drop (if (result eqref) (i32.const 1) (local.get $local_eqref) @@ -490,25 +392,27 @@ (if (result anyref) (i32.const 1) (local.get $local_eqref) - (local.get $local_funcref) + (local.get $local_eqref) ) ) (drop (if (result anyref) (i32.const 1) (ref.null eq) - (ref.null func) + (ref.null i31) ) ) (drop (if (result anyref) (i32.const 1) - (ref.func $foo) + (i31.new + (i32.const 0) + ) (ref.null eq) ) ) (drop - (try $label$47 (result eqref) + (try $label$40 (result eqref) (do (local.get $local_eqref) ) @@ -521,7 +425,7 @@ ) ) (drop - (try $label$50 (result funcref) + (try $label$43 (result funcref) (do (ref.func $foo) ) @@ -534,7 +438,7 @@ ) ) (drop - (try $label$53 (result anyref) + (try $label$46 (result anyref) (do (local.get $local_eqref) ) @@ -542,14 +446,14 @@ (drop (pop i32) ) - (ref.func $foo) + (ref.null any) ) ) ) (drop - (try $label$56 (result anyref) + (try $label$49 (result anyref) (do - (ref.func $foo) + (ref.null eq) ) (catch $tag$0 (drop @@ -583,14 +487,9 @@ (drop (select (result anyref) (local.get $local_eqref) - (local.get $local_funcref) - (i32.const 1) - ) - ) - (drop - (select (result anyref) - (local.get $local_funcref) - (local.get $local_eqref) + (i31.new + (i32.const 0) + ) (i32.const 1) ) ) @@ -688,19 +587,6 @@ (func $return_anyref4 (result anyref) (ref.null eq) ) - (func $return_anyref5 (result anyref) - (local $local_funcref funcref) - (local.get $local_funcref) - ) - (func $return_anyref6 (result anyref) - (global.get $global_funcref) - ) - (func $return_anyref7 (result anyref) - (ref.null func) - ) - (func $return_anyref8 (result anyref) - (ref.func $foo) - ) (func $returns_eqref (result eqref) (local $local_eqref eqref) (return diff --git a/test/reference-types.wast.fromBinary.noDebugInfo b/test/reference-types.wast.fromBinary.noDebugInfo index 5caa085c9..cc05523b2 100644 --- a/test/reference-types.wast.fromBinary.noDebugInfo +++ b/test/reference-types.wast.fromBinary.noDebugInfo @@ -15,11 +15,9 @@ (global $global$2 (mut funcref) (ref.func $3)) (global $global$3 (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) (elem (i32.const 0) $0 $1 $2) - (elem declare func $27 $3) + (elem declare func $23 $3) (tag $tag$0 (param i32)) (export "export_func" (func $fimport$0)) (export "export_global" (global $gimport$0)) @@ -78,18 +76,6 @@ (local.set $2 (ref.null eq) ) - (local.set $2 - (local.get $1) - ) - (local.set $2 - (global.get $global$1) - ) - (local.set $2 - (ref.null func) - ) - (local.set $2 - (ref.func $3) - ) (global.set $global$0 (global.get $global$0) ) @@ -129,18 +115,6 @@ (global.set $global$3 (ref.null eq) ) - (global.set $global$3 - (global.get $global$1) - ) - (global.set $global$3 - (local.get $1) - ) - (global.set $global$3 - (ref.null func) - ) - (global.set $global$3 - (ref.func $3) - ) (call $0 (local.get $0) ) @@ -180,18 +154,6 @@ (call $2 (ref.null eq) ) - (call $2 - (local.get $1) - ) - (call $2 - (global.get $global$1) - ) - (call $2 - (ref.null func) - ) - (call $2 - (ref.func $3) - ) (call_indirect $0 (type $eqref_=>_none) (local.get $0) (i32.const 0) @@ -244,22 +206,6 @@ (ref.null eq) (i32.const 3) ) - (call_indirect $0 (type $anyref_=>_none) - (local.get $1) - (i32.const 3) - ) - (call_indirect $0 (type $anyref_=>_none) - (global.get $global$1) - (i32.const 3) - ) - (call_indirect $0 (type $anyref_=>_none) - (ref.null func) - (i32.const 3) - ) - (call_indirect $0 (type $anyref_=>_none) - (ref.func $3) - (i32.const 3) - ) (drop (block $label$1 (result eqref) (br_if $label$1 @@ -351,121 +297,77 @@ (drop (block $label$12 (result anyref) (br_if $label$12 - (local.get $1) - (i32.const 1) - ) - ) - ) - (drop - (block $label$13 (result anyref) - (br_if $label$13 (ref.null eq) (i32.const 1) ) ) ) (drop - (block $label$14 (result anyref) - (br_if $label$14 - (ref.null func) - (i32.const 1) - ) - ) - ) - (drop - (block $label$15 (result anyref) - (br_if $label$15 - (ref.func $3) - (i32.const 1) - ) - ) - ) - (drop - (loop $label$16 (result eqref) + (loop $label$13 (result eqref) (local.get $0) ) ) (drop - (loop $label$17 (result eqref) + (loop $label$14 (result eqref) (global.get $global$0) ) ) (drop - (loop $label$18 (result eqref) + (loop $label$15 (result eqref) (ref.null eq) ) ) (drop - (loop $label$19 (result funcref) + (loop $label$16 (result funcref) (local.get $1) ) ) (drop - (loop $label$20 (result funcref) + (loop $label$17 (result funcref) (global.get $global$1) ) ) (drop - (loop $label$21 (result funcref) + (loop $label$18 (result funcref) (ref.null func) ) ) (drop - (loop $label$22 (result funcref) + (loop $label$19 (result funcref) (ref.func $3) ) ) (drop - (loop $label$23 (result anyref) + (loop $label$20 (result anyref) (local.get $2) ) ) (drop - (loop $label$24 (result anyref) + (loop $label$21 (result anyref) (global.get $global$3) ) ) (drop - (loop $label$25 (result anyref) + (loop $label$22 (result anyref) (ref.null any) ) ) (drop - (loop $label$26 (result anyref) + (loop $label$23 (result anyref) (local.get $0) ) ) (drop - (loop $label$27 (result anyref) + (loop $label$24 (result anyref) (global.get $global$0) ) ) (drop - (loop $label$28 (result anyref) + (loop $label$25 (result anyref) (ref.null eq) ) ) (drop - (loop $label$29 (result anyref) - (local.get $1) - ) - ) - (drop - (loop $label$30 (result anyref) - (global.get $global$1) - ) - ) - (drop - (loop $label$31 (result anyref) - (ref.null func) - ) - ) - (drop - (loop $label$32 (result anyref) - (ref.func $3) - ) - ) - (drop (if (result eqref) (i32.const 1) (local.get $0) @@ -490,25 +392,27 @@ (if (result anyref) (i32.const 1) (local.get $0) - (local.get $1) + (local.get $0) ) ) (drop (if (result anyref) (i32.const 1) (ref.null eq) - (ref.null func) + (ref.null i31) ) ) (drop (if (result anyref) (i32.const 1) - (ref.func $3) + (i31.new + (i32.const 0) + ) (ref.null eq) ) ) (drop - (try $label$47 (result eqref) + (try $label$40 (result eqref) (do (local.get $0) ) @@ -521,7 +425,7 @@ ) ) (drop - (try $label$50 (result funcref) + (try $label$43 (result funcref) (do (ref.func $3) ) @@ -534,7 +438,7 @@ ) ) (drop - (try $label$53 (result anyref) + (try $label$46 (result anyref) (do (local.get $0) ) @@ -542,14 +446,14 @@ (drop (pop i32) ) - (ref.func $3) + (ref.null any) ) ) ) (drop - (try $label$56 (result anyref) + (try $label$49 (result anyref) (do - (ref.func $3) + (ref.null eq) ) (catch $tag$0 (drop @@ -583,14 +487,9 @@ (drop (select (result anyref) (local.get $0) - (local.get $1) - (i32.const 1) - ) - ) - (drop - (select (result anyref) - (local.get $1) - (local.get $0) + (i31.new + (i32.const 0) + ) (i32.const 1) ) ) @@ -688,50 +587,37 @@ (func $17 (result anyref) (ref.null eq) ) - (func $18 (result anyref) - (local $0 funcref) - (local.get $0) - ) - (func $19 (result anyref) - (global.get $global$1) - ) - (func $20 (result anyref) - (ref.null func) - ) - (func $21 (result anyref) - (ref.func $3) - ) - (func $22 (result eqref) + (func $18 (result eqref) (local $0 eqref) (return (local.get $0) ) ) - (func $23 (result funcref) + (func $19 (result funcref) (local $0 funcref) (return (local.get $0) ) ) - (func $24 (result anyref) + (func $20 (result anyref) (local $0 anyref) (return (local.get $0) ) ) - (func $25 (result anyref) + (func $21 (result anyref) (local $0 eqref) (local $1 funcref) (return (local.get $0) ) ) - (func $26 + (func $22 (drop - (ref.func $27) + (ref.func $23) ) ) - (func $27 + (func $23 (nop) ) ) |