summaryrefslogtreecommitdiff
path: root/test/reference-types.wast.fromBinary
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-12-30 17:55:20 -0800
committerGitHub <noreply@github.com>2019-12-30 17:55:20 -0800
commitbcc76146fed433cbc8ba01a9f568d979c145110b (patch)
treeab70ad24afc257b73513c3e62f3aab9938d05944 /test/reference-types.wast.fromBinary
parenta30f1df5696ccb3490e2eaa3a9ed5e7e487c7b0e (diff)
downloadbinaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.gz
binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.bz2
binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.zip
Add support for reference types proposal (#2451)
This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447.
Diffstat (limited to 'test/reference-types.wast.fromBinary')
-rw-r--r--test/reference-types.wast.fromBinary492
1 files changed, 492 insertions, 0 deletions
diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary
new file mode 100644
index 000000000..b1229db8b
--- /dev/null
+++ b/test/reference-types.wast.fromBinary
@@ -0,0 +1,492 @@
+(module
+ (type $anyref_=>_none (func (param anyref)))
+ (type $none_=>_anyref (func (result anyref)))
+ (type $funcref_=>_none (func (param funcref)))
+ (type $nullref_=>_none (func (param nullref)))
+ (type $exnref_=>_none (func (param exnref)))
+ (type $none_=>_funcref (func (result funcref)))
+ (type $none_=>_exnref (func (result exnref)))
+ (type $none_=>_none (func))
+ (type $none_=>_nullref (func (result nullref)))
+ (type $anyref_=>_funcref (func (param anyref) (result funcref)))
+ (import "env" "import_global" (global $gimport$1 anyref))
+ (import "env" "import_func" (func $import_func (param anyref) (result funcref)))
+ (table $0 4 4 funcref)
+ (elem (i32.const 0) $take_anyref $take_funcref $take_exnref $take_nullref)
+ (global $global$0 (mut anyref) (ref.null))
+ (global $global$1 (mut funcref) (ref.null))
+ (global $global$2 (mut exnref) (ref.null))
+ (global $global$3 (mut nullref) (ref.null))
+ (global $global$4 (mut anyref) (ref.func $foo))
+ (global $global$5 (mut funcref) (ref.func $foo))
+ (export "export_func" (func $import_func))
+ (export "export_global" (global $gimport$1))
+ (func $take_anyref (; 1 ;) (param $0 anyref)
+ (nop)
+ )
+ (func $take_funcref (; 2 ;) (param $0 funcref)
+ (nop)
+ )
+ (func $take_exnref (; 3 ;) (param $0 exnref)
+ (nop)
+ )
+ (func $take_nullref (; 4 ;) (param $0 nullref)
+ (nop)
+ )
+ (func $foo (; 5 ;)
+ (nop)
+ )
+ (func $test (; 6 ;)
+ (local $0 funcref)
+ (local $1 anyref)
+ (local $2 nullref)
+ (local $3 exnref)
+ (local.set $1
+ (local.get $1)
+ )
+ (local.set $1
+ (local.get $0)
+ )
+ (local.set $1
+ (local.get $3)
+ )
+ (local.set $1
+ (local.get $2)
+ )
+ (local.set $1
+ (ref.null)
+ )
+ (local.set $1
+ (ref.func $foo)
+ )
+ (local.set $0
+ (local.get $0)
+ )
+ (local.set $0
+ (ref.null)
+ )
+ (local.set $0
+ (ref.func $foo)
+ )
+ (local.set $3
+ (local.get $3)
+ )
+ (local.set $3
+ (ref.null)
+ )
+ (local.set $2
+ (local.get $2)
+ )
+ (local.set $2
+ (ref.null)
+ )
+ (global.set $global$0
+ (global.get $global$0)
+ )
+ (global.set $global$0
+ (global.get $global$1)
+ )
+ (global.set $global$0
+ (global.get $global$2)
+ )
+ (global.set $global$0
+ (global.get $global$3)
+ )
+ (global.set $global$0
+ (ref.null)
+ )
+ (global.set $global$0
+ (ref.func $foo)
+ )
+ (global.set $global$1
+ (global.get $global$1)
+ )
+ (global.set $global$1
+ (ref.null)
+ )
+ (global.set $global$1
+ (ref.func $foo)
+ )
+ (global.set $global$2
+ (global.get $global$2)
+ )
+ (global.set $global$2
+ (ref.null)
+ )
+ (global.set $global$3
+ (global.get $global$3)
+ )
+ (global.set $global$3
+ (ref.null)
+ )
+ (call $take_anyref
+ (local.get $1)
+ )
+ (call $take_anyref
+ (local.get $0)
+ )
+ (call $take_anyref
+ (local.get $3)
+ )
+ (call $take_anyref
+ (ref.null)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $1)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $0)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (local.get $3)
+ (i32.const 0)
+ )
+ (call_indirect (type $anyref_=>_none)
+ (ref.null)
+ (i32.const 0)
+ )
+ (call_indirect (type $funcref_=>_none)
+ (local.get $0)
+ (i32.const 1)
+ )
+ (call_indirect (type $funcref_=>_none)
+ (ref.null)
+ (i32.const 1)
+ )
+ (call_indirect (type $exnref_=>_none)
+ (local.get $3)
+ (i32.const 2)
+ )
+ (call_indirect (type $exnref_=>_none)
+ (ref.null)
+ (i32.const 2)
+ )
+ (call_indirect (type $nullref_=>_none)
+ (local.get $2)
+ (i32.const 3)
+ )
+ (call_indirect (type $nullref_=>_none)
+ (ref.null)
+ (i32.const 3)
+ )
+ (drop
+ (block $label$1 (result anyref)
+ (br_if $label$1
+ (local.get $1)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$2 (result anyref)
+ (br_if $label$2
+ (local.get $0)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$3 (result anyref)
+ (br_if $label$3
+ (local.get $3)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$4 (result anyref)
+ (br_if $label$4
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$5 (result funcref)
+ (br_if $label$5
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$6 (result exnref)
+ (br_if $label$6
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (block $label$7 (result nullref)
+ (br_if $label$7
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (loop $label$8 (result anyref)
+ (local.get $1)
+ )
+ )
+ (drop
+ (loop $label$9 (result anyref)
+ (local.get $0)
+ )
+ )
+ (drop
+ (loop $label$10 (result anyref)
+ (local.get $3)
+ )
+ )
+ (drop
+ (loop $label$11 (result anyref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $label$12 (result funcref)
+ (local.get $0)
+ )
+ )
+ (drop
+ (loop $label$13 (result funcref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $label$14 (result exnref)
+ (local.get $3)
+ )
+ )
+ (drop
+ (loop $label$15 (result exnref)
+ (ref.null)
+ )
+ )
+ (drop
+ (loop $label$16 (result nullref)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result anyref)
+ (i32.const 1)
+ (local.get $1)
+ (local.get $3)
+ )
+ )
+ (drop
+ (if (result anyref)
+ (i32.const 1)
+ (ref.func $foo)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result funcref)
+ (i32.const 1)
+ (ref.func $foo)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result exnref)
+ (i32.const 1)
+ (local.get $3)
+ (ref.null)
+ )
+ )
+ (drop
+ (if (result nullref)
+ (i32.const 1)
+ (local.get $2)
+ (ref.null)
+ )
+ )
+ (drop
+ (try (result anyref)
+ (local.get $1)
+ (catch
+ (exnref.pop)
+ )
+ )
+ )
+ (drop
+ (try (result anyref)
+ (ref.func $foo)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (try (result funcref)
+ (ref.func $foo)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (try (result exnref)
+ (ref.null)
+ (catch
+ (exnref.pop)
+ )
+ )
+ )
+ (drop
+ (try (result nullref)
+ (ref.null)
+ (catch
+ (drop
+ (exnref.pop)
+ )
+ (ref.null)
+ )
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $1)
+ (ref.func $foo)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $3)
+ (local.get $1)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (local.get $1)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result anyref)
+ (ref.null)
+ (ref.func $foo)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result funcref)
+ (ref.func $foo)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result exnref)
+ (ref.null)
+ (local.get $3)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select (result nullref)
+ (ref.null)
+ (ref.null)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (select
+ (i32.const 0)
+ (i32.const 2)
+ (i32.const 1)
+ )
+ )
+ (drop
+ (ref.is_null
+ (local.get $1)
+ )
+ )
+ (drop
+ (ref.is_null
+ (local.get $3)
+ )
+ )
+ (drop
+ (ref.is_null
+ (ref.func $foo)
+ )
+ )
+ (drop
+ (ref.is_null
+ (ref.null)
+ )
+ )
+ )
+ (func $return_anyref (; 7 ;) (result anyref)
+ (local $0 anyref)
+ (local.get $0)
+ )
+ (func $return_anyref2 (; 8 ;) (result anyref)
+ (ref.func $foo)
+ )
+ (func $return_anyref3 (; 9 ;) (result anyref)
+ (local $0 exnref)
+ (local.get $0)
+ )
+ (func $return_anyref4 (; 10 ;) (result anyref)
+ (ref.null)
+ )
+ (func $return_funcref (; 11 ;) (result funcref)
+ (ref.func $foo)
+ )
+ (func $return_funcref2 (; 12 ;) (result funcref)
+ (ref.null)
+ )
+ (func $return_exnref (; 13 ;) (result exnref)
+ (local $0 exnref)
+ (local.get $0)
+ )
+ (func $return_exnref2 (; 14 ;) (result exnref)
+ (ref.null)
+ )
+ (func $return_nullref (; 15 ;) (result nullref)
+ (local $0 nullref)
+ (local.get $0)
+ )
+ (func $return_anyref_returns (; 16 ;) (result anyref)
+ (local $0 anyref)
+ (local $1 exnref)
+ (return
+ (local.get $0)
+ )
+ )
+ (func $return_funcref_returns (; 17 ;) (result funcref)
+ (return
+ (ref.func $foo)
+ )
+ )
+ (func $return_exnref_returns (; 18 ;) (result exnref)
+ (local $0 exnref)
+ (return
+ (local.get $0)
+ )
+ )
+ (func $return_nullref_returns (; 19 ;) (result nullref)
+ (local $0 nullref)
+ (return
+ (local.get $0)
+ )
+ )
+)
+