diff options
Diffstat (limited to 'test')
28 files changed, 311 insertions, 15 deletions
diff --git a/test/dump/callindirect.txt b/test/dump/callindirect.txt index 08c47d98..f15a2e35 100644 --- a/test/dump/callindirect.txt +++ b/test/dump/callindirect.txt @@ -61,7 +61,7 @@ 000002b: 00 ; i32 literal 000002c: 11 ; call_indirect 000002d: 00 ; signature index -000002e: 00 ; call_indirect reserved +000002e: 00 ; table index 000002f: 0b ; end 0000026: 09 ; FIXUP func body size 0000024: 0b ; FIXUP section size diff --git a/test/dump/no-canonicalize.txt b/test/dump/no-canonicalize.txt index 35ba558b..bdec18af 100644 --- a/test/dump/no-canonicalize.txt +++ b/test/dump/no-canonicalize.txt @@ -119,7 +119,7 @@ 000007a: 01 ; local index 000007b: 11 ; call_indirect 000007c: 00 ; signature index -000007d: 00 ; call_indirect reserved +000007d: 00 ; table index 000007e: 1a ; drop 000007f: 0b ; end 0000071: 8a80 8080 00 ; FIXUP func body size diff --git a/test/dump/reference-types.txt b/test/dump/reference-types.txt new file mode 100644 index 00000000..dbae4d52 --- /dev/null +++ b/test/dump/reference-types.txt @@ -0,0 +1,104 @@ +;;; TOOL: run-objdump +;;; ARGS0: --enable-reference-types + +(module + (table $foo 1 anyref) + (table $bar 1 anyref) + (table $baz 1 anyfunc) + + (func (result anyref) + i32.const 0 + table.get $foo + ) + (func (result anyref) + i32.const 0 + table.get $bar + ) + + (func (param anyref) + i32.const 0 + get_local 0 + table.set $foo + ) + (func (param anyref) + i32.const 0 + get_local 0 + table.set $bar + ) + + (func (result i32) + i32.const 0 + ref.null + table.grow $foo + ) + (func (result i32) + i32.const 0 + ref.null + table.grow $bar + ) + + (func (param anyref) (result i32) + local.get 0 + ref.is_null + ) + + + (func (result i32) + table.size $foo + ) + (func (result i32) + table.size $bar + ) + (func (result i32) + table.size $baz + ) +) + +(;; STDOUT ;;; + +reference-types.wasm: file format wasm 0x1 + +Code Disassembly: + +000039 func[0]: + 00003a: 41 00 | i32.const 0 + 00003c: 25 00 | table.get 0 + 00003e: 0b | end +000040 func[1]: + 000041: 41 00 | i32.const 0 + 000043: 25 01 | table.get 1 + 000045: 0b | end +000047 func[2]: + 000048: 41 00 | i32.const 0 + 00004a: 20 00 | local.get 0 + 00004c: 26 00 | table.set 0 + 00004e: 0b | end +000050 func[3]: + 000051: 41 00 | i32.const 0 + 000053: 20 00 | local.get 0 + 000055: 26 01 | table.set 1 + 000057: 0b | end +000059 func[4]: + 00005a: 41 00 | i32.const 0 + 00005c: d0 | ref.null + 00005d: fc 0f 00 | table.grow 0 + 000060: 0b | end +000062 func[5]: + 000063: 41 00 | i32.const 0 + 000065: d0 | ref.null + 000066: fc 0f 01 | table.grow 1 + 000069: 0b | end +00006b func[6]: + 00006c: 20 00 | local.get 0 + 00006e: d1 | ref.is_null + 00006f: 0b | end +000071 func[7]: + 000072: fc 10 00 | table.size 0 + 000075: 0b | end +000077 func[8]: + 000078: fc 10 01 | table.size 1 + 00007b: 0b | end +00007d func[9]: + 00007e: fc 10 02 | table.size 2 + 000081: 0b | end +;;; STDOUT ;;) diff --git a/test/help/spectest-interp.txt b/test/help/spectest-interp.txt index 8ad66af4..2fa2f98a 100644 --- a/test/help/spectest-interp.txt +++ b/test/help/spectest-interp.txt @@ -21,6 +21,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) -V, --value-stack-size=SIZE Size in elements of the value stack -C, --call-stack-size=SIZE Size in elements of the call stack -t, --trace Trace execution diff --git a/test/help/wasm-interp.txt b/test/help/wasm-interp.txt index 77420472..6b3f27ac 100644 --- a/test/help/wasm-interp.txt +++ b/test/help/wasm-interp.txt @@ -32,6 +32,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) -V, --value-stack-size=SIZE Size in elements of the value stack -C, --call-stack-size=SIZE Size in elements of the call stack -t, --trace Trace execution diff --git a/test/help/wasm-validate.txt b/test/help/wasm-validate.txt index 4b1a45a8..3cb08431 100644 --- a/test/help/wasm-validate.txt +++ b/test/help/wasm-validate.txt @@ -21,6 +21,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) --no-debug-names Ignore debug names in the binary file --ignore-custom-section-errors Ignore errors in custom sections ;;; STDOUT ;;) diff --git a/test/help/wasm2wat.txt b/test/help/wasm2wat.txt index 38641fe1..f5bedf12 100644 --- a/test/help/wasm2wat.txt +++ b/test/help/wasm2wat.txt @@ -27,6 +27,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) --inline-exports Write all exports inline --inline-imports Write all imports inline --no-debug-names Ignore debug names in the binary file diff --git a/test/help/wast2json.txt b/test/help/wast2json.txt index 7b71d625..f6833d90 100644 --- a/test/help/wast2json.txt +++ b/test/help/wast2json.txt @@ -24,6 +24,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) -o, --output=FILE output wasm binary file -r, --relocatable Create a relocatable wasm binary (suitable for linking with e.g. lld) --no-canonicalize-leb128s Write all LEB128 sizes as 5-bytes instead of their minimal size diff --git a/test/help/wat-desugar.txt b/test/help/wat-desugar.txt index 383d10d1..f7d48d98 100644 --- a/test/help/wat-desugar.txt +++ b/test/help/wat-desugar.txt @@ -31,5 +31,6 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) --generate-names Give auto-generated names to non-named functions, types, etc. ;;; STDOUT ;;) diff --git a/test/help/wat2wasm.txt b/test/help/wat2wasm.txt index 853e1b92..f052ebad 100644 --- a/test/help/wat2wasm.txt +++ b/test/help/wat2wasm.txt @@ -31,6 +31,7 @@ options: --enable-multi-value Enable Multi-value --enable-tail-call Enable Tail-call support --enable-bulk-memory Enable Bulk-memory operations + --enable-reference-types Enable Reference types (anyref) -o, --output=FILE output wasm binary file -r, --relocatable Create a relocatable wasm binary (suitable for linking with e.g. lld) --no-canonicalize-leb128s Write all LEB128 sizes as 5-bytes instead of their minimal size diff --git a/test/interp/logging-all-opcodes.txt b/test/interp/logging-all-opcodes.txt index 85c308e8..f2c72f05 100644 --- a/test/interp/logging-all-opcodes.txt +++ b/test/interp/logging-all-opcodes.txt @@ -2631,7 +2631,7 @@ 0001a73: 01 ; i32 literal 0001a74: 11 ; call_indirect 0001a75: 00 ; signature index -0001a76: 00 ; call_indirect reserved +0001a76: 00 ; table index 0001a77: 0b ; end 0001a70: 07 ; FIXUP func body size ; function body 7 @@ -2648,7 +2648,7 @@ 0001a80: 01 ; i32 literal 0001a81: 13 ; return_call_indirect 0001a82: 00 ; signature index -0001a83: 00 ; return_call_indirect reserved +0001a83: 00 ; table index 0001a84: 0b ; end 0001a7d: 07 ; FIXUP func body size ; function body 9 @@ -8071,7 +8071,7 @@ BeginModule(version: 1) BeginFunctionBody(7, size:7) OnLocalDeclCount(0) OnI32ConstExpr(1 (0x1)) - OnCallIndirectExpr(sig_index: 0) + OnCallIndirectExpr(sig_index: 0, table_index: 0) EndFunctionBody(7) BeginFunctionBody(8, size:4) OnLocalDeclCount(0) @@ -8080,7 +8080,7 @@ BeginModule(version: 1) BeginFunctionBody(9, size:7) OnLocalDeclCount(0) OnI32ConstExpr(1 (0x1)) - OnReturnCallIndirectExpr(sig_index: 0) + OnReturnCallIndirectExpr(sig_index: 0, table_index: 0) EndFunctionBody(9) BeginFunctionBody(10, size:5) OnLocalDeclCount(0) diff --git a/test/parse/expr/reference-types-call-indirect.txt b/test/parse/expr/reference-types-call-indirect.txt new file mode 100644 index 00000000..bcb74296 --- /dev/null +++ b/test/parse/expr/reference-types-call-indirect.txt @@ -0,0 +1,18 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types + +(module + (table $foo 1 anyfunc) + (table $bar 1 anyfunc) + + (func (result i32) i32.const 0) + (func (result i32) i32.const 1) + + (func (result i32) + i32.const 0 + call_indirect (type 0) $foo) + + (func (result i32) + i32.const 0 + call_indirect (type 0) $bar) +) diff --git a/test/parse/expr/reference-types-named.txt b/test/parse/expr/reference-types-named.txt new file mode 100644 index 00000000..e9d1a63d --- /dev/null +++ b/test/parse/expr/reference-types-named.txt @@ -0,0 +1,21 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types + +(module + (table $foo 1 anyref) + (func (result anyref) + i32.const 0 + table.get $foo + ) + (func (param anyref) + i32.const 0 + get_local 0 + table.set $foo + ) + (func (result i32) + i32.const 0 + ref.null + table.grow $foo + ) +) + diff --git a/test/parse/expr/reference-types.txt b/test/parse/expr/reference-types.txt new file mode 100644 index 00000000..d46aaba3 --- /dev/null +++ b/test/parse/expr/reference-types.txt @@ -0,0 +1,55 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types + +(module + (table $foo 1 anyref) + (table $bar 1 anyref) + (table $baz 1 anyfunc) + + (func (result anyref) + i32.const 0 + table.get $foo + ) + (func (result anyref) + i32.const 0 + table.get $bar + ) + + (func (param anyref) + i32.const 0 + get_local 0 + table.set $foo + ) + (func (param anyref) + i32.const 0 + get_local 0 + table.set $bar + ) + + (func (result i32) + i32.const 0 + ref.null + table.grow $foo + ) + (func (result i32) + i32.const 0 + ref.null + table.grow $bar + ) + + (func (param anyref) (result i32) + local.get 0 + ref.is_null + ) + + + (func (result i32) + table.size $foo + ) + (func (result i32) + table.size $bar + ) + (func (result i32) + table.size $baz + ) +) diff --git a/test/parse/expr/table-get.txt b/test/parse/expr/table-get.txt new file mode 100644 index 00000000..ed2e7155 --- /dev/null +++ b/test/parse/expr/table-get.txt @@ -0,0 +1,8 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types +(module + (func (result anyref) + i32.const 0 + table.get 0) + + (table 1 anyref)) diff --git a/test/parse/expr/table-grow.txt b/test/parse/expr/table-grow.txt new file mode 100644 index 00000000..8b8fcc59 --- /dev/null +++ b/test/parse/expr/table-grow.txt @@ -0,0 +1,9 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types +(module + (func (result i32) + i32.const 0 + ref.null + table.grow 0) + + (table 1 anyref)) diff --git a/test/parse/expr/table-set.txt b/test/parse/expr/table-set.txt new file mode 100644 index 00000000..d441437e --- /dev/null +++ b/test/parse/expr/table-set.txt @@ -0,0 +1,9 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types +(module + (func (param anyref) + i32.const 0 + get_local 0 + table.set 0) + + (table 1 anyref)) diff --git a/test/parse/func/bad-local-binding-no-type.txt b/test/parse/func/bad-local-binding-no-type.txt index 9c1a3a88..029218e9 100644 --- a/test/parse/func/bad-local-binding-no-type.txt +++ b/test/parse/func/bad-local-binding-no-type.txt @@ -2,7 +2,7 @@ ;;; ERROR: 1 (module (func (local $n))) (;; STDERR ;;; -out/test/parse/func/bad-local-binding-no-type.txt:3:24: error: unexpected token ")", expected i32, i64, f32, f64 or v128. +out/test/parse/func/bad-local-binding-no-type.txt:3:24: error: unexpected token ")", expected i32, i64, f32, f64, v128 or anyref. (module (func (local $n))) ^ ;;; STDERR ;;) diff --git a/test/parse/func/bad-local-binding.txt b/test/parse/func/bad-local-binding.txt index 4aee0258..51110dfe 100644 --- a/test/parse/func/bad-local-binding.txt +++ b/test/parse/func/bad-local-binding.txt @@ -2,7 +2,7 @@ ;;; ERROR: 1 (module (func (local $foo $bar))) (;; STDERR ;;; -out/test/parse/func/bad-local-binding.txt:3:27: error: unexpected token "$bar", expected i32, i64, f32, f64 or v128. +out/test/parse/func/bad-local-binding.txt:3:27: error: unexpected token "$bar", expected i32, i64, f32, f64, v128 or anyref. (module (func (local $foo $bar))) ^^^^ ;;; STDERR ;;) diff --git a/test/parse/func/bad-param-binding.txt b/test/parse/func/bad-param-binding.txt index 323ad4b2..f813b23c 100644 --- a/test/parse/func/bad-param-binding.txt +++ b/test/parse/func/bad-param-binding.txt @@ -2,7 +2,7 @@ ;;; ERROR: 1 (module (func (param $bar $baz))) (;; STDERR ;;; -out/test/parse/func/bad-param-binding.txt:3:27: error: unexpected token "$baz", expected i32, i64, f32, f64 or v128. +out/test/parse/func/bad-param-binding.txt:3:27: error: unexpected token "$baz", expected i32, i64, f32, f64, v128 or anyref. (module (func (param $bar $baz))) ^^^^ ;;; STDERR ;;) diff --git a/test/parse/module/reference-types-disabled.txt b/test/parse/module/reference-types-disabled.txt new file mode 100644 index 00000000..10963352 --- /dev/null +++ b/test/parse/module/reference-types-disabled.txt @@ -0,0 +1,20 @@ +;;; TOOL: wat2wasm +;;; ERROR: 1 + +(module + (table $t 1 anyref) + (func + i32.const 0 + i32.const 0 + table.get $t + table.set $t + ) +) +(;; STDERR ;;; +out/test/parse/module/reference-types-disabled.txt:9:5: error: opcode not allowed: table.get + table.get $t + ^^^^^^^^^ +out/test/parse/module/reference-types-disabled.txt:10:5: error: opcode not allowed: table.set + table.set $t + ^^^^^^^^^ +;;; STDERR ;;) diff --git a/test/roundtrip/fold-reference-types.txt b/test/roundtrip/fold-reference-types.txt new file mode 100644 index 00000000..23412a5f --- /dev/null +++ b/test/roundtrip/fold-reference-types.txt @@ -0,0 +1,22 @@ +;;; TOOL: run-roundtrip +;;; ARGS: --stdout --fold-exprs --enable-reference-types + +(module + (table $t 1 anyref) + (func + i32.const 0 + i32.const 0 + table.get $t + table.set $t + ) +) +(;; STDOUT ;;; +(module + (type (;0;) (func)) + (func (;0;) (type 0) + (table.set 0 + (i32.const 0) + (table.get 0 + (i32.const 0)))) + (table (;0;) 1 anyref)) +;;; STDOUT ;;) diff --git a/test/roundtrip/generate-func-type-names.txt b/test/roundtrip/generate-func-type-names.txt index d5af88f7..7b9c177d 100644 --- a/test/roundtrip/generate-func-type-names.txt +++ b/test/roundtrip/generate-func-type-names.txt @@ -18,7 +18,7 @@ (func $f1 (type $t0)) (func $f2 (type $t1) (result i32) i32.const 0 - call_indirect (type $t0) + call_indirect (type $t0) $T0 i32.const 1) (table $T0 1 1 anyfunc) (elem $e0 (i32.const 0) $foo.bar)) diff --git a/test/roundtrip/generate-some-names.txt b/test/roundtrip/generate-some-names.txt index 4af66724..5ea9d620 100644 --- a/test/roundtrip/generate-some-names.txt +++ b/test/roundtrip/generate-some-names.txt @@ -45,7 +45,7 @@ drop i32.const 0 i32.const 1 - call_indirect (type $t0) + call_indirect (type $t0) $T0 drop local.get $param1 drop diff --git a/test/run-roundtrip.py b/test/run-roundtrip.py index cb871372..6b66ed7c 100755 --- a/test/run-roundtrip.py +++ b/test/run-roundtrip.py @@ -124,6 +124,7 @@ def main(args): parser.add_argument('--enable-multi-value', action='store_true') parser.add_argument('--enable-bulk-memory', action='store_true') parser.add_argument('--enable-tail-call', action='store_true') + parser.add_argument('--enable-reference-types', action='store_true') parser.add_argument('--inline-exports', action='store_true') parser.add_argument('--inline-imports', action='store_true') parser.add_argument('file', help='test file.') @@ -143,6 +144,7 @@ def main(args): '--enable-threads': options.enable_threads, '--enable-bulk-memory': options.enable_bulk_memory, '--enable-tail-call': options.enable_tail_call, + '--enable-reference-types': options.enable_reference_types, '--no-check': options.no_check, }) @@ -159,6 +161,7 @@ def main(args): '--enable-simd': options.enable_simd, '--enable-bulk-memory': options.enable_bulk_memory, '--enable-tail-call': options.enable_tail_call, + '--enable-reference-types': options.enable_reference_types, '--enable-threads': options.enable_threads, '--inline-exports': options.inline_exports, '--inline-imports': options.inline_imports, diff --git a/test/typecheck/bad-bulk-memory-no-table.txt b/test/typecheck/bad-bulk-memory-no-table.txt index 5d5ecc16..f7cad08e 100644 --- a/test/typecheck/bad-bulk-memory-no-table.txt +++ b/test/typecheck/bad-bulk-memory-no-table.txt @@ -10,19 +10,19 @@ ) ) (;; STDERR ;;; -out/test/typecheck/bad-bulk-memory-no-table.txt:7:41: error: table.init requires an imported or defined table. +out/test/typecheck/bad-bulk-memory-no-table.txt:7:41: error: table.init requires table 0 to be an imported or defined table. i32.const 0 i32.const 0 i32.const 0 table.init 0 ^^^^^^^^^^ out/test/typecheck/bad-bulk-memory-no-table.txt:7:52: error: elem_segment variable out of range (max 0) i32.const 0 i32.const 0 i32.const 0 table.init 0 ^ -out/test/typecheck/bad-bulk-memory-no-table.txt:8:5: error: elem.drop requires an imported or defined table. +out/test/typecheck/bad-bulk-memory-no-table.txt:8:5: error: elem.drop requires table 0 to be an imported or defined table. elem.drop 0 ^^^^^^^^^ out/test/typecheck/bad-bulk-memory-no-table.txt:8:15: error: elem_segment variable out of range (max 0) elem.drop 0 ^ -out/test/typecheck/bad-bulk-memory-no-table.txt:9:41: error: table.copy requires an imported or defined table. +out/test/typecheck/bad-bulk-memory-no-table.txt:9:41: error: table.copy requires table 0 to be an imported or defined table. i32.const 0 i32.const 0 i32.const 0 table.copy ^^^^^^^^^^ ;;; STDERR ;;) diff --git a/test/typecheck/bad-reference-types-no-table.txt b/test/typecheck/bad-reference-types-no-table.txt new file mode 100644 index 00000000..0c0449ee --- /dev/null +++ b/test/typecheck/bad-reference-types-no-table.txt @@ -0,0 +1,20 @@ +;;; TOOL: wat2wasm +;;; ARGS: --enable-reference-types +;;; ERROR: 1 + +(module + (func + i32.const 0 + i32.const 0 + table.get $t + table.set $t + ) +) +(;; STDERR ;;; +out/test/typecheck/bad-reference-types-no-table.txt:9:15: error: undefined table variable "$t" + table.get $t + ^^ +out/test/typecheck/bad-reference-types-no-table.txt:10:15: error: undefined table variable "$t" + table.set $t + ^^ +;;; STDERR ;;) diff --git a/test/typecheck/bad-returncallindirect-no-table.txt b/test/typecheck/bad-returncallindirect-no-table.txt index c9b8d3f0..24c7f808 100644 --- a/test/typecheck/bad-returncallindirect-no-table.txt +++ b/test/typecheck/bad-returncallindirect-no-table.txt @@ -9,7 +9,7 @@ return_call_indirect) ) (;; STDERR ;;; -out/test/typecheck/bad-returncallindirect-no-table.txt:9:5: error: found return_call_indirect operator, but no table +out/test/typecheck/bad-returncallindirect-no-table.txt:9:5: error: return_call_indirect requires table 0 to be an imported or defined table. return_call_indirect) ^^^^^^^^^^^^^^^^^^^^ ;;; STDERR ;;) |