-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gc] Fix subtype check in call_indirect, binary encoding of recursion…
… groups
- Loading branch information
Showing
9 changed files
with
167 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
;; Link-time matching of recursive function types | ||
|
||
(module $M | ||
(rec (type $f1 (func)) (type (struct))) | ||
(func (export "f") (type $f1)) | ||
) | ||
(register "M" $M) | ||
|
||
(module | ||
(rec (type $f2 (func)) (type (struct))) | ||
(func (import "M" "f") (type $f2)) | ||
) | ||
|
||
(assert_unlinkable | ||
(module | ||
(rec (type (struct)) (type $f2 (func))) | ||
(func (import "M" "f") (type $f2)) | ||
) | ||
"incompatible import type" | ||
) | ||
|
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,60 @@ | ||
(module | ||
(type $t0 (sub (func (result (ref null func))))) | ||
(rec (type $t1 (sub $t0 (func (result (ref null $t1)))))) | ||
(rec (type $t2 (sub $t1 (func (result (ref null $t2)))))) | ||
|
||
(func $f0 (type $t0) (ref.null func)) | ||
(func $f1 (type $t1) (ref.null $t1)) | ||
(func $f2 (type $t2) (ref.null $t2)) | ||
(table funcref (elem $f0 $f1 $f2)) | ||
|
||
(func (export "run") | ||
(block (result (ref null func)) (call_indirect (type $t0) (i32.const 0))) | ||
(block (result (ref null func)) (call_indirect (type $t0) (i32.const 1))) | ||
(block (result (ref null func)) (call_indirect (type $t0) (i32.const 2))) | ||
(block (result (ref null $t1)) (call_indirect (type $t1) (i32.const 1))) | ||
(block (result (ref null $t1)) (call_indirect (type $t1) (i32.const 2))) | ||
(block (result (ref null $t2)) (call_indirect (type $t2) (i32.const 2))) | ||
|
||
(block (result (ref null $t0)) (ref.cast (ref $t0) (table.get (i32.const 0)))) | ||
(block (result (ref null $t0)) (ref.cast (ref $t0) (table.get (i32.const 1)))) | ||
(block (result (ref null $t0)) (ref.cast (ref $t0) (table.get (i32.const 2)))) | ||
(block (result (ref null $t1)) (ref.cast (ref $t1) (table.get (i32.const 1)))) | ||
(block (result (ref null $t1)) (ref.cast (ref $t1) (table.get (i32.const 2)))) | ||
(block (result (ref null $t2)) (ref.cast (ref $t2) (table.get (i32.const 2)))) | ||
(br 0) | ||
) | ||
|
||
(func (export "fail1") | ||
(block (result (ref null $t1)) (call_indirect (type $t1) (i32.const 0))) | ||
(br 0) | ||
) | ||
(func (export "fail2") | ||
(block (result (ref null $t1)) (call_indirect (type $t2) (i32.const 0))) | ||
(br 0) | ||
) | ||
(func (export "fail3") | ||
(block (result (ref null $t1)) (call_indirect (type $t2) (i32.const 1))) | ||
(br 0) | ||
) | ||
|
||
(func (export "fail4") | ||
(ref.cast (ref $t1) (table.get (i32.const 0))) | ||
(br 0) | ||
) | ||
(func (export "fail5") | ||
(ref.cast (ref $t2) (table.get (i32.const 0))) | ||
(br 0) | ||
) | ||
(func (export "fail6") | ||
(ref.cast (ref $t2) (table.get (i32.const 1))) | ||
(br 0) | ||
) | ||
) | ||
(assert_return (invoke "run")) | ||
(assert_trap (invoke "fail1") "indirect call") | ||
(assert_trap (invoke "fail2") "indirect call") | ||
(assert_trap (invoke "fail3") "indirect call") | ||
(assert_trap (invoke "fail4") "cast") | ||
(assert_trap (invoke "fail5") "cast") | ||
(assert_trap (invoke "fail6") "cast") |
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,18 @@ | ||
(module binary | ||
"\00\61\73\6d\01\00\00\00\01\89\80\80\80\00\02\50" | ||
"\00\60\00\00\60\00\00\03\87\80\80\80\00\06\00\01" | ||
"\01\01\01\01\04\85\80\80\80\00\01\70\01\02\02\07" | ||
"\a1\80\80\80\00\04\05\66\61\69\6c\31\00\02\05\66" | ||
"\61\69\6c\32\00\03\05\66\61\69\6c\33\00\04\05\66" | ||
"\61\69\6c\34\00\05\09\8e\80\80\80\00\01\06\00\41" | ||
"\00\0b\70\02\d2\00\0b\d2\01\0b\0a\cb\80\80\80\00" | ||
"\06\82\80\80\80\00\00\0b\82\80\80\80\00\00\0b\8a" | ||
"\80\80\80\00\00\02\40\41\01\11\00\00\0b\0b\8a\80" | ||
"\80\80\00\00\02\40\41\00\11\01\00\0b\0b\8a\80\80" | ||
"\80\00\00\41\01\25\00\fb\16\00\1a\0b\8a\80\80\80" | ||
"\00\00\41\00\25\00\fb\16\01\1a\0b" | ||
) | ||
(assert_trap (invoke "fail1") "indirect call") | ||
(assert_trap (invoke "fail2") "indirect call") | ||
(assert_trap (invoke "fail3") "cast") | ||
(assert_trap (invoke "fail4") "cast") |
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,28 @@ | ||
(module | ||
(type $t1 (sub (func))) | ||
(type $t2 (sub final (func))) | ||
|
||
(func $f1 (type $t1)) | ||
(func $f2 (type $t2)) | ||
(table funcref (elem $f1 $f2)) | ||
|
||
(func (export "fail1") | ||
(block (call_indirect (type $t1) (i32.const 1))) | ||
) | ||
(func (export "fail2") | ||
(block (call_indirect (type $t2) (i32.const 0))) | ||
) | ||
|
||
(func (export "fail3") | ||
(ref.cast (ref $t1) (table.get (i32.const 1))) | ||
(drop) | ||
) | ||
(func (export "fail4") | ||
(ref.cast (ref $t2) (table.get (i32.const 0))) | ||
(drop) | ||
) | ||
) | ||
(assert_trap (invoke "fail1") "indirect call") | ||
(assert_trap (invoke "fail2") "indirect call") | ||
(assert_trap (invoke "fail3") "cast") | ||
(assert_trap (invoke "fail4") "cast") |
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,24 @@ | ||
(module | ||
(type $t1 (sub (func))) | ||
(type $t2 (sub final (func))) | ||
(func (export "f1") (type $t1)) | ||
(func (export "f2") (type $t2)) | ||
) | ||
(register "M2") | ||
|
||
(assert_unlinkable | ||
(module | ||
(type $t1 (sub (func))) | ||
(type $t2 (sub final (func))) | ||
(func (import "M2" "f1") (type $t2)) | ||
) | ||
"incompatible import type" | ||
) | ||
(assert_unlinkable | ||
(module | ||
(type $t1 (sub (func))) | ||
(type $t2 (sub final (func))) | ||
(func (import "M2" "f2") (type $t1)) | ||
) | ||
"incompatible import type" | ||
) |