summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/gto-mutability.wast63
-rw-r--r--test/lit/passes/type-merging.wast6
-rw-r--r--test/lit/validation/closed-world-interface.wast4
3 files changed, 68 insertions, 5 deletions
diff --git a/test/lit/passes/gto-mutability.wast b/test/lit/passes/gto-mutability.wast
index 28fc1bc69..ed04edccc 100644
--- a/test/lit/passes/gto-mutability.wast
+++ b/test/lit/passes/gto-mutability.wast
@@ -589,3 +589,66 @@
(drop (struct.get $sub 0 (local.get $sub)))
)
)
+
+;; This pass does not refine array types yet. Verify that we do not. This is
+;; particularly important for array of i8 and i6, which we special-case as they
+;; are used for string interop even in closed world. For now, however, we do not
+;; optimize even arrays of i32.
+;;
+;; Nothing should change in these array types. They have no writes, but they'll
+;; stay mutable. Also, this test verifies that we can even validate this module
+;; in closed world, even though it contains imports of i8 and i16 arrays.
+;;
+;; The test also verifies that while we refine the mutability of a struct type,
+;; which causes us to rewrite types, that we keep the i8 and i16 arrays in
+;; their own size-1 rec groups by themselves, unmodified. The i32 array will be
+;; moved into a new big rec group, together with the struct type (that is also
+;; refined to be immutable).
+(module
+ ;; CHECK: (type $array8 (array (mut i8)))
+ (type $array8 (array (mut i8)))
+ ;; CHECK: (type $array16 (array (mut i16)))
+ (type $array16 (array (mut i16)))
+ ;; CHECK: (rec
+ ;; CHECK-NEXT: (type $struct (struct (field funcref)))
+
+ ;; CHECK: (type $array32 (array (mut i32)))
+ (type $array32 (array (mut i32)))
+
+ (type $struct (struct (field (mut funcref))))
+
+ ;; CHECK: (type $4 (func (param funcref)))
+
+ ;; CHECK: (import "a" "b" (global $i8 (ref $array8)))
+ (import "a" "b" (global $i8 (ref $array8)))
+
+ ;; CHECK: (import "a" "c" (global $i16 (ref $array16)))
+ (import "a" "c" (global $i16 (ref $array16)))
+
+ ;; CHECK: (func $use (type $4) (param $funcref funcref)
+ ;; CHECK-NEXT: (local $array8 (ref $array8))
+ ;; CHECK-NEXT: (local $array16 (ref $array16))
+ ;; CHECK-NEXT: (local $array32 (ref $array32))
+ ;; CHECK-NEXT: (local $struct (ref $struct))
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (struct.get $struct 0
+ ;; CHECK-NEXT: (struct.new $struct
+ ;; CHECK-NEXT: (local.get $funcref)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $use (param $funcref funcref)
+ (local $array8 (ref $array8))
+ (local $array16 (ref $array16))
+ (local $array32 (ref $array32))
+ (local $struct (ref $struct))
+ (drop
+ (struct.get $struct 0
+ (struct.new $struct
+ (local.get $funcref)
+ )
+ )
+ )
+ )
+)
diff --git a/test/lit/passes/type-merging.wast b/test/lit/passes/type-merging.wast
index 643e28bd9..7c44fe8e2 100644
--- a/test/lit/passes/type-merging.wast
+++ b/test/lit/passes/type-merging.wast
@@ -388,17 +388,17 @@
;; CHECK: (type $C (array i16))
- ;; CHECK: (type $B (array (mut i8)))
+ ;; CHECK: (type $B (array (mut i32)))
;; CHECK: (type $A (array i8))
(type $A (array i8))
(type $A' (array i8))
- (type $B (array (mut i8)))
- (type $B' (array (mut i8)))
(type $C (array i16))
(type $C' (array i16))
(type $D (array i32))
(type $D' (array i32))
+ (type $B (array (mut i32)))
+ (type $B' (array (mut i32)))
(type $E (array i64))
(type $E' (array i64))
(type $F (array anyref))
diff --git a/test/lit/validation/closed-world-interface.wast b/test/lit/validation/closed-world-interface.wast
index f5dd7ad46..06cf1cef7 100644
--- a/test/lit/validation/closed-world-interface.wast
+++ b/test/lit/validation/closed-world-interface.wast
@@ -9,7 +9,7 @@
;; This is pulled in by a global.
;; CHECK: publicly exposed type disallowed with a closed world: $array, on
-;; CHECK-NEXT: (array (mut i8))
+;; CHECK-NEXT: (array (mut i32))
;; This is pulled in only by a global, so it is disallowed even though it is a function type.
;; CHECK: publicly exposed type disallowed with a closed world: $private, on
@@ -21,7 +21,7 @@
(module
(type $struct (struct))
- (type $array (array (mut i8)))
+ (type $array (array (mut i32)))
(type $void (func))
(type $abstract (func (param anyref)))