summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/example/c-api-kitchen-sink.txt20
-rw-r--r--test/gtest/lattices.cpp10
-rw-r--r--test/gtest/type-builder.cpp209
-rw-r--r--test/lit/basic/shared-types.wast42
-rw-r--r--test/lit/basic/typed_continuations.wast8
-rw-r--r--test/lit/passes/type-merging-shared.wast22
-rw-r--r--test/lit/wat-kitchen-sink.wast32
7 files changed, 301 insertions, 42 deletions
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index d79b34e66..5ba35fb0e 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -21,16 +21,16 @@ BinaryenPackedTypeNotPacked: 0
BinaryenPackedTypeInt8: 1
BinaryenPackedTypeInt16: 2
BinaryenHeapTypeExt: 0
-BinaryenHeapTypeFunc: 1
-BinaryenHeapTypeAny: 3
-BinaryenHeapTypeEq: 4
-BinaryenHeapTypeI31: 5
-BinaryenHeapTypeStruct: 6
-BinaryenHeapTypeArray: 7
-BinaryenHeapTypeString: 9
-BinaryenHeapTypeNone: 10
-BinaryenHeapTypeNoext: 11
-BinaryenHeapTypeNofunc: 12
+BinaryenHeapTypeFunc: 2
+BinaryenHeapTypeAny: 6
+BinaryenHeapTypeEq: 8
+BinaryenHeapTypeI31: 10
+BinaryenHeapTypeStruct: 12
+BinaryenHeapTypeArray: 14
+BinaryenHeapTypeString: 18
+BinaryenHeapTypeNone: 20
+BinaryenHeapTypeNoext: 22
+BinaryenHeapTypeNofunc: 24
BinaryenFeatureMVP: 0
BinaryenFeatureAtomics: 1
BinaryenFeatureBulkMemory: 16
diff --git a/test/gtest/lattices.cpp b/test/gtest/lattices.cpp
index 905f03420..7fff8d0c0 100644
--- a/test/gtest/lattices.cpp
+++ b/test/gtest/lattices.cpp
@@ -574,12 +574,12 @@ TEST(ValTypeLattice, Meet) {
}
TEST(SharedLattice, GetBottom) {
- analysis::Shared<analysis::UInt32> shared{analysis::UInt32{}};
+ analysis::SharedPath<analysis::UInt32> shared{analysis::UInt32{}};
EXPECT_EQ(*shared.getBottom(), 0u);
}
TEST(SharedLattice, Compare) {
- analysis::Shared<analysis::UInt32> shared{analysis::UInt32{}};
+ analysis::SharedPath<analysis::UInt32> shared{analysis::UInt32{}};
auto zero = shared.getBottom();
@@ -615,7 +615,7 @@ TEST(SharedLattice, Compare) {
}
TEST(SharedLattice, Join) {
- analysis::Shared<analysis::UInt32> shared{analysis::UInt32{}};
+ analysis::SharedPath<analysis::UInt32> shared{analysis::UInt32{}};
auto zero = shared.getBottom();
@@ -682,7 +682,7 @@ TEST(SharedLattice, Join) {
TEST(SharedLattice, JoinVecSingleton) {
using Vec = analysis::Vector<analysis::Bool>;
- analysis::Shared<Vec> shared{analysis::Vector{analysis::Bool{}, 2}};
+ analysis::SharedPath<Vec> shared{analysis::Vector{analysis::Bool{}, 2}};
auto elem = shared.getBottom();
EXPECT_TRUE(shared.join(elem, Vec::SingletonElement(1, true)));
@@ -691,7 +691,7 @@ TEST(SharedLattice, JoinVecSingleton) {
TEST(SharedLattice, JoinInvertedVecSingleton) {
using Vec = analysis::Vector<analysis::Bool>;
- analysis::Shared<analysis::Inverted<Vec>> shared{
+ analysis::SharedPath<analysis::Inverted<Vec>> shared{
analysis::Inverted{analysis::Vector{analysis::Bool{}, 2}}};
auto elem = shared.getBottom();
diff --git a/test/gtest/type-builder.cpp b/test/gtest/type-builder.cpp
index b72b78c9e..2ad43d189 100644
--- a/test/gtest/type-builder.cpp
+++ b/test/gtest/type-builder.cpp
@@ -277,8 +277,8 @@ TEST_F(TypeTest, InvalidSharedSupertype) {
TypeBuilder builder(2);
builder[0] = Struct{};
builder[1] = Struct{};
- builder[0].setShared(true);
- builder[1].setShared(false);
+ builder[0].setShared();
+ builder[1].setShared();
builder[1].subTypeOf(builder[0]);
auto result = builder.build();
@@ -294,8 +294,8 @@ TEST_F(TypeTest, InvalidUnsharedSupertype) {
TypeBuilder builder(2);
builder[0] = Struct{};
builder[1] = Struct{};
- builder[0].setShared(false);
- builder[1].setShared(true);
+ builder[0].setShared(Unshared);
+ builder[1].setShared(Shared);
builder[1].subTypeOf(builder[0]);
auto result = builder.build();
@@ -570,6 +570,27 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
HeapType defCont = Continuation(defFunc);
HeapType defStruct = Struct();
HeapType defArray = Array(Field(Type::i32, Immutable));
+ HeapType sharedAny = any.getBasic(Shared);
+ HeapType sharedEq = eq.getBasic(Shared);
+ HeapType sharedI31 = i31.getBasic(Shared);
+ HeapType sharedStruct = struct_.getBasic(Shared);
+ HeapType sharedNone = none.getBasic(Shared);
+ HeapType sharedFunc = func.getBasic(Shared);
+
+ HeapType sharedDefStruct;
+ HeapType sharedDefFunc;
+ {
+ TypeBuilder builder(2);
+ builder[0] = Struct{};
+ builder[1] = Signature();
+ builder[0].setShared();
+ builder[1].setShared();
+ auto results = builder.build();
+ ASSERT_TRUE(results);
+ auto built = *results;
+ sharedDefStruct = built[0];
+ sharedDefFunc = built[1];
+ }
auto assertLUB = [](HeapType a, HeapType b, std::optional<HeapType> lub) {
auto lub1 = HeapType::getLeastUpperBound(a, b);
@@ -620,6 +641,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(ext, defFunc, {});
assertLUB(ext, defStruct, {});
assertLUB(ext, defArray, {});
+ assertLUB(ext, sharedAny, {});
+ assertLUB(ext, sharedEq, {});
+ assertLUB(ext, sharedI31, {});
+ assertLUB(ext, sharedStruct, {});
+ assertLUB(ext, sharedNone, {});
+ assertLUB(ext, sharedFunc, {});
+ assertLUB(ext, sharedDefStruct, {});
+ assertLUB(ext, sharedDefFunc, {});
assertLUB(func, func, func);
assertLUB(func, cont, {});
@@ -637,6 +666,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(func, defCont, {});
assertLUB(func, defStruct, {});
assertLUB(func, defArray, {});
+ assertLUB(func, sharedAny, {});
+ assertLUB(func, sharedEq, {});
+ assertLUB(func, sharedI31, {});
+ assertLUB(func, sharedStruct, {});
+ assertLUB(func, sharedNone, {});
+ assertLUB(func, sharedFunc, {});
+ assertLUB(func, sharedDefStruct, {});
+ assertLUB(func, sharedDefFunc, {});
assertLUB(cont, cont, cont);
assertLUB(cont, func, {});
@@ -654,6 +691,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(cont, defCont, cont);
assertLUB(cont, defStruct, {});
assertLUB(cont, defArray, {});
+ assertLUB(cont, sharedAny, {});
+ assertLUB(cont, sharedEq, {});
+ assertLUB(cont, sharedI31, {});
+ assertLUB(cont, sharedStruct, {});
+ assertLUB(cont, sharedNone, {});
+ assertLUB(cont, sharedFunc, {});
+ assertLUB(cont, sharedDefStruct, {});
+ assertLUB(cont, sharedDefFunc, {});
assertLUB(any, any, any);
assertLUB(any, cont, {});
@@ -670,6 +715,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(any, defCont, {});
assertLUB(any, defStruct, any);
assertLUB(any, defArray, any);
+ assertLUB(any, sharedAny, {});
+ assertLUB(any, sharedEq, {});
+ assertLUB(any, sharedI31, {});
+ assertLUB(any, sharedStruct, {});
+ assertLUB(any, sharedNone, {});
+ assertLUB(any, sharedFunc, {});
+ assertLUB(any, sharedDefStruct, {});
+ assertLUB(any, sharedDefFunc, {});
assertLUB(eq, eq, eq);
assertLUB(eq, cont, {});
@@ -685,6 +738,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(eq, defCont, {});
assertLUB(eq, defStruct, eq);
assertLUB(eq, defArray, eq);
+ assertLUB(eq, sharedAny, {});
+ assertLUB(eq, sharedEq, {});
+ assertLUB(eq, sharedI31, {});
+ assertLUB(eq, sharedStruct, {});
+ assertLUB(eq, sharedNone, {});
+ assertLUB(eq, sharedFunc, {});
+ assertLUB(eq, sharedDefStruct, {});
+ assertLUB(eq, sharedDefFunc, {});
assertLUB(i31, i31, i31);
assertLUB(i31, cont, {});
@@ -699,6 +760,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(i31, defCont, {});
assertLUB(i31, defStruct, eq);
assertLUB(i31, defArray, eq);
+ assertLUB(i31, sharedAny, {});
+ assertLUB(i31, sharedEq, {});
+ assertLUB(i31, sharedI31, {});
+ assertLUB(i31, sharedStruct, {});
+ assertLUB(i31, sharedNone, {});
+ assertLUB(i31, sharedFunc, {});
+ assertLUB(i31, sharedDefStruct, {});
+ assertLUB(i31, sharedDefFunc, {});
assertLUB(struct_, struct_, struct_);
assertLUB(struct_, cont, {});
@@ -712,6 +781,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(struct_, defCont, {});
assertLUB(struct_, defStruct, struct_);
assertLUB(struct_, defArray, eq);
+ assertLUB(struct_, sharedAny, {});
+ assertLUB(struct_, sharedEq, {});
+ assertLUB(struct_, sharedI31, {});
+ assertLUB(struct_, sharedStruct, {});
+ assertLUB(struct_, sharedNone, {});
+ assertLUB(struct_, sharedFunc, {});
+ assertLUB(struct_, sharedDefStruct, {});
+ assertLUB(struct_, sharedDefFunc, {});
assertLUB(array, array, array);
assertLUB(array, cont, {});
@@ -724,6 +801,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(array, defCont, {});
assertLUB(array, defStruct, eq);
assertLUB(array, defArray, array);
+ assertLUB(array, sharedAny, {});
+ assertLUB(array, sharedEq, {});
+ assertLUB(array, sharedI31, {});
+ assertLUB(array, sharedStruct, {});
+ assertLUB(array, sharedNone, {});
+ assertLUB(array, sharedFunc, {});
+ assertLUB(array, sharedDefStruct, {});
+ assertLUB(array, sharedDefFunc, {});
assertLUB(string, string, string);
assertLUB(string, cont, {});
@@ -735,6 +820,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(string, defCont, {});
assertLUB(string, defStruct, any);
assertLUB(string, defArray, any);
+ assertLUB(string, sharedAny, {});
+ assertLUB(string, sharedEq, {});
+ assertLUB(string, sharedI31, {});
+ assertLUB(string, sharedStruct, {});
+ assertLUB(string, sharedNone, {});
+ assertLUB(string, sharedFunc, {});
+ assertLUB(string, sharedDefStruct, {});
+ assertLUB(string, sharedDefFunc, {});
assertLUB(none, none, none);
assertLUB(none, noext, {});
@@ -744,6 +837,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(none, defCont, {});
assertLUB(none, defStruct, defStruct);
assertLUB(none, defArray, defArray);
+ assertLUB(none, sharedAny, {});
+ assertLUB(none, sharedEq, {});
+ assertLUB(none, sharedI31, {});
+ assertLUB(none, sharedStruct, {});
+ assertLUB(none, sharedNone, {});
+ assertLUB(none, sharedFunc, {});
+ assertLUB(none, sharedDefStruct, {});
+ assertLUB(none, sharedDefFunc, {});
assertLUB(noext, noext, noext);
assertLUB(noext, nofunc, {});
@@ -752,6 +853,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(noext, defCont, {});
assertLUB(noext, defStruct, {});
assertLUB(noext, defArray, {});
+ assertLUB(noext, sharedAny, {});
+ assertLUB(noext, sharedEq, {});
+ assertLUB(noext, sharedI31, {});
+ assertLUB(noext, sharedStruct, {});
+ assertLUB(noext, sharedNone, {});
+ assertLUB(noext, sharedFunc, {});
+ assertLUB(noext, sharedDefStruct, {});
+ assertLUB(noext, sharedDefFunc, {});
assertLUB(nofunc, nofunc, nofunc);
assertLUB(nofunc, nocont, {});
@@ -759,6 +868,14 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(nofunc, defCont, {});
assertLUB(nofunc, defStruct, {});
assertLUB(nofunc, defArray, {});
+ assertLUB(nofunc, sharedAny, {});
+ assertLUB(nofunc, sharedEq, {});
+ assertLUB(nofunc, sharedI31, {});
+ assertLUB(nofunc, sharedStruct, {});
+ assertLUB(nofunc, sharedNone, {});
+ assertLUB(nofunc, sharedFunc, {});
+ assertLUB(nofunc, sharedDefStruct, {});
+ assertLUB(nofunc, sharedDefFunc, {});
assertLUB(nocont, nocont, nocont);
assertLUB(nocont, func, {});
@@ -768,21 +885,105 @@ TEST_F(TypeTest, TestHeapTypeRelations) {
assertLUB(nocont, defCont, defCont);
assertLUB(nocont, defStruct, {});
assertLUB(nocont, defArray, {});
+ assertLUB(nocont, sharedAny, {});
+ assertLUB(nocont, sharedEq, {});
+ assertLUB(nocont, sharedI31, {});
+ assertLUB(nocont, sharedStruct, {});
+ assertLUB(nocont, sharedNone, {});
+ assertLUB(nocont, sharedFunc, {});
+ assertLUB(nocont, sharedDefStruct, {});
+ assertLUB(nocont, sharedDefFunc, {});
assertLUB(defFunc, defFunc, defFunc);
assertLUB(defFunc, defCont, {});
assertLUB(defFunc, defStruct, {});
assertLUB(defFunc, defArray, {});
+ assertLUB(defFunc, sharedAny, {});
+ assertLUB(defFunc, sharedEq, {});
+ assertLUB(defFunc, sharedI31, {});
+ assertLUB(defFunc, sharedStruct, {});
+ assertLUB(defFunc, sharedNone, {});
+ assertLUB(defFunc, sharedFunc, {});
+ assertLUB(defFunc, sharedDefStruct, {});
+ assertLUB(defFunc, sharedDefFunc, {});
assertLUB(defCont, defCont, defCont);
assertLUB(defCont, defFunc, {});
assertLUB(defCont, defStruct, {});
assertLUB(defCont, defArray, {});
+ assertLUB(defCont, sharedAny, {});
+ assertLUB(defCont, sharedEq, {});
+ assertLUB(defCont, sharedI31, {});
+ assertLUB(defCont, sharedStruct, {});
+ assertLUB(defCont, sharedNone, {});
+ assertLUB(defCont, sharedFunc, {});
+ assertLUB(defCont, sharedDefStruct, {});
+ assertLUB(defCont, sharedDefFunc, {});
assertLUB(defStruct, defStruct, defStruct);
assertLUB(defStruct, defArray, eq);
+ assertLUB(defStruct, sharedAny, {});
+ assertLUB(defStruct, sharedEq, {});
+ assertLUB(defStruct, sharedI31, {});
+ assertLUB(defStruct, sharedStruct, {});
+ assertLUB(defStruct, sharedNone, {});
+ assertLUB(defStruct, sharedFunc, {});
+ assertLUB(defStruct, sharedDefStruct, {});
+ assertLUB(defStruct, sharedDefFunc, {});
assertLUB(defArray, defArray, defArray);
+ assertLUB(defArray, sharedAny, {});
+ assertLUB(defArray, sharedEq, {});
+ assertLUB(defArray, sharedI31, {});
+ assertLUB(defArray, sharedStruct, {});
+ assertLUB(defArray, sharedNone, {});
+ assertLUB(defArray, sharedFunc, {});
+ assertLUB(defArray, sharedDefStruct, {});
+ assertLUB(defArray, sharedDefFunc, {});
+
+ assertLUB(sharedAny, sharedAny, sharedAny);
+ assertLUB(sharedAny, sharedEq, sharedAny);
+ assertLUB(sharedAny, sharedI31, sharedAny);
+ assertLUB(sharedAny, sharedStruct, sharedAny);
+ assertLUB(sharedAny, sharedNone, sharedAny);
+ assertLUB(sharedAny, sharedFunc, {});
+ assertLUB(sharedAny, sharedDefStruct, sharedAny);
+ assertLUB(sharedAny, sharedDefFunc, {});
+
+ assertLUB(sharedEq, sharedEq, sharedEq);
+ assertLUB(sharedEq, sharedI31, sharedEq);
+ assertLUB(sharedEq, sharedStruct, sharedEq);
+ assertLUB(sharedEq, sharedNone, sharedEq);
+ assertLUB(sharedEq, sharedFunc, {});
+ assertLUB(sharedEq, sharedDefStruct, sharedEq);
+ assertLUB(sharedEq, sharedDefFunc, {});
+
+ assertLUB(sharedI31, sharedI31, sharedI31);
+ assertLUB(sharedI31, sharedStruct, sharedEq);
+ assertLUB(sharedI31, sharedNone, sharedI31);
+ assertLUB(sharedI31, sharedFunc, {});
+ assertLUB(sharedI31, sharedDefStruct, sharedEq);
+ assertLUB(sharedI31, sharedDefFunc, {});
+
+ assertLUB(sharedStruct, sharedStruct, sharedStruct);
+ assertLUB(sharedStruct, sharedNone, sharedStruct);
+ assertLUB(sharedStruct, sharedFunc, {});
+ assertLUB(sharedStruct, sharedDefStruct, sharedStruct);
+ assertLUB(sharedStruct, sharedDefFunc, {});
+
+ assertLUB(sharedNone, sharedNone, sharedNone);
+ assertLUB(sharedNone, sharedFunc, {});
+ assertLUB(sharedNone, sharedDefStruct, sharedDefStruct);
+ assertLUB(sharedNone, sharedDefFunc, {});
+
+ assertLUB(sharedFunc, sharedFunc, sharedFunc);
+ assertLUB(sharedFunc, sharedDefStruct, {});
+ assertLUB(sharedFunc, sharedDefFunc, sharedFunc);
+
+ assertLUB(sharedDefStruct, sharedDefStruct, sharedDefStruct);
+ assertLUB(sharedDefStruct, sharedDefFunc, {});
+
+ assertLUB(sharedDefFunc, sharedDefFunc, sharedDefFunc);
Type anyref = Type(any, Nullable);
Type eqref = Type(eq, Nullable);
diff --git a/test/lit/basic/shared-types.wast b/test/lit/basic/shared-types.wast
index d3720c2e9..0bba2f054 100644
--- a/test/lit/basic/shared-types.wast
+++ b/test/lit/basic/shared-types.wast
@@ -5,6 +5,8 @@
(module
(rec
+ ;; CHECK: (type $0 (func))
+
;; CHECK: (rec
;; CHECK-NEXT: (type $final (shared (struct )))
(type $final (shared (struct)))
@@ -23,9 +25,7 @@
(type $cont (shared (cont $func)))
)
- ;; CHECK: (type $7 (func))
-
- ;; CHECK: (func $use-types (type $7)
+ ;; CHECK: (func $use-types (type $0)
;; CHECK-NEXT: (local $0 (ref $final))
;; CHECK-NEXT: (local $1 (ref $top))
;; CHECK-NEXT: (local $2 (ref $mid))
@@ -44,4 +44,40 @@
(local (ref $array))
(local (ref $cont))
)
+
+ ;; CHECK: (func $use-basic-types (type $0)
+ ;; CHECK-NEXT: (local $0 (ref (shared extern)))
+ ;; CHECK-NEXT: (local $1 (ref (shared func)))
+ ;; CHECK-NEXT: (local $2 (ref (shared cont)))
+ ;; CHECK-NEXT: (local $3 (ref (shared any)))
+ ;; CHECK-NEXT: (local $4 (ref (shared eq)))
+ ;; CHECK-NEXT: (local $5 (ref (shared i31)))
+ ;; CHECK-NEXT: (local $6 (ref (shared struct)))
+ ;; CHECK-NEXT: (local $7 (ref (shared array)))
+ ;; CHECK-NEXT: (local $8 (ref (shared exn)))
+ ;; CHECK-NEXT: (local $9 (ref (shared string)))
+ ;; CHECK-NEXT: (local $10 (ref (shared none)))
+ ;; CHECK-NEXT: (local $11 (ref (shared noextern)))
+ ;; CHECK-NEXT: (local $12 (ref (shared nofunc)))
+ ;; CHECK-NEXT: (local $13 (ref (shared nocont)))
+ ;; CHECK-NEXT: (local $14 (ref (shared noexn)))
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $use-basic-types
+ (local (ref (shared extern)))
+ (local (ref (shared func)))
+ (local (ref (shared cont)))
+ (local (ref (shared any)))
+ (local (ref (shared eq)))
+ (local (ref (shared i31)))
+ (local (ref (shared struct)))
+ (local (ref (shared array)))
+ (local (ref (shared exn)))
+ (local (ref (shared string)))
+ (local (ref (shared none)))
+ (local (ref (shared noextern)))
+ (local (ref (shared nofunc)))
+ (local (ref (shared nocont)))
+ (local (ref (shared noexn)))
+ )
)
diff --git a/test/lit/basic/typed_continuations.wast b/test/lit/basic/typed_continuations.wast
index 52258403f..1e024ca0b 100644
--- a/test/lit/basic/typed_continuations.wast
+++ b/test/lit/basic/typed_continuations.wast
@@ -26,7 +26,7 @@
;; CHECK-TEXT-NEXT: )
;; CHECK-BIN: (type $2 (func (param (ref $ct)) (result (ref $ct))))
- ;; CHECK-BIN: (type $3 (func (param contref nullcontref (ref func) (ref nocont)) (result contref)))
+ ;; CHECK-BIN: (type $3 (func (param contref nullcontref (ref cont) (ref nocont)) (result contref)))
;; CHECK-BIN: (func $id (type $2) (param $x (ref $ct)) (result (ref $ct))
;; CHECK-BIN-NEXT: (local.get $x)
@@ -38,7 +38,7 @@
;; CHECK-TEXT: (func $id2 (type $3) (param $w contref) (param $x nullcontref) (param $y (ref cont)) (param $z (ref nocont)) (result contref)
;; CHECK-TEXT-NEXT: (local.get $z)
;; CHECK-TEXT-NEXT: )
- ;; CHECK-BIN: (func $id2 (type $3) (param $w contref) (param $x nullcontref) (param $y (ref func)) (param $z (ref nocont)) (result contref)
+ ;; CHECK-BIN: (func $id2 (type $3) (param $w contref) (param $x nullcontref) (param $y (ref cont)) (param $z (ref nocont)) (result contref)
;; CHECK-BIN-NEXT: (local.get $z)
;; CHECK-BIN-NEXT: )
(func $id2
@@ -57,12 +57,12 @@
;; CHECK-BIN-NODEBUG: (type $2 (func (param (ref $1)) (result (ref $1))))
-;; CHECK-BIN-NODEBUG: (type $3 (func (param contref nullcontref (ref func) (ref nocont)) (result contref)))
+;; CHECK-BIN-NODEBUG: (type $3 (func (param contref nullcontref (ref cont) (ref nocont)) (result contref)))
;; CHECK-BIN-NODEBUG: (func $0 (type $2) (param $0 (ref $1)) (result (ref $1))
;; CHECK-BIN-NODEBUG-NEXT: (local.get $0)
;; CHECK-BIN-NODEBUG-NEXT: )
-;; CHECK-BIN-NODEBUG: (func $1 (type $3) (param $0 contref) (param $1 nullcontref) (param $2 (ref func)) (param $3 (ref nocont)) (result contref)
+;; CHECK-BIN-NODEBUG: (func $1 (type $3) (param $0 contref) (param $1 nullcontref) (param $2 (ref cont)) (param $3 (ref nocont)) (result contref)
;; CHECK-BIN-NODEBUG-NEXT: (local.get $3)
;; CHECK-BIN-NODEBUG-NEXT: )
diff --git a/test/lit/passes/type-merging-shared.wast b/test/lit/passes/type-merging-shared.wast
index 2d3bcdc21..2457cd572 100644
--- a/test/lit/passes/type-merging-shared.wast
+++ b/test/lit/passes/type-merging-shared.wast
@@ -75,3 +75,25 @@
(local $c' (ref null $C'))
)
)
+
+(module
+ ;; Shared and unshared basic heap types similarly cannot be merged.
+ ;; CHECK: (rec
+ ;; CHECK-NEXT: (type $A' (shared (struct (field anyref))))
+
+ ;; CHECK: (type $A (shared (struct (field (ref null (shared any))))))
+ (type $A (shared (struct (ref null (shared any)))))
+ (type $A' (shared (struct (ref null any))))
+
+ ;; CHECK: (type $2 (func))
+
+ ;; CHECK: (func $foo (type $2)
+ ;; CHECK-NEXT: (local $a (ref null $A))
+ ;; CHECK-NEXT: (local $a' (ref null $A'))
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $foo
+ (local $a (ref null $A))
+ (local $a' (ref null $A'))
+ )
+)
diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast
index 87778bd24..71484977a 100644
--- a/test/lit/wat-kitchen-sink.wast
+++ b/test/lit/wat-kitchen-sink.wast
@@ -234,22 +234,22 @@
(type $cont-bind-before-func (func (param i32) (param i64) (param i32) (param i64) (result f32)))
(type $cont-bind-before (cont $cont-bind-before-func))
- ;; CHECK: (type $all-types (struct (field externref) (field (ref extern)) (field funcref) (field (ref func)) (field anyref) (field (ref any)) (field eqref) (field (ref eq)) (field i31ref) (field (ref i31)) (field structref) (field (ref struct)) (field arrayref) (field (ref array)) (field exnref) (field (ref exn)) (field stringref) (field (ref string)) (field contref) (field (ref cont)) (field nullref) (field (ref none)) (field nullexternref) (field (ref noextern)) (field nullfuncref) (field (ref nofunc)) (field nullexnref) (field (ref noexn)) (field nullcontref) (field (ref nocont))))
- (type $all-types (struct externref (ref extern)
- funcref (ref func)
- anyref (ref any)
- eqref (ref eq)
- i31ref (ref i31)
- structref (ref struct)
- arrayref (ref array)
- exnref (ref exn)
- stringref (ref string)
- contref (ref cont)
- nullref (ref none)
- nullexternref (ref noextern)
- nullfuncref (ref nofunc)
- nullexnref (ref noexn)
- nullcontref (ref nocont)))
+ ;; CHECK: (type $all-types (struct (field externref) (field (ref extern)) (field (ref null (shared extern))) (field (ref (shared extern))) (field funcref) (field (ref func)) (field (ref null (shared func))) (field (ref (shared func))) (field anyref) (field (ref any)) (field (ref null (shared any))) (field (ref (shared any))) (field eqref) (field (ref eq)) (field (ref null (shared eq))) (field (ref (shared eq))) (field i31ref) (field (ref i31)) (field (ref null (shared i31))) (field (ref (shared i31))) (field structref) (field (ref struct)) (field (ref null (shared struct))) (field (ref (shared struct))) (field arrayref) (field (ref array)) (field (ref null (shared array))) (field (ref (shared array))) (field exnref) (field (ref exn)) (field (ref null (shared exn))) (field (ref (shared exn))) (field stringref) (field (ref string)) (field (ref null (shared string))) (field (ref (shared string))) (field contref) (field (ref cont)) (field (ref null (shared cont))) (field (ref (shared cont))) (field nullref) (field (ref none)) (field (ref null (shared none))) (field (ref (shared none))) (field nullexternref) (field (ref noextern)) (field (ref null (shared noextern))) (field (ref (shared noextern))) (field nullfuncref) (field (ref nofunc)) (field (ref null (shared nofunc))) (field (ref (shared nofunc))) (field nullexnref) (field (ref noexn)) (field (ref null (shared noexn))) (field (ref (shared noexn))) (field nullcontref) (field (ref nocont)) (field (ref null (shared nocont))) (field (ref (shared nocont)))))
+ (type $all-types (struct externref (ref extern) (ref null (shared extern)) (ref (shared extern))
+ funcref (ref func) (ref null (shared func)) (ref (shared func))
+ anyref (ref any) (ref null (shared any)) (ref (shared any))
+ eqref (ref eq) (ref null (shared eq)) (ref (shared eq))
+ i31ref (ref i31) (ref null (shared i31)) (ref (shared i31))
+ structref (ref struct) (ref null (shared struct)) (ref (shared struct))
+ arrayref (ref array) (ref null (shared array)) (ref (shared array))
+ exnref (ref exn) (ref null (shared exn)) (ref (shared exn))
+ stringref (ref string) (ref null (shared string)) (ref (shared string))
+ contref (ref cont) (ref null (shared cont)) (ref (shared cont))
+ nullref (ref none) (ref null (shared none)) (ref (shared none))
+ nullexternref (ref noextern) (ref null (shared noextern)) (ref (shared noextern))
+ nullfuncref (ref nofunc) (ref null (shared nofunc)) (ref (shared nofunc))
+ nullexnref (ref noexn) (ref null (shared noexn)) (ref (shared noexn))
+ nullcontref (ref nocont) (ref null (shared nocont)) (ref (shared nocont))))
;; imported memories
(memory (export "mem") (export "mem2") (import "" "mem") 0)