summaryrefslogtreecommitdiff
path: root/test/lit
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-08-22 16:21:19 -0700
committerGitHub <noreply@github.com>2022-08-22 16:21:19 -0700
commit92cdc7245b715d88cf986a7eaf78c49ea64ba825 (patch)
tree7e20e91c0a60a5b08f8bb01d64ea7ebc3a6b6885 /test/lit
parent195c4e1804d5a4530c8216d4c9a138b56f676d10 (diff)
downloadbinaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.tar.gz
binaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.tar.bz2
binaryen-92cdc7245b715d88cf986a7eaf78c49ea64ba825.zip
Separate `func` into a separate type hierarchy (#4955)
Just like `extern` is no longer a subtype of `any` in the new GC type system, `func` is no longer a subtype of `any`, either. Make that change in our type system implementation and update tests and fuzzers accordingly.
Diffstat (limited to 'test/lit')
-rw-r--r--test/lit/passes/dae-gc-refine-return.wast204
-rw-r--r--test/lit/passes/dae-gc.wast22
-rw-r--r--test/lit/passes/global-refining.wast83
-rw-r--r--test/lit/passes/gufa-refs.wast52
-rw-r--r--test/lit/passes/inlining_splitting.wast8
-rw-r--r--test/lit/passes/local-subtyping-nn.wast2
-rw-r--r--test/lit/passes/local-subtyping.wast104
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast12
-rw-r--r--test/lit/passes/remove-unused-brs-gc.wast8
-rw-r--r--test/lit/passes/remove-unused-brs.wast15
-rw-r--r--test/lit/passes/signature-pruning.wast14
-rw-r--r--test/lit/passes/signature-refining.wast42
-rw-r--r--test/lit/passes/type-refining.wast20
13 files changed, 270 insertions, 316 deletions
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))
)
)
)