forked from bytecodealliance/wasm-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
ref.{test,cast}
to check against top types (bytecodealliance#1336)
The spec says that `ref.{test,cast} rt` are valid when `rt'` is on the stack and `rt <: rt'`. We were checking this before, but not allowing `rt'` to upcast to any of its super types. The solution is to immediately upcast it to its top type, and then check `rt <: top(rt')`. This gets the `type-subtyping.wast` test fully passing.
- Loading branch information
Showing
49 changed files
with
1,006 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/0.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(module | ||
(type $e0 (;0;) (sub (array i32))) | ||
(type $e1 (;1;) (sub $e0 (;0;) (array i32))) | ||
(type $e2 (;2;) (sub (array anyref))) | ||
(type $e3 (;3;) (sub (array (ref null 0)))) | ||
(type $e4 (;4;) (sub (array (ref 1)))) | ||
(type $m1 (;5;) (sub (array (mut i32)))) | ||
(type $m2 (;6;) (sub $m1 (;5;) (array (mut i32)))) | ||
) |
8 changes: 8 additions & 0 deletions
8
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/1.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(module | ||
(type $e0 (;0;) (sub (struct))) | ||
(type $e1 (;1;) (sub $e0 (;0;) (struct))) | ||
(type $e2 (;2;) (sub $e1 (;1;) (struct (field i32)))) | ||
(type $e3 (;3;) (sub $e2 (;2;) (struct (field i32) (field (ref null 0))))) | ||
(type $e4 (;4;) (sub $e3 (;3;) (struct (field i32) (field (ref 0)) (field (mut i64))))) | ||
(type $e5 (;5;) (sub $e4 (;4;) (struct (field i32) (field (ref 1)) (field (mut i64))))) | ||
) |
16 changes: 16 additions & 0 deletions
16
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/11.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(module | ||
(rec | ||
(type $f1 (;0;) (sub (func))) | ||
(type (;1;) (struct (field (ref 0)))) | ||
) | ||
(rec | ||
(type $f2 (;2;) (sub (func))) | ||
(type (;3;) (struct (field (ref 2)))) | ||
) | ||
(rec | ||
(type $g (;4;) (sub $f1 (;0;) (func))) | ||
(type (;5;) (struct)) | ||
) | ||
(func $g (;0;) (type $g)) | ||
(global (;0;) (ref 0) ref.func $g) | ||
) |
25 changes: 25 additions & 0 deletions
25
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/12.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(module | ||
(rec | ||
(type $f1 (;0;) (sub (func))) | ||
(type $s1 (;1;) (sub (struct (field (ref 0))))) | ||
) | ||
(rec | ||
(type $f2 (;2;) (sub (func))) | ||
(type $s2 (;3;) (sub (struct (field (ref 2))))) | ||
) | ||
(rec | ||
(type $g1 (;4;) (sub $f1 (;0;) (func))) | ||
(type (;5;) (sub $s1 (;1;) (struct (field (ref 0)) (field (ref 0)) (field (ref 2)) (field (ref 2)) (field (ref 4))))) | ||
) | ||
(rec | ||
(type $g2 (;6;) (sub $f2 (;2;) (func))) | ||
(type (;7;) (sub $s2 (;3;) (struct (field (ref 0)) (field (ref 2)) (field (ref 0)) (field (ref 2)) (field (ref 6))))) | ||
) | ||
(rec | ||
(type $h (;8;) (sub $g2 (;6;) (func))) | ||
(type (;9;) (struct)) | ||
) | ||
(func $h (;0;) (type $h)) | ||
(global (;0;) (ref 0) ref.func $h) | ||
(global (;1;) (ref 4) ref.func $h) | ||
) |
20 changes: 20 additions & 0 deletions
20
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/13.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(module | ||
(rec | ||
(type $f11 (;0;) (sub (func (result (ref func))))) | ||
(type $f12 (;1;) (sub $f11 (;0;) (func (result (ref 0))))) | ||
) | ||
(rec | ||
(type $f21 (;2;) (sub (func (result (ref func))))) | ||
(type $f22 (;3;) (sub $f21 (;2;) (func (result (ref 2))))) | ||
) | ||
(func $f11 (;0;) (type $f11) (result (ref func)) | ||
unreachable | ||
) | ||
(func $f12 (;1;) (type $f12) (result (ref 0)) | ||
unreachable | ||
) | ||
(global (;0;) (ref 0) ref.func $f11) | ||
(global (;1;) (ref 2) ref.func $f11) | ||
(global (;2;) (ref 1) ref.func $f12) | ||
(global (;3;) (ref 3) ref.func $f12) | ||
) |
32 changes: 32 additions & 0 deletions
32
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/14.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(module | ||
(rec | ||
(type $f11 (;0;) (sub (func (result (ref func))))) | ||
(type $f12 (;1;) (sub $f11 (;0;) (func (result (ref 0))))) | ||
) | ||
(rec | ||
(type $f21 (;2;) (sub (func (result (ref func))))) | ||
(type $f22 (;3;) (sub $f21 (;2;) (func (result (ref 2))))) | ||
) | ||
(rec | ||
(type $g11 (;4;) (sub $f11 (;0;) (func (result (ref func))))) | ||
(type $g12 (;5;) (sub $g11 (;4;) (func (result (ref 4))))) | ||
) | ||
(rec | ||
(type $g21 (;6;) (sub $f21 (;2;) (func (result (ref func))))) | ||
(type $g22 (;7;) (sub $g21 (;6;) (func (result (ref 6))))) | ||
) | ||
(func $g11 (;0;) (type $g11) (result (ref func)) | ||
unreachable | ||
) | ||
(func $g12 (;1;) (type $g12) (result (ref 4)) | ||
unreachable | ||
) | ||
(global (;0;) (ref 0) ref.func $g11) | ||
(global (;1;) (ref 2) ref.func $g11) | ||
(global (;2;) (ref 0) ref.func $g12) | ||
(global (;3;) (ref 2) ref.func $g12) | ||
(global (;4;) (ref 4) ref.func $g11) | ||
(global (;5;) (ref 6) ref.func $g11) | ||
(global (;6;) (ref 5) ref.func $g12) | ||
(global (;7;) (ref 7) ref.func $g12) | ||
) |
124 changes: 124 additions & 0 deletions
124
tests/snapshots/testsuite/proposals/gc/type-subtyping.wast/17.print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
(module | ||
(type $t0 (;0;) (sub (func (result funcref)))) | ||
(rec | ||
(type $t1 (;1;) (sub $t0 (;0;) (func (result (ref null 1))))) | ||
) | ||
(rec | ||
(type $t2 (;2;) (sub $t1 (;1;) (func (result (ref null 2))))) | ||
) | ||
(type (;3;) (func)) | ||
(func $f0 (;0;) (type $t0) (result funcref) | ||
ref.null func | ||
) | ||
(func $f1 (;1;) (type $t1) (result (ref null 1)) | ||
ref.null 1 | ||
) | ||
(func $f2 (;2;) (type $t2) (result (ref null 2)) | ||
ref.null 2 | ||
) | ||
(func (;3;) (type 3) | ||
block (result funcref) ;; label = @1 | ||
i32.const 0 | ||
call_indirect (type $t0) | ||
end | ||
block (result funcref) ;; label = @1 | ||
i32.const 1 | ||
call_indirect (type $t0) | ||
end | ||
block (result funcref) ;; label = @1 | ||
i32.const 2 | ||
call_indirect (type $t0) | ||
end | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 1 | ||
call_indirect (type $t1) | ||
end | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 2 | ||
call_indirect (type $t1) | ||
end | ||
block (result (ref null 2)) ;; label = @1 | ||
i32.const 2 | ||
call_indirect (type $t2) | ||
end | ||
block (result (ref null 0)) ;; label = @1 | ||
i32.const 0 | ||
table.get 0 | ||
ref.cast (ref 0) | ||
end | ||
block (result (ref null 0)) ;; label = @1 | ||
i32.const 1 | ||
table.get 0 | ||
ref.cast (ref 0) | ||
end | ||
block (result (ref null 0)) ;; label = @1 | ||
i32.const 2 | ||
table.get 0 | ||
ref.cast (ref 0) | ||
end | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 1 | ||
table.get 0 | ||
ref.cast (ref 1) | ||
end | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 2 | ||
table.get 0 | ||
ref.cast (ref 1) | ||
end | ||
block (result (ref null 2)) ;; label = @1 | ||
i32.const 2 | ||
table.get 0 | ||
ref.cast (ref 2) | ||
end | ||
br 0 (;@0;) | ||
) | ||
(func (;4;) (type 3) | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 0 | ||
call_indirect (type $t1) | ||
end | ||
br 0 (;@0;) | ||
) | ||
(func (;5;) (type 3) | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 0 | ||
call_indirect (type $t2) | ||
end | ||
br 0 (;@0;) | ||
) | ||
(func (;6;) (type 3) | ||
block (result (ref null 1)) ;; label = @1 | ||
i32.const 1 | ||
call_indirect (type $t2) | ||
end | ||
br 0 (;@0;) | ||
) | ||
(func (;7;) (type 3) | ||
i32.const 0 | ||
table.get 0 | ||
ref.cast (ref 1) | ||
br 0 (;@0;) | ||
) | ||
(func (;8;) (type 3) | ||
i32.const 0 | ||
table.get 0 | ||
ref.cast (ref 2) | ||
br 0 (;@0;) | ||
) | ||
(func (;9;) (type 3) | ||
i32.const 1 | ||
table.get 0 | ||
ref.cast (ref 2) | ||
br 0 (;@0;) | ||
) | ||
(table (;0;) 3 3 funcref) | ||
(export "run" (func 3)) | ||
(export "fail1" (func 4)) | ||
(export "fail2" (func 5)) | ||
(export "fail3" (func 6)) | ||
(export "fail4" (func 7)) | ||
(export "fail5" (func 8)) | ||
(export "fail6" (func 9)) | ||
(elem (;0;) (i32.const 0) func $f0 $f1 $f2) | ||
) |
Oops, something went wrong.