summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAbbas Mashayekh <martianboy2005@gmail.com>2021-03-24 21:43:45 +0430
committerGitHub <noreply@github.com>2021-03-24 10:13:45 -0700
commitffac06650507ac413d60d72aadc1e33fb1f91ccf (patch)
treef581d02da66df8db2a775fc731d39baf15d96c82 /test
parent683c31381f5798016f683a6b42e2a8fad0f871cb (diff)
downloadbinaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.gz
binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.tar.bz2
binaryen-ffac06650507ac413d60d72aadc1e33fb1f91ccf.zip
[RT] Support expressions in element segments (#3666)
This PR adds support for `ref.null t` as a valid element segment item. The abbreviated format of `(elem ... func $f $g...)` is kept in both printing and binary emitting if all items are `ref.func`s. Public APIs aren't updated in this PR.
Diffstat (limited to 'test')
-rw-r--r--test/multi-table.wast6
-rw-r--r--test/multi-table.wast.from-wast5
-rw-r--r--test/multi-table.wast.fromBinary5
-rw-r--r--test/multi-table.wast.fromBinary.noDebugInfo5
-rw-r--r--test/passes/converge_O3_metrics.bin.txt6
-rw-r--r--test/passes/func-metrics.txt3
-rw-r--r--test/passes/fuzz_metrics_noprint.bin.txt3
-rw-r--r--test/passes/metrics_all-features.txt3
-rw-r--r--test/spec/call_indirect_refnull.wast12
9 files changed, 39 insertions, 9 deletions
diff --git a/test/multi-table.wast b/test/multi-table.wast
index 378d4018a..cbfa369e0 100644
--- a/test/multi-table.wast
+++ b/test/multi-table.wast
@@ -1,6 +1,7 @@
(module
(import "a" "b" (table $t1 1 10 funcref))
(table $t2 3 3 funcref)
+ (table $t3 4 4 funcref)
;; add to $t1
(elem (i32.const 0) $f)
@@ -9,7 +10,10 @@
(elem (table $t2) (i32.const 0) func $f)
(elem $activeNonZeroOffset (table $t2) (offset (i32.const 1)) func $f $g)
- (elem $passive func $f $g)
+ (elem $e3-1 (table $t3) (i32.const 0) funcref (ref.func $f) (ref.null func))
+ (elem $e3-2 (table $t3) (offset (i32.const 2)) funcref (item ref.func $f) (item (ref.func $g)))
+
+ (elem $passive funcref (item ref.func $f) (item (ref.func $g)) (ref.null func))
(elem $empty func)
(elem $declarative declare func $h)
diff --git a/test/multi-table.wast.from-wast b/test/multi-table.wast.from-wast
index f60bab8cb..80c081354 100644
--- a/test/multi-table.wast.from-wast
+++ b/test/multi-table.wast.from-wast
@@ -5,7 +5,10 @@
(table $t2 3 3 funcref)
(elem (table $t2) (i32.const 0) func $f)
(elem $activeNonZeroOffset (table $t2) (i32.const 1) func $f $g)
- (elem $passive func $f $g)
+ (table $t3 4 4 funcref)
+ (elem $e3-1 (table $t3) (i32.const 0) funcref (ref.func $f) (ref.null func))
+ (elem $e3-2 (table $t3) (i32.const 2) func $f $g)
+ (elem $passive funcref (ref.func $f) (ref.func $g) (ref.null func))
(elem declare func $h)
(func $f
(drop
diff --git a/test/multi-table.wast.fromBinary b/test/multi-table.wast.fromBinary
index 13604e69d..9918b6183 100644
--- a/test/multi-table.wast.fromBinary
+++ b/test/multi-table.wast.fromBinary
@@ -5,7 +5,10 @@
(table $t2 3 3 funcref)
(elem (table $t2) (i32.const 0) func $f)
(elem $activeNonZeroOffset (table $t2) (i32.const 1) func $f $g)
- (elem $passive func $f $g)
+ (table $t3 4 4 funcref)
+ (elem $e3-1 (table $t3) (i32.const 0) funcref (ref.func $f) (ref.null func))
+ (elem $e3-2 (table $t3) (i32.const 2) func $f $g)
+ (elem $passive funcref (ref.func $f) (ref.func $g) (ref.null func))
(elem declare func $h)
(func $f
(drop
diff --git a/test/multi-table.wast.fromBinary.noDebugInfo b/test/multi-table.wast.fromBinary.noDebugInfo
index 77e2ea439..638ee7329 100644
--- a/test/multi-table.wast.fromBinary.noDebugInfo
+++ b/test/multi-table.wast.fromBinary.noDebugInfo
@@ -5,7 +5,10 @@
(table $0 3 3 funcref)
(elem (table $0) (i32.const 0) func $0)
(elem (table $0) (i32.const 1) func $0 $1)
- (elem func $0 $1)
+ (table $1 4 4 funcref)
+ (elem (table $1) (i32.const 0) funcref (ref.func $0) (ref.null func))
+ (elem (table $1) (i32.const 2) func $0 $1)
+ (elem funcref (ref.func $0) (ref.func $1) (ref.null func))
(elem declare func $2)
(func $0
(drop
diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt
index 2df4a4b0b..4c1bed30d 100644
--- a/test/passes/converge_O3_metrics.bin.txt
+++ b/test/passes/converge_O3_metrics.bin.txt
@@ -7,7 +7,7 @@ total
[memory-data] : 28
[table-data] : 429
[tables] : 0
- [total] : 129
+ [total] : 558
[vars] : 4
Binary : 12
Block : 8
@@ -23,6 +23,7 @@ total
LocalGet : 18
LocalSet : 7
Loop : 1
+ RefFunc : 429
Store : 5
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
@@ -249,7 +250,7 @@ total
[memory-data] : 28
[table-data] : 429
[tables] : 0
- [total] : 129
+ [total] : 558
[vars] : 4
Binary : 12
Block : 8
@@ -265,6 +266,7 @@ total
LocalGet : 18
LocalSet : 7
Loop : 1
+ RefFunc : 429
Store : 5
(module
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
diff --git a/test/passes/func-metrics.txt b/test/passes/func-metrics.txt
index 1ca5d2fd9..61d97ddad 100644
--- a/test/passes/func-metrics.txt
+++ b/test/passes/func-metrics.txt
@@ -7,8 +7,9 @@ global
[memory-data] : 9
[table-data] : 3
[tables] : 1
- [total] : 3
+ [total] : 6
Const : 3
+ RefFunc : 3
func: empty
[binary-bytes] : 3
[total] : 1
diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt
index eb24adfa4..d2b5e37e9 100644
--- a/test/passes/fuzz_metrics_noprint.bin.txt
+++ b/test/passes/fuzz_metrics_noprint.bin.txt
@@ -7,7 +7,7 @@ total
[memory-data] : 4
[table-data] : 17
[tables] : 1
- [total] : 5797
+ [total] : 5814
[vars] : 160
Binary : 467
Block : 810
@@ -24,6 +24,7 @@ total
LocalSet : 292
Loop : 127
Nop : 69
+ RefFunc : 17
Return : 259
Select : 53
Store : 53
diff --git a/test/passes/metrics_all-features.txt b/test/passes/metrics_all-features.txt
index ae746355d..14c1bc72d 100644
--- a/test/passes/metrics_all-features.txt
+++ b/test/passes/metrics_all-features.txt
@@ -7,13 +7,14 @@ total
[memory-data] : 9
[table-data] : 3
[tables] : 1
- [total] : 27
+ [total] : 30
[vars] : 1
Binary : 1
Block : 1
Const : 15
Drop : 6
If : 4
+ RefFunc : 3
(module
(type $0 (func (param i32)))
(type $i32_i32_=>_none (func (param i32 i32)))
diff --git a/test/spec/call_indirect_refnull.wast b/test/spec/call_indirect_refnull.wast
new file mode 100644
index 000000000..f1b4f5978
--- /dev/null
+++ b/test/spec/call_indirect_refnull.wast
@@ -0,0 +1,12 @@
+(module
+ (table $t 1 1 funcref)
+ (elem (table $t) (i32.const 0) funcref (ref.null func))
+
+ (func $call-refnull (export "call-refnull") (result f32)
+ (call_indirect (result f32) (i32.const 0))
+ )
+)
+(assert_trap
+ (invoke "call-refnull")
+ "uninitialized table element"
+) \ No newline at end of file