summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/empty_imported_table.wast.from-wast4
-rw-r--r--test/empty_table.wast.from-wast4
-rw-r--r--test/example/c-api-unused-mem.txt14
-rw-r--r--test/hello_world.wast.from-wast11
-rw-r--r--test/imported_memory.wast.from-wast4
-rw-r--r--test/imported_memory_growth.wast.from-wast4
-rw-r--r--test/kitchen_sink.wast.from-wast667
-rw-r--r--test/memory-import.wast.from-wast9
-rw-r--r--test/min.wast.from-wast57
-rw-r--r--test/passes/remove-unused-brs.txt21
-rw-r--r--test/passes/remove-unused-brs.wast16
-rw-r--r--test/passes/remove-unused-names_merge-blocks.txt14
-rw-r--r--test/passes/remove-unused-names_merge-blocks.wast13
-rw-r--r--test/passes/remove-unused-names_remove-unused-brs_vacuum.txt116
-rw-r--r--test/passes/remove-unused-names_remove-unused-brs_vacuum.wast131
-rw-r--r--test/passes/remove-unused-names_vacuum.txt5
-rw-r--r--test/passes/remove-unused-names_vacuum.wast9
-rw-r--r--test/passes/vacuum_remove-unused-names_merge-blocks.txt12
-rw-r--r--test/passes/vacuum_remove-unused-names_merge-blocks.wast16
-rw-r--r--test/reg_switch.wast.from-wast14
-rw-r--r--test/table-import.wast.from-wast9
-rw-r--r--test/unit.wast78
-rw-r--r--test/unit.wast.from-wast560
-rw-r--r--test/unit.wast.fromBinary138
-rw-r--r--test/unit.wast.fromBinary.noDebugInfo138
25 files changed, 2062 insertions, 2 deletions
diff --git a/test/empty_imported_table.wast.from-wast b/test/empty_imported_table.wast.from-wast
new file mode 100644
index 000000000..7662c068e
--- /dev/null
+++ b/test/empty_imported_table.wast.from-wast
@@ -0,0 +1,4 @@
+(module
+ (import "env" "table" (table 0 0 anyfunc))
+ (memory $0 0)
+)
diff --git a/test/empty_table.wast.from-wast b/test/empty_table.wast.from-wast
new file mode 100644
index 000000000..17ce9d6b2
--- /dev/null
+++ b/test/empty_table.wast.from-wast
@@ -0,0 +1,4 @@
+(module
+ (table 0 0 anyfunc)
+ (memory $0 0)
+)
diff --git a/test/example/c-api-unused-mem.txt b/test/example/c-api-unused-mem.txt
index cae196ea7..52742f476 100644
--- a/test/example/c-api-unused-mem.txt
+++ b/test/example/c-api-unused-mem.txt
@@ -46,7 +46,7 @@
(call $main)
)
)
-195
+207
(module
(type $0 (func))
(type $1 (func))
@@ -67,7 +67,9 @@
)
(block $label$2
(br $label$1)
+ (unreachable)
)
+ (unreachable)
)
(block $label$3
(block $label$4
@@ -75,7 +77,9 @@
)
(block $label$6
(br $label$4)
+ (unreachable)
)
+ (unreachable)
)
(block $label$7
(block $label$8
@@ -84,10 +88,18 @@
(get_local $var$0)
)
(return)
+ (unreachable)
)
+ (unreachable)
+ (unreachable)
)
+ (unreachable)
+ (unreachable)
)
+ (unreachable)
+ (unreachable)
)
+ (unreachable)
)
(func $__wasm_start (type $1)
(block $label$0
diff --git a/test/hello_world.wast.from-wast b/test/hello_world.wast.from-wast
new file mode 100644
index 000000000..44a1f9336
--- /dev/null
+++ b/test/hello_world.wast.from-wast
@@ -0,0 +1,11 @@
+(module
+ (type $0 (func (param i32 i32) (result i32)))
+ (memory $0 256 256)
+ (export "add" (func $add))
+ (func $add (type $0) (param $x i32) (param $y i32) (result i32)
+ (i32.add
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+)
diff --git a/test/imported_memory.wast.from-wast b/test/imported_memory.wast.from-wast
new file mode 100644
index 000000000..790ffbbfa
--- /dev/null
+++ b/test/imported_memory.wast.from-wast
@@ -0,0 +1,4 @@
+(module
+ (import "env" "memory" (memory $0 256 256))
+ (import "env" "table" (table 256 256 anyfunc))
+)
diff --git a/test/imported_memory_growth.wast.from-wast b/test/imported_memory_growth.wast.from-wast
new file mode 100644
index 000000000..a6e99fe85
--- /dev/null
+++ b/test/imported_memory_growth.wast.from-wast
@@ -0,0 +1,4 @@
+(module
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 256 anyfunc))
+)
diff --git a/test/kitchen_sink.wast.from-wast b/test/kitchen_sink.wast.from-wast
new file mode 100644
index 000000000..7598ee989
--- /dev/null
+++ b/test/kitchen_sink.wast.from-wast
@@ -0,0 +1,667 @@
+(module
+ (type $0 (func (result i32)))
+ (memory $0 4096 4096)
+ (data (i32.const 1026) "\14\00")
+ (func $kitchensink (type $0) (result i32)
+ (block $block0 i32
+ (drop
+ (i32.add
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.sub
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.mul
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.div_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.div_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.rem_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.rem_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.and
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.or
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.xor
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.shl
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.shr_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.shr_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.eq
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.ne
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.lt_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.le_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.lt_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.le_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.gt_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.ge_s
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.gt_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.ge_u
+ (i32.const 10)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.clz
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.ctz
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i32.popcnt
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i64.add
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.sub
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.mul
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.div_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.div_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.rem_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.rem_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.and
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.or
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.xor
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.shl
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.shr_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.shr_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.eq
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.ne
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.lt_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.le_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.lt_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.le_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.gt_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.ge_s
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.gt_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.ge_u
+ (i64.const 100)
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.clz
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.ctz
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.popcnt
+ (i64.const 100)
+ )
+ )
+ (drop
+ (f32.add
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.sub
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.mul
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.div
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.min
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.max
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.abs
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.neg
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.copysign
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.ceil
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.floor
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.trunc
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.nearest
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.sqrt
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.eq
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.ne
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.lt
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.le
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.gt
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f32.ge
+ (f32.const 10)
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f64.add
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.sub
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.mul
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.div
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.min
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.max
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.abs
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.neg
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.copysign
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.ceil
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.floor
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.trunc
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.nearest
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.sqrt
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.eq
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.ne
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.lt
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.le
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.gt
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f64.ge
+ (f64.const 10)
+ (f64.const 10)
+ )
+ )
+ (drop
+ (i32.trunc_s/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (i32.trunc_s/f64
+ (f64.const 10)
+ )
+ )
+ (drop
+ (i32.trunc_u/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (i32.trunc_u/f64
+ (f64.const 10)
+ )
+ )
+ (drop
+ (i32.wrap/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i64.trunc_s/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (i64.trunc_s/f64
+ (f64.const 10)
+ )
+ )
+ (drop
+ (i64.trunc_u/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (i64.trunc_u/f64
+ (f64.const 10)
+ )
+ )
+ (drop
+ (i64.extend_s/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (i64.extend_u/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f32.convert_s/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f32.convert_u/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f32.convert_s/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (f32.convert_u/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (f32.demote/f64
+ (f64.const 10)
+ )
+ )
+ (drop
+ (f32.reinterpret/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f64.convert_s/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f64.convert_u/i32
+ (i32.const 10)
+ )
+ )
+ (drop
+ (f64.convert_s/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (f64.convert_u/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (f64.promote/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (f64.reinterpret/i64
+ (i64.const 100)
+ )
+ )
+ (drop
+ (i32.reinterpret/f32
+ (f32.const 10)
+ )
+ )
+ (drop
+ (i64.reinterpret/f64
+ (f64.const 10)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/memory-import.wast.from-wast b/test/memory-import.wast.from-wast
new file mode 100644
index 000000000..d7e6e3770
--- /dev/null
+++ b/test/memory-import.wast.from-wast
@@ -0,0 +1,9 @@
+(module
+ (type $0 (func (result i32)))
+ (import "env" "memory" (memory $0 1 1))
+ (func $foo (type $0) (result i32)
+ (i32.load offset=13
+ (i32.const 37)
+ )
+ )
+)
diff --git a/test/min.wast.from-wast b/test/min.wast.from-wast
new file mode 100644
index 000000000..28a1b1b89
--- /dev/null
+++ b/test/min.wast.from-wast
@@ -0,0 +1,57 @@
+(module
+ (type $0 (func (param f32) (result f32)))
+ (type $1 (func (param i32 i32) (result f32)))
+ (type $2 (func (param i32) (result i32)))
+ (type $3 (func (param i32 i32 i32) (result i32)))
+ (memory $0 256 256)
+ (export "floats" (func $floats))
+ (func $floats (type $0) (param $f f32) (result f32)
+ (local $t f32)
+ (f32.add
+ (get_local $t)
+ (get_local $f)
+ )
+ )
+ (func $neg (type $1) (param $k i32) (param $p i32) (result f32)
+ (local $n f32)
+ (tee_local $n
+ (f32.neg
+ (block $block0 f32
+ (i32.store
+ (get_local $k)
+ (get_local $p)
+ )
+ (f32.load
+ (get_local $k)
+ )
+ )
+ )
+ )
+ )
+ (func $littleswitch (type $2) (param $x i32) (result i32)
+ (block $topmost i32
+ (block $switch-case$2
+ (block $switch-case$1
+ (br_table $switch-case$1 $switch-case$2 $switch-case$1
+ (i32.sub
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ )
+ (br $topmost
+ (i32.const 1)
+ )
+ )
+ (br $topmost
+ (i32.const 2)
+ )
+ (i32.const 0)
+ )
+ )
+ (func $f1 (type $3) (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32)
+ (block $topmost i32
+ (get_local $i3)
+ )
+ )
+)
diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt
index b95ace90d..b682fcf46 100644
--- a/test/passes/remove-unused-brs.txt
+++ b/test/passes/remove-unused-brs.txt
@@ -328,7 +328,7 @@
)
)
(if
- (block $block6 i32
+ (block $block6
(block $block15
(drop
(i32.const 2)
@@ -937,4 +937,23 @@
)
)
)
+ (func $loop-if (type $2) (result i32)
+ (block $outer i32
+ (loop $typed
+ (br_if $typed
+ (i32.eqz
+ (i32.const 2)
+ )
+ )
+ (block $block
+ (drop
+ (call $loop-if)
+ )
+ (br $outer
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast
index 8b0ad357b..40ca5f520 100644
--- a/test/passes/remove-unused-brs.wast
+++ b/test/passes/remove-unused-brs.wast
@@ -831,5 +831,21 @@
)
)
)
+ (func $loop-if (result i32)
+ (block $outer i32
+ (loop $typed i32
+ ;; we can move the br after us into our if-else, which means we are the final
+ ;; element in the block,
+ (if
+ (i32.const 2)
+ (block
+ (drop (call $loop-if))
+ (br $outer (i32.const 0))
+ )
+ )
+ (br $typed)
+ )
+ )
+ )
)
diff --git a/test/passes/remove-unused-names_merge-blocks.txt b/test/passes/remove-unused-names_merge-blocks.txt
index 413fe32c2..7f253089c 100644
--- a/test/passes/remove-unused-names_merge-blocks.txt
+++ b/test/passes/remove-unused-names_merge-blocks.txt
@@ -3,6 +3,7 @@
(type $ii (func (param i32 i32)))
(type $iii (func (param i32 i32 i32)))
(type $3 (func))
+ (type $4 (func (result i32)))
(table 1 1 anyfunc)
(elem (i32.const 0) $call-i)
(memory $0 256 256)
@@ -737,4 +738,17 @@
)
)
)
+ (func $return-different-type (type $4) (result i32)
+ (drop
+ (i32.const 2)
+ )
+ (drop
+ (f64.abs
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (unreachable)
+ )
)
diff --git a/test/passes/remove-unused-names_merge-blocks.wast b/test/passes/remove-unused-names_merge-blocks.wast
index 2127f4cef..d41ff5fa4 100644
--- a/test/passes/remove-unused-names_merge-blocks.wast
+++ b/test/passes/remove-unused-names_merge-blocks.wast
@@ -901,4 +901,17 @@
)
)
)
+ (func $return-different-type (result i32)
+ (drop
+ (f64.abs
+ (return
+ (block i32 ;; when we flip the block out, it should have an ok type for the (dead) f64 op
+ (drop (i32.const 2))
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (unreachable)
+ )
)
diff --git a/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt b/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt
new file mode 100644
index 000000000..2475ad335
--- /dev/null
+++ b/test/passes/remove-unused-names_remove-unused-brs_vacuum.txt
@@ -0,0 +1,116 @@
+(module
+ (type $0 (func (param i32 i32 i32) (result i32)))
+ (type $1 (func (param f64) (result i32)))
+ (type $2 (func (param i32 i32) (result i32)))
+ (type $3 (func (param i32) (result i32)))
+ (type $4 (func (param i32)))
+ (type $5 (func (result i32)))
+ (type $6 (func))
+ (type $7 (func (param i32 i32)))
+ (type $8 (func (param i64 i32 i32)))
+ (type $9 (func (param i64 i64) (result i64)))
+ (type $10 (func (param i32 i32 i32 i32 i32) (result i32)))
+ (type $11 (func (param i32 i32 i32)))
+ (type $12 (func (param i64 i32) (result i32)))
+ (type $13 (func (param i32 i32 i32 i32 i32)))
+ (type $14 (func (param f64 i32) (result f64)))
+ (type $15 (func (param i32 i32 i32 i32) (result i32)))
+ (type $FUNCSIG$i (func (result i32)))
+ (type $FUNCSIG$vi (func (param i32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$iii (func (param i32 i32) (result i32)))
+ (type $FUNCSIG$vii (func (param i32 i32)))
+ (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
+ (type $FUNCSIG$id (func (param f64) (result i32)))
+ (import "env" "DYNAMICTOP_PTR" (global $import$0 i32))
+ (import "env" "tempDoublePtr" (global $import$1 i32))
+ (import "env" "ABORT" (global $import$2 i32))
+ (import "env" "STACKTOP" (global $import$3 i32))
+ (import "env" "STACK_MAX" (global $import$4 i32))
+ (import "global" "NaN" (global $import$5 f64))
+ (import "global" "Infinity" (global $import$6 f64))
+ (import "env" "enlargeMemory" (func $import$7 (result i32)))
+ (import "env" "getTotalMemory" (func $import$8 (result i32)))
+ (import "env" "abortOnCannotGrowMemory" (func $import$9 (result i32)))
+ (import "env" "abortStackOverflow" (func $import$10 (param i32)))
+ (import "env" "nullFunc_ii" (func $import$11 (param i32)))
+ (import "env" "nullFunc_iiii" (func $import$12 (param i32)))
+ (import "env" "nullFunc_vi" (func $import$13 (param i32)))
+ (import "env" "_pthread_cleanup_pop" (func $import$14 (param i32)))
+ (import "env" "___lock" (func $import$15 (param i32)))
+ (import "env" "_abort" (func $import$16))
+ (import "env" "___setErrNo" (func $import$17 (param i32)))
+ (import "env" "___syscall6" (func $import$18 (param i32 i32) (result i32)))
+ (import "env" "___syscall140" (func $import$19 (param i32 i32) (result i32)))
+ (import "env" "_pthread_cleanup_push" (func $import$20 (param i32 i32)))
+ (import "env" "_emscripten_memcpy_big" (func $import$21 (param i32 i32 i32) (result i32)))
+ (import "env" "___syscall54" (func $import$22 (param i32 i32) (result i32)))
+ (import "env" "___unlock" (func $import$23 (param i32)))
+ (import "env" "___syscall146" (func $import$24 (param i32 i32) (result i32)))
+ (import "asm2wasm" "f64-to-int" (func $import$25 (param f64) (result i32)))
+ (import "asm2wasm" "i32s-div" (func $import$26 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32s-rem" (func $import$27 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32u-rem" (func $import$28 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32u-div" (func $import$29 (param i32 i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 18 18 anyfunc))
+ (import "env" "memoryBase" (global $import$32 i32))
+ (import "env" "tableBase" (global $import$33 i32))
+ (global $global$0 (mut i32) (get_global $import$0))
+ (global $global$1 (mut i32) (get_global $import$1))
+ (global $global$2 (mut i32) (get_global $import$2))
+ (global $global$3 (mut i32) (get_global $import$3))
+ (global $global$4 (mut i32) (get_global $import$4))
+ (global $global$5 (mut i32) (i32.const 0))
+ (global $global$6 (mut i32) (i32.const 0))
+ (global $global$7 (mut i32) (i32.const 0))
+ (global $global$8 (mut i32) (i32.const 0))
+ (global $global$9 (mut f64) (get_global $import$5))
+ (global $global$10 (mut f64) (get_global $import$6))
+ (global $global$11 (mut i32) (i32.const 0))
+ (global $global$12 (mut i32) (i32.const 0))
+ (global $global$13 (mut i32) (i32.const 0))
+ (global $global$14 (mut i32) (i32.const 0))
+ (global $global$15 (mut f64) (f64.const 0))
+ (global $global$16 (mut i32) (i32.const 0))
+ (global $global$17 (mut i32) (i32.const 0))
+ (global $global$18 (mut i32) (i32.const 0))
+ (global $global$19 (mut f64) (f64.const 0))
+ (global $global$20 (mut i32) (i32.const 0))
+ (global $global$21 (mut f32) (f32.const 0))
+ (global $global$22 (mut f32) (f32.const 0))
+ (func $27 (type $13) (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) (param $var$3 i32) (param $var$4 i32)
+ (local $var$5 i32)
+ (local $var$6 i32)
+ (local $var$7 i32)
+ (local $var$8 i32)
+ (block $label$3
+ (if
+ (get_local $var$4)
+ (block
+ (if
+ (i32.eqz
+ (get_local $var$8)
+ )
+ (if
+ (i32.eqz
+ (get_local $var$6)
+ )
+ (br $label$3)
+ )
+ )
+ (drop
+ (call $23
+ (get_local $var$7)
+ (get_local $var$4)
+ (get_local $var$0)
+ )
+ )
+ )
+ )
+ )
+ )
+ (func $23 (type $0) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
+ (unreachable)
+ )
+)
diff --git a/test/passes/remove-unused-names_remove-unused-brs_vacuum.wast b/test/passes/remove-unused-names_remove-unused-brs_vacuum.wast
new file mode 100644
index 000000000..5a0ec5114
--- /dev/null
+++ b/test/passes/remove-unused-names_remove-unused-brs_vacuum.wast
@@ -0,0 +1,131 @@
+(module
+ (type $0 (func (param i32 i32 i32) (result i32)))
+ (type $1 (func (param f64) (result i32)))
+ (type $2 (func (param i32 i32) (result i32)))
+ (type $3 (func (param i32) (result i32)))
+ (type $4 (func (param i32)))
+ (type $5 (func (result i32)))
+ (type $6 (func))
+ (type $7 (func (param i32 i32)))
+ (type $8 (func (param i64 i32 i32)))
+ (type $9 (func (param i64 i64) (result i64)))
+ (type $10 (func (param i32 i32 i32 i32 i32) (result i32)))
+ (type $11 (func (param i32 i32 i32)))
+ (type $12 (func (param i64 i32) (result i32)))
+ (type $13 (func (param i32 i32 i32 i32 i32)))
+ (type $14 (func (param f64 i32) (result f64)))
+ (type $15 (func (param i32 i32 i32 i32) (result i32)))
+ (import "env" "DYNAMICTOP_PTR" (global $import$0 i32))
+ (import "env" "tempDoublePtr" (global $import$1 i32))
+ (import "env" "ABORT" (global $import$2 i32))
+ (import "env" "STACKTOP" (global $import$3 i32))
+ (import "env" "STACK_MAX" (global $import$4 i32))
+ (import "global" "NaN" (global $import$5 f64))
+ (import "global" "Infinity" (global $import$6 f64))
+ (import "env" "enlargeMemory" (func $import$7 (result i32)))
+ (import "env" "getTotalMemory" (func $import$8 (result i32)))
+ (import "env" "abortOnCannotGrowMemory" (func $import$9 (result i32)))
+ (import "env" "abortStackOverflow" (func $import$10 (param i32)))
+ (import "env" "nullFunc_ii" (func $import$11 (param i32)))
+ (import "env" "nullFunc_iiii" (func $import$12 (param i32)))
+ (import "env" "nullFunc_vi" (func $import$13 (param i32)))
+ (import "env" "_pthread_cleanup_pop" (func $import$14 (param i32)))
+ (import "env" "___lock" (func $import$15 (param i32)))
+ (import "env" "_abort" (func $import$16))
+ (import "env" "___setErrNo" (func $import$17 (param i32)))
+ (import "env" "___syscall6" (func $import$18 (param i32 i32) (result i32)))
+ (import "env" "___syscall140" (func $import$19 (param i32 i32) (result i32)))
+ (import "env" "_pthread_cleanup_push" (func $import$20 (param i32 i32)))
+ (import "env" "_emscripten_memcpy_big" (func $import$21 (param i32 i32 i32) (result i32)))
+ (import "env" "___syscall54" (func $import$22 (param i32 i32) (result i32)))
+ (import "env" "___unlock" (func $import$23 (param i32)))
+ (import "env" "___syscall146" (func $import$24 (param i32 i32) (result i32)))
+ (import "asm2wasm" "f64-to-int" (func $import$25 (param f64) (result i32)))
+ (import "asm2wasm" "i32s-div" (func $import$26 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32s-rem" (func $import$27 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32u-rem" (func $import$28 (param i32 i32) (result i32)))
+ (import "asm2wasm" "i32u-div" (func $import$29 (param i32 i32) (result i32)))
+ (import "env" "memory" (memory $0 256))
+ (import "env" "table" (table 18 18 anyfunc))
+ (import "env" "memoryBase" (global $import$32 i32))
+ (import "env" "tableBase" (global $import$33 i32))
+ (global $global$0 (mut i32) (get_global $import$0))
+ (global $global$1 (mut i32) (get_global $import$1))
+ (global $global$2 (mut i32) (get_global $import$2))
+ (global $global$3 (mut i32) (get_global $import$3))
+ (global $global$4 (mut i32) (get_global $import$4))
+ (global $global$5 (mut i32) (i32.const 0))
+ (global $global$6 (mut i32) (i32.const 0))
+ (global $global$7 (mut i32) (i32.const 0))
+ (global $global$8 (mut i32) (i32.const 0))
+ (global $global$9 (mut f64) (get_global $import$5))
+ (global $global$10 (mut f64) (get_global $import$6))
+ (global $global$11 (mut i32) (i32.const 0))
+ (global $global$12 (mut i32) (i32.const 0))
+ (global $global$13 (mut i32) (i32.const 0))
+ (global $global$14 (mut i32) (i32.const 0))
+ (global $global$15 (mut f64) (f64.const 0))
+ (global $global$16 (mut i32) (i32.const 0))
+ (global $global$17 (mut i32) (i32.const 0))
+ (global $global$18 (mut i32) (i32.const 0))
+ (global $global$19 (mut f64) (f64.const 0))
+ (global $global$20 (mut i32) (i32.const 0))
+ (global $global$21 (mut f32) (f32.const 0))
+ (global $global$22 (mut f32) (f32.const 0))
+ (func $27 (type $13) (param $var$0 i32) (param $var$1 i32) (param $var$2 i32) (param $var$3 i32) (param $var$4 i32)
+ (local $var$5 i32)
+ (local $var$6 i32)
+ (local $var$7 i32)
+ (local $var$8 i32)
+ (block $label$0
+ (block $label$1
+ (block $label$3
+ (if
+ (get_local $var$4)
+ (block $label$4
+ (if
+ (get_local $var$8)
+ (block $label$7
+ (loop $label$8
+ (block $label$9
+ (if
+ (get_local $var$3)
+ (block $label$12 ;; these empty blocks must never be unreachable-typed
+ )
+ (block $label$13
+ (br $label$9)
+ )
+ )
+ (br $label$8)
+ )
+ )
+ )
+ (block $label$16
+ (if
+ (get_local $var$6)
+ (block $label$17
+ )
+ (block $label$18
+ (br $label$3)
+ )
+ )
+ )
+ )
+ (drop
+ (call $23
+ (get_local $var$7)
+ (get_local $var$4)
+ (get_local $var$0)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (func $23 (param i32) (param i32) (param i32) (result i32)
+ (unreachable)
+ )
+)
+
diff --git a/test/passes/remove-unused-names_vacuum.txt b/test/passes/remove-unused-names_vacuum.txt
index 4da159f92..dc6ab403a 100644
--- a/test/passes/remove-unused-names_vacuum.txt
+++ b/test/passes/remove-unused-names_vacuum.txt
@@ -5,4 +5,9 @@
(local $label i32)
(unreachable)
)
+ (func $return-i32-but-body-is-unreachable4 (type $0) (result i32)
+ (local $label i32)
+ (unreachable)
+ (i32.const 0)
+ )
)
diff --git a/test/passes/remove-unused-names_vacuum.wast b/test/passes/remove-unused-names_vacuum.wast
index 04b08c332..694d95cfd 100644
--- a/test/passes/remove-unused-names_vacuum.wast
+++ b/test/passes/remove-unused-names_vacuum.wast
@@ -7,5 +7,14 @@
)
)
)
+ (func $return-i32-but-body-is-unreachable4 (result i32)
+ (local $label i32)
+ (block ;; without a name here, vaccum had a too-eager bug
+ (loop $while-in$1
+ (br $while-in$1)
+ )
+ )
+ (i32.const 0)
+ )
)
diff --git a/test/passes/vacuum_remove-unused-names_merge-blocks.txt b/test/passes/vacuum_remove-unused-names_merge-blocks.txt
new file mode 100644
index 000000000..a351c443b
--- /dev/null
+++ b/test/passes/vacuum_remove-unused-names_merge-blocks.txt
@@ -0,0 +1,12 @@
+(module
+ (type $0 (func (param i32) (result i32)))
+ (memory $0 0)
+ (func $return-block (type $0) (param $x i32) (result i32)
+ (set_local $x
+ (get_local $x)
+ )
+ (return
+ (get_local $x)
+ )
+ )
+)
diff --git a/test/passes/vacuum_remove-unused-names_merge-blocks.wast b/test/passes/vacuum_remove-unused-names_merge-blocks.wast
new file mode 100644
index 000000000..79ffa1d9f
--- /dev/null
+++ b/test/passes/vacuum_remove-unused-names_merge-blocks.wast
@@ -0,0 +1,16 @@
+(module
+ ;; vacuum and remove-unused names leave us with a return at the top, and then
+ ;; merge-blocks wants to move the first line of the block into an outer block
+ ;; that then becomes the fallthrough of the function, so it must be properly typed.
+ ;; and here the new last element is a return, with unreachable type, bad for a block
+ ;; in that position
+ (func $return-block (param $x i32) (result i32)
+ (return
+ (block i32
+ (set_local $x (get_local $x))
+ (get_local $x)
+ )
+ )
+ )
+)
+
diff --git a/test/reg_switch.wast.from-wast b/test/reg_switch.wast.from-wast
new file mode 100644
index 000000000..3bae4683d
--- /dev/null
+++ b/test/reg_switch.wast.from-wast
@@ -0,0 +1,14 @@
+(module
+ (type $0 (func))
+ (memory $0 0)
+ (func $0 (type $0)
+ (if
+ (i32.const 0)
+ (block $A
+ (br_table $A
+ (i32.const 0)
+ )
+ )
+ )
+ )
+)
diff --git a/test/table-import.wast.from-wast b/test/table-import.wast.from-wast
new file mode 100644
index 000000000..6d40941e2
--- /dev/null
+++ b/test/table-import.wast.from-wast
@@ -0,0 +1,9 @@
+(module
+ (type $0 (func))
+ (import "env" "table" (table 1 1 anyfunc))
+ (elem (i32.const 0) $foo)
+ (memory $0 0)
+ (func $foo (type $0)
+ (nop)
+ )
+)
diff --git a/test/unit.wast b/test/unit.wast
index ca90eeeb9..6c3d8e0fa 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -447,4 +447,82 @@
(get_local $1)
)
)
+ (func $return-unreachable (result i32)
+ (return (i32.const 1))
+ )
+ (func $unreachable-block (result i32)
+ (f64.abs
+ (block ;; note no type - valid in binaryen IR, in wasm must be i32
+ (drop (i32.const 1))
+ (return (i32.const 2))
+ )
+ )
+ )
+ (func $unreachable-block-toplevel (result i32)
+ (block ;; note no type - valid in binaryen IR, in wasm must be i32
+ (drop (i32.const 1))
+ (return (i32.const 2))
+ )
+ )
+ (func $unreachable-block0 (result i32)
+ (f64.abs
+ (block ;; note no type - valid in binaryen IR, in wasm must be i32
+ (return (i32.const 2))
+ )
+ )
+ )
+ (func $unreachable-block0-toplevel (result i32)
+ (block ;; note no type - valid in binaryen IR, in wasm must be i32
+ (return (i32.const 2))
+ )
+ )
+ (func $unreachable-block-with-br (result i32)
+ (block $block ;; unreachable type due to last element having that type, but the block is exitable
+ (drop (i32.const 1))
+ (br $block)
+ )
+ (i32.const 1)
+ )
+ (func $unreachable-if (result i32)
+ (f64.abs
+ (if ;; note no type - valid in binaryen IR, in wasm must be i32
+ (i32.const 3)
+ (return (i32.const 2))
+ (return (i32.const 1))
+ )
+ )
+ )
+ (func $unreachable-if-toplevel (result i32)
+ (if ;; note no type - valid in binaryen IR, in wasm must be i32
+ (i32.const 3)
+ (return (i32.const 2))
+ (return (i32.const 1))
+ )
+ )
+ (func $unreachable-loop (result i32)
+ (f64.abs
+ (loop ;; note no type - valid in binaryen IR, in wasm must be i32
+ (nop)
+ (return (i32.const 1))
+ )
+ )
+ )
+ (func $unreachable-loop0 (result i32)
+ (f64.abs
+ (loop ;; note no type - valid in binaryen IR, in wasm must be i32
+ (return (i32.const 1))
+ )
+ )
+ )
+ (func $unreachable-loop-toplevel (result i32)
+ (loop ;; note no type - valid in binaryen IR, in wasm must be i32
+ (nop)
+ (return (i32.const 1))
+ )
+ )
+ (func $unreachable-loop0-toplevel (result i32)
+ (loop ;; note no type - valid in binaryen IR, in wasm must be i32
+ (return (i32.const 1))
+ )
+ )
)
diff --git a/test/unit.wast.from-wast b/test/unit.wast.from-wast
new file mode 100644
index 000000000..1fed14f68
--- /dev/null
+++ b/test/unit.wast.from-wast
@@ -0,0 +1,560 @@
+(module
+ (type $FUNCSIG$vf (func (param f32)))
+ (type $FUNCSIG$v (func))
+ (type $FUNCSIG$id (func (param f64) (result i32)))
+ (type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
+ (type $4 (func (result f64)))
+ (type $5 (func (result i32)))
+ (type $6 (func (param i32) (result i32)))
+ (type $7 (func (param f64) (result f64)))
+ (type $8 (func (result i64)))
+ (type $9 (func (param i32 i64)))
+ (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi))
+ (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
+ (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
+ (table 10 anyfunc)
+ (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (memory $0 4096 4096)
+ (data (i32.const 1026) "\14\00")
+ (export "big_negative" (func $big_negative))
+ (func $big_negative (type $FUNCSIG$v)
+ (local $temp f64)
+ (block $block0
+ (set_local $temp
+ (f64.const -2147483648)
+ )
+ (set_local $temp
+ (f64.const -2147483648)
+ )
+ (set_local $temp
+ (f64.const -21474836480)
+ )
+ (set_local $temp
+ (f64.const 0.039625)
+ )
+ (set_local $temp
+ (f64.const -0.039625)
+ )
+ )
+ )
+ (func $importedDoubles (type $4) (result f64)
+ (local $temp f64)
+ (block $topmost f64
+ (set_local $temp
+ (f64.add
+ (f64.add
+ (f64.add
+ (f64.load
+ (i32.const 8)
+ )
+ (f64.load
+ (i32.const 16)
+ )
+ )
+ (f64.neg
+ (f64.load
+ (i32.const 16)
+ )
+ )
+ )
+ (f64.neg
+ (f64.load
+ (i32.const 8)
+ )
+ )
+ )
+ )
+ (if
+ (i32.gt_s
+ (i32.load
+ (i32.const 24)
+ )
+ (i32.const 0)
+ )
+ (br $topmost
+ (f64.const -3.4)
+ )
+ )
+ (if
+ (f64.gt
+ (f64.load
+ (i32.const 32)
+ )
+ (f64.const 0)
+ )
+ (br $topmost
+ (f64.const 5.6)
+ )
+ )
+ (f64.const 1.2)
+ )
+ )
+ (func $doubleCompares (type $FUNCSIG$ddd) (param $x f64) (param $y f64) (result f64)
+ (local $t f64)
+ (local $Int f64)
+ (local $Double i32)
+ (block $topmost f64
+ (if
+ (f64.gt
+ (get_local $x)
+ (f64.const 0)
+ )
+ (br $topmost
+ (f64.const 1.2)
+ )
+ )
+ (if
+ (f64.gt
+ (get_local $Int)
+ (f64.const 0)
+ )
+ (br $topmost
+ (f64.const -3.4)
+ )
+ )
+ (if
+ (i32.gt_s
+ (get_local $Double)
+ (i32.const 0)
+ )
+ (br $topmost
+ (f64.const 5.6)
+ )
+ )
+ (if
+ (f64.lt
+ (get_local $x)
+ (get_local $y)
+ )
+ (br $topmost
+ (get_local $x)
+ )
+ )
+ (get_local $y)
+ )
+ )
+ (func $intOps (type $5) (result i32)
+ (local $x i32)
+ (i32.eq
+ (get_local $x)
+ (i32.const 0)
+ )
+ )
+ (func $hexLiterals (type $FUNCSIG$v)
+ (drop
+ (i32.add
+ (i32.add
+ (i32.const 0)
+ (i32.const 313249263)
+ )
+ (i32.const -19088752)
+ )
+ )
+ )
+ (func $conversions (type $FUNCSIG$v)
+ (local $i i32)
+ (local $d f64)
+ (block $block0
+ (set_local $i
+ (call $f64-to-int
+ (get_local $d)
+ )
+ )
+ (set_local $d
+ (f64.convert_s/i32
+ (get_local $i)
+ )
+ )
+ (set_local $d
+ (f64.convert_u/i32
+ (i32.shr_u
+ (get_local $i)
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ )
+ (func $seq (type $FUNCSIG$v)
+ (local $J f64)
+ (set_local $J
+ (f64.sub
+ (block $block0 f64
+ (drop
+ (f64.const 0.1)
+ )
+ (f64.const 5.1)
+ )
+ (block $block1 f64
+ (drop
+ (f64.const 3.2)
+ )
+ (f64.const 4.2)
+ )
+ )
+ )
+ )
+ (func $switcher (type $6) (param $x i32) (result i32)
+ (block $topmost i32
+ (block $switch$0
+ (block $switch-default$3
+ (block $switch-case$2
+ (block $switch-case$1
+ (br_table $switch-case$1 $switch-case$2 $switch-default$3
+ (i32.sub
+ (get_local $x)
+ (i32.const 1)
+ )
+ )
+ )
+ (br $topmost
+ (i32.const 1)
+ )
+ )
+ (br $topmost
+ (i32.const 2)
+ )
+ )
+ (nop)
+ )
+ (block $switch$4
+ (block $switch-default$7
+ (block $switch-case$6
+ (block $switch-case$5
+ (br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7
+ (i32.sub
+ (get_local $x)
+ (i32.const 5)
+ )
+ )
+ )
+ (br $topmost
+ (i32.const 121)
+ )
+ )
+ (br $topmost
+ (i32.const 51)
+ )
+ )
+ (nop)
+ )
+ (block $label$break$Lout
+ (block $switch-default$16
+ (block $switch-case$15
+ (block $switch-case$12
+ (block $switch-case$9
+ (block $switch-case$8
+ (br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16
+ (i32.sub
+ (get_local $x)
+ (i32.const 2)
+ )
+ )
+ )
+ (br $label$break$Lout)
+ )
+ (br $label$break$Lout)
+ )
+ (block $while-out$10
+ (loop $while-in$11
+ (block $block1
+ (br $while-out$10)
+ (br $while-in$11)
+ )
+ )
+ (br $label$break$Lout)
+ )
+ )
+ (block $while-out$13
+ (loop $while-in$14
+ (block $block3
+ (br $label$break$Lout)
+ (br $while-in$14)
+ )
+ )
+ (br $label$break$Lout)
+ )
+ )
+ (nop)
+ )
+ (i32.const 0)
+ )
+ )
+ (func $blocker (type $FUNCSIG$v)
+ (block $label$break$L
+ (br $label$break$L)
+ )
+ )
+ (func $frem (type $4) (result f64)
+ (call $f64-rem
+ (f64.const 5.5)
+ (f64.const 1.2)
+ )
+ )
+ (func $big_uint_div_u (type $5) (result i32)
+ (local $x i32)
+ (block $topmost i32
+ (set_local $x
+ (i32.and
+ (i32.div_u
+ (i32.const -1)
+ (i32.const 2)
+ )
+ (i32.const -1)
+ )
+ )
+ (get_local $x)
+ )
+ )
+ (func $fr (type $FUNCSIG$vf) (param $x f32)
+ (local $y f32)
+ (local $z f64)
+ (block $block0
+ (drop
+ (f32.demote/f64
+ (get_local $z)
+ )
+ )
+ (drop
+ (get_local $y)
+ )
+ (drop
+ (f32.const 5)
+ )
+ (drop
+ (f32.const 0)
+ )
+ (drop
+ (f32.const 5)
+ )
+ (drop
+ (f32.const 0)
+ )
+ )
+ )
+ (func $negZero (type $4) (result f64)
+ (f64.const -0)
+ )
+ (func $abs (type $FUNCSIG$v)
+ (local $x i32)
+ (local $y f64)
+ (local $z f32)
+ (local $asm2wasm_i32_temp i32)
+ (block $block0
+ (set_local $x
+ (block $block1 i32
+ (set_local $asm2wasm_i32_temp
+ (i32.const 0)
+ )
+ (select
+ (i32.sub
+ (i32.const 0)
+ (get_local $asm2wasm_i32_temp)
+ )
+ (get_local $asm2wasm_i32_temp)
+ (i32.lt_s
+ (get_local $asm2wasm_i32_temp)
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (set_local $y
+ (f64.abs
+ (f64.const 0)
+ )
+ )
+ (set_local $z
+ (f32.abs
+ (f32.const 0)
+ )
+ )
+ )
+ )
+ (func $neg (type $FUNCSIG$v)
+ (local $x f32)
+ (block $block0
+ (set_local $x
+ (f32.neg
+ (get_local $x)
+ )
+ )
+ (call_indirect $FUNCSIG$vf
+ (get_local $x)
+ (i32.add
+ (i32.and
+ (i32.const 1)
+ (i32.const 7)
+ )
+ (i32.const 8)
+ )
+ )
+ )
+ )
+ (func $cneg (type $FUNCSIG$vf) (param $x f32)
+ (call_indirect $FUNCSIG$vf
+ (get_local $x)
+ (i32.add
+ (i32.and
+ (i32.const 1)
+ (i32.const 7)
+ )
+ (i32.const 8)
+ )
+ )
+ )
+ (func $___syscall_ret (type $FUNCSIG$v)
+ (local $$0 i32)
+ (drop
+ (i32.gt_u
+ (i32.shr_u
+ (get_local $$0)
+ (i32.const 0)
+ )
+ (i32.const -4096)
+ )
+ )
+ )
+ (func $z (type $FUNCSIG$v)
+ (nop)
+ )
+ (func $w (type $FUNCSIG$v)
+ (nop)
+ )
+ (func $block_and_after (type $5) (result i32)
+ (block $waka
+ (drop
+ (i32.const 1)
+ )
+ (br $waka)
+ )
+ (i32.const 0)
+ )
+ (func $loop-roundtrip (type $7) (param $0 f64) (result f64)
+ (loop $loop-in1 f64
+ (drop
+ (get_local $0)
+ )
+ (get_local $0)
+ )
+ )
+ (func $big-i64 (type $8) (result i64)
+ (i64.const -9218868437227405313)
+ )
+ (func $i64-store32 (type $9) (param $0 i32) (param $1 i64)
+ (i64.store32
+ (get_local $0)
+ (get_local $1)
+ )
+ )
+ (func $return-unreachable (type $5) (result i32)
+ (return
+ (i32.const 1)
+ )
+ )
+ (func $unreachable-block (type $5) (result i32)
+ (f64.abs
+ (block $block
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ )
+ )
+ )
+ (func $unreachable-block-toplevel (type $5) (result i32)
+ (block $block
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ )
+ )
+ (func $unreachable-block0 (type $5) (result i32)
+ (f64.abs
+ (block $block
+ (return
+ (i32.const 2)
+ )
+ )
+ )
+ )
+ (func $unreachable-block0-toplevel (type $5) (result i32)
+ (block $block
+ (return
+ (i32.const 2)
+ )
+ )
+ )
+ (func $unreachable-block-with-br (type $5) (result i32)
+ (block $block
+ (drop
+ (i32.const 1)
+ )
+ (br $block)
+ )
+ (i32.const 1)
+ )
+ (func $unreachable-if (type $5) (result i32)
+ (f64.abs
+ (if
+ (i32.const 3)
+ (return
+ (i32.const 2)
+ )
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $unreachable-if-toplevel (type $5) (result i32)
+ (if
+ (i32.const 3)
+ (return
+ (i32.const 2)
+ )
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (func $unreachable-loop (type $5) (result i32)
+ (f64.abs
+ (loop $loop-in
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $unreachable-loop0 (type $5) (result i32)
+ (f64.abs
+ (loop $loop-in
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $unreachable-loop-toplevel (type $5) (result i32)
+ (loop $loop-in
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (func $unreachable-loop0-toplevel (type $5) (result i32)
+ (loop $loop-in
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+)
diff --git a/test/unit.wast.fromBinary b/test/unit.wast.fromBinary
index 1f1cf753f..7ed6268c8 100644
--- a/test/unit.wast.fromBinary
+++ b/test/unit.wast.fromBinary
@@ -272,6 +272,7 @@
(br $label$15)
(br $label$16)
)
+ (unreachable)
(br $label$9)
)
)
@@ -280,8 +281,11 @@
(br $label$9)
(br $label$18)
)
+ (unreachable)
(br $label$9)
+ (unreachable)
)
+ (unreachable)
)
(nop)
)
@@ -457,5 +461,139 @@
(get_local $var$1)
)
)
+ (func $return-unreachable (type $5) (result i32)
+ (return
+ (i32.const 1)
+ )
+ )
+ (func $unreachable-block (type $5) (result i32)
+ (block $label$0
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $unreachable-block-toplevel (type $5) (result i32)
+ (block $label$0
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $unreachable-block0 (type $5) (result i32)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $unreachable-block0-toplevel (type $5) (result i32)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $unreachable-block-with-br (type $5) (result i32)
+ (block $label$0 i32
+ (block $label$1
+ (drop
+ (i32.const 1)
+ )
+ (br $label$1)
+ )
+ (i32.const 1)
+ )
+ )
+ (func $unreachable-if (type $5) (result i32)
+ (if
+ (i32.const 3)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ )
+ (block $label$1
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $unreachable-if-toplevel (type $5) (result i32)
+ (if
+ (i32.const 3)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ )
+ (block $label$1
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (unreachable)
+ )
+ (func $unreachable-loop (type $5) (result i32)
+ (loop $label$0
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $unreachable-loop0 (type $5) (result i32)
+ (loop $label$0
+ (return
+ (i32.const 1)
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $unreachable-loop-toplevel (type $5) (result i32)
+ (loop $label$0
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ (unreachable)
+ )
+ (func $unreachable-loop0-toplevel (type $5) (result i32)
+ (loop $label$0
+ (return
+ (i32.const 1)
+ )
+ )
+ (unreachable)
+ )
)
diff --git a/test/unit.wast.fromBinary.noDebugInfo b/test/unit.wast.fromBinary.noDebugInfo
index 508080e21..161c11a47 100644
--- a/test/unit.wast.fromBinary.noDebugInfo
+++ b/test/unit.wast.fromBinary.noDebugInfo
@@ -272,6 +272,7 @@
(br $label$15)
(br $label$16)
)
+ (unreachable)
(br $label$9)
)
)
@@ -280,8 +281,11 @@
(br $label$9)
(br $label$18)
)
+ (unreachable)
(br $label$9)
+ (unreachable)
)
+ (unreachable)
)
(nop)
)
@@ -457,5 +461,139 @@
(get_local $var$1)
)
)
+ (func $23 (type $5) (result i32)
+ (return
+ (i32.const 1)
+ )
+ )
+ (func $24 (type $5) (result i32)
+ (block $label$0
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $25 (type $5) (result i32)
+ (block $label$0
+ (drop
+ (i32.const 1)
+ )
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $26 (type $5) (result i32)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $27 (type $5) (result i32)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $28 (type $5) (result i32)
+ (block $label$0 i32
+ (block $label$1
+ (drop
+ (i32.const 1)
+ )
+ (br $label$1)
+ )
+ (i32.const 1)
+ )
+ )
+ (func $29 (type $5) (result i32)
+ (if
+ (i32.const 3)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ )
+ (block $label$1
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $30 (type $5) (result i32)
+ (if
+ (i32.const 3)
+ (block $label$0
+ (return
+ (i32.const 2)
+ )
+ )
+ (block $label$1
+ (return
+ (i32.const 1)
+ )
+ )
+ )
+ (unreachable)
+ )
+ (func $31 (type $5) (result i32)
+ (loop $label$0
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $32 (type $5) (result i32)
+ (loop $label$0
+ (return
+ (i32.const 1)
+ )
+ )
+ (f64.abs
+ (unreachable)
+ )
+ )
+ (func $33 (type $5) (result i32)
+ (loop $label$0
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ )
+ (unreachable)
+ )
+ (func $34 (type $5) (result i32)
+ (loop $label$0
+ (return
+ (i32.const 1)
+ )
+ )
+ (unreachable)
+ )
)