| 1 |
;; Test `unreachable` operator |
| 2 |
|
| 3 |
(module |
| 4 |
;; Auxiliary definitions |
| 5 |
(func $dummy) |
| 6 |
(func $dummy3 (param i32 i32 i32)) |
| 7 |
|
| 8 |
(func (export "type-i32") (result i32) (unreachable)) |
| 9 |
(func (export "type-i64") (result i32) (unreachable)) |
| 10 |
(func (export "type-f32") (result f64) (unreachable)) |
| 11 |
(func (export "type-f64") (result f64) (unreachable)) |
| 12 |
|
| 13 |
(func (export "as-func-first") (result i32) |
| 14 |
(unreachable) (i32.const -1) |
| 15 |
) |
| 16 |
(func (export "as-func-mid") (result i32) |
| 17 |
(call $dummy) (unreachable) (i32.const -1) |
| 18 |
) |
| 19 |
(func (export "as-func-last") |
| 20 |
(call $dummy) (unreachable) |
| 21 |
) |
| 22 |
(func (export "as-func-value") (result i32) |
| 23 |
(call $dummy) (unreachable) |
| 24 |
) |
| 25 |
|
| 26 |
(func (export "as-block-first") (result i32) |
| 27 |
(block (result i32) (unreachable) (i32.const 2)) |
| 28 |
) |
| 29 |
(func (export "as-block-mid") (result i32) |
| 30 |
(block (result i32) (call $dummy) (unreachable) (i32.const 2)) |
| 31 |
) |
| 32 |
(func (export "as-block-last") |
| 33 |
(block (nop) (call $dummy) (unreachable)) |
| 34 |
) |
| 35 |
(func (export "as-block-value") (result i32) |
| 36 |
(block (result i32) (nop) (call $dummy) (unreachable)) |
| 37 |
) |
| 38 |
(func (export "as-block-broke") (result i32) |
| 39 |
(block (result i32) (call $dummy) (br 0 (i32.const 1)) (unreachable)) |
| 40 |
) |
| 41 |
|
| 42 |
(func (export "as-loop-first") (result i32) |
| 43 |
(loop (result i32) (unreachable) (i32.const 2)) |
| 44 |
) |
| 45 |
(func (export "as-loop-mid") (result i32) |
| 46 |
(loop (result i32) (call $dummy) (unreachable) (i32.const 2)) |
| 47 |
) |
| 48 |
(func (export "as-loop-last") |
| 49 |
(loop (nop) (call $dummy) (unreachable)) |
| 50 |
) |
| 51 |
(func (export "as-loop-broke") (result i32) |
| 52 |
(block (result i32) |
| 53 |
(loop (result i32) (call $dummy) (br 1 (i32.const 1)) (unreachable)) |
| 54 |
) |
| 55 |
) |
| 56 |
|
| 57 |
(func (export "as-br-value") (result i32) |
| 58 |
(block (result i32) (br 0 (unreachable))) |
| 59 |
) |
| 60 |
|
| 61 |
(func (export "as-br_if-cond") |
| 62 |
(block (br_if 0 (unreachable))) |
| 63 |
) |
| 64 |
(func (export "as-br_if-value") (result i32) |
| 65 |
(block (result i32) |
| 66 |
(drop (br_if 0 (unreachable) (i32.const 1))) (i32.const 7) |
| 67 |
) |
| 68 |
) |
| 69 |
(func (export "as-br_if-value-cond") (result i32) |
| 70 |
(block (result i32) |
| 71 |
(drop (br_if 0 (i32.const 6) (unreachable))) (i32.const 7) |
| 72 |
) |
| 73 |
) |
| 74 |
|
| 75 |
(func (export "as-br_table-index") |
| 76 |
(block (br_table 0 0 0 (unreachable))) |
| 77 |
) |
| 78 |
(func (export "as-br_table-value") (result i32) |
| 79 |
(block (result i32) |
| 80 |
(br_table 0 0 0 (unreachable) (i32.const 1)) (i32.const 7) |
| 81 |
) |
| 82 |
) |
| 83 |
(func (export "as-br_table-value-2") (result i32) |
| 84 |
(block (result i32) |
| 85 |
(block (result i32) (br_table 0 1 (unreachable) (i32.const 1))) |
| 86 |
) |
| 87 |
) |
| 88 |
(func (export "as-br_table-value-index") (result i32) |
| 89 |
(block (result i32) |
| 90 |
(br_table 0 0 (i32.const 6) (unreachable)) (i32.const 7) |
| 91 |
) |
| 92 |
) |
| 93 |
(func (export "as-br_table-value-and-index") (result i32) |
| 94 |
(block (result i32) (br_table 0 0 (unreachable)) (i32.const 8)) |
| 95 |
) |
| 96 |
|
| 97 |
(func (export "as-return-value") (result i64) |
| 98 |
(return (unreachable)) |
| 99 |
) |
| 100 |
|
| 101 |
(func (export "as-if-cond") (result i32) |
| 102 |
(if (result i32) (unreachable) (then (i32.const 0)) (else (i32.const 1))) |
| 103 |
) |
| 104 |
(func (export "as-if-then") (param i32 i32) (result i32) |
| 105 |
(if (result i32) (local.get 0) (then (unreachable)) (else (local.get 1))) |
| 106 |
) |
| 107 |
(func (export "as-if-else") (param i32 i32) (result i32) |
| 108 |
(if (result i32) (local.get 0) (then (local.get 1)) (else (unreachable))) |
| 109 |
) |
| 110 |
|
| 111 |
(func (export "as-select-first") (param i32 i32) (result i32) |
| 112 |
(select (unreachable) (local.get 0) (local.get 1)) |
| 113 |
) |
| 114 |
(func (export "as-select-second") (param i32 i32) (result i32) |
| 115 |
(select (local.get 0) (unreachable) (local.get 1)) |
| 116 |
) |
| 117 |
(func (export "as-select-cond") (result i32) |
| 118 |
(select (i32.const 0) (i32.const 1) (unreachable)) |
| 119 |
) |
| 120 |
|
| 121 |
(func (export "as-call-first") |
| 122 |
(call $dummy3 (unreachable) (i32.const 2) (i32.const 3)) |
| 123 |
) |
| 124 |
(func (export "as-call-mid") |
| 125 |
(call $dummy3 (i32.const 1) (unreachable) (i32.const 3)) |
| 126 |
) |
| 127 |
(func (export "as-call-last") |
| 128 |
(call $dummy3 (i32.const 1) (i32.const 2) (unreachable)) |
| 129 |
) |
| 130 |
|
| 131 |
(type $sig (func (param i32 i32 i32))) |
| 132 |
(table funcref (elem $dummy3)) |
| 133 |
(func (export "as-call_indirect-func") |
| 134 |
(call_indirect (type $sig) |
| 135 |
(unreachable) (i32.const 1) (i32.const 2) (i32.const 3) |
| 136 |
) |
| 137 |
) |
| 138 |
(func (export "as-call_indirect-first") |
| 139 |
(call_indirect (type $sig) |
| 140 |
(i32.const 0) (unreachable) (i32.const 2) (i32.const 3) |
| 141 |
) |
| 142 |
) |
| 143 |
(func (export "as-call_indirect-mid") |
| 144 |
(call_indirect (type $sig) |
| 145 |
(i32.const 0) (i32.const 1) (unreachable) (i32.const 3) |
| 146 |
) |
| 147 |
) |
| 148 |
(func (export "as-call_indirect-last") |
| 149 |
(call_indirect (type $sig) |
| 150 |
(i32.const 0) (i32.const 1) (i32.const 2) (unreachable) |
| 151 |
) |
| 152 |
) |
| 153 |
|
| 154 |
(func (export "as-local.set-value") (local f32) |
| 155 |
(local.set 0 (unreachable)) |
| 156 |
) |
| 157 |
(func (export "as-local.tee-value") (result f32) (local f32) |
| 158 |
(local.tee 0 (unreachable)) |
| 159 |
) |
| 160 |
(global $a (mut f32) (f32.const 0)) |
| 161 |
(func (export "as-global.set-value") (result f32) |
| 162 |
(global.set $a (unreachable)) |
| 163 |
) |
| 164 |
|
| 165 |
(memory 1) |
| 166 |
(func (export "as-load-address") (result f32) |
| 167 |
(f32.load (unreachable)) |
| 168 |
) |
| 169 |
(func (export "as-loadN-address") (result i64) |
| 170 |
(i64.load8_s (unreachable)) |
| 171 |
) |
| 172 |
|
| 173 |
(func (export "as-store-address") |
| 174 |
(f64.store (unreachable) (f64.const 7)) |
| 175 |
) |
| 176 |
(func (export "as-store-value") |
| 177 |
(i64.store (i32.const 2) (unreachable)) |
| 178 |
) |
| 179 |
|
| 180 |
(func (export "as-storeN-address") |
| 181 |
(i32.store8 (unreachable) (i32.const 7)) |
| 182 |
) |
| 183 |
(func (export "as-storeN-value") |
| 184 |
(i64.store16 (i32.const 2) (unreachable)) |
| 185 |
) |
| 186 |
|
| 187 |
(func (export "as-unary-operand") (result f32) |
| 188 |
(f32.neg (unreachable)) |
| 189 |
) |
| 190 |
|
| 191 |
(func (export "as-binary-left") (result i32) |
| 192 |
(i32.add (unreachable) (i32.const 10)) |
| 193 |
) |
| 194 |
(func (export "as-binary-right") (result i64) |
| 195 |
(i64.sub (i64.const 10) (unreachable)) |
| 196 |
) |
| 197 |
|
| 198 |
(func (export "as-test-operand") (result i32) |
| 199 |
(i32.eqz (unreachable)) |
| 200 |
) |
| 201 |
|
| 202 |
(func (export "as-compare-left") (result i32) |
| 203 |
(f64.le (unreachable) (f64.const 10)) |
| 204 |
) |
| 205 |
(func (export "as-compare-right") (result i32) |
| 206 |
(f32.ne (f32.const 10) (unreachable)) |
| 207 |
) |
| 208 |
|
| 209 |
(func (export "as-convert-operand") (result i32) |
| 210 |
(i32.wrap_i64 (unreachable)) |
| 211 |
) |
| 212 |
|
| 213 |
(func (export "as-memory.grow-size") (result i32) |
| 214 |
(memory.grow (unreachable)) |
| 215 |
) |
| 216 |
) |
| 217 |
|
| 218 |
(assert_trap (invoke "type-i32") "unreachable") |
| 219 |
(assert_trap (invoke "type-i64") "unreachable") |
| 220 |
(assert_trap (invoke "type-f32") "unreachable") |
| 221 |
(assert_trap (invoke "type-f64") "unreachable") |
| 222 |
|
| 223 |
(assert_trap (invoke "as-func-first") "unreachable") |
| 224 |
(assert_trap (invoke "as-func-mid") "unreachable") |
| 225 |
(assert_trap (invoke "as-func-last") "unreachable") |
| 226 |
(assert_trap (invoke "as-func-value") "unreachable") |
| 227 |
|
| 228 |
(assert_trap (invoke "as-block-first") "unreachable") |
| 229 |
(assert_trap (invoke "as-block-mid") "unreachable") |
| 230 |
(assert_trap (invoke "as-block-last") "unreachable") |
| 231 |
(assert_trap (invoke "as-block-value") "unreachable") |
| 232 |
(assert_return (invoke "as-block-broke") (i32.const 1)) |
| 233 |
|
| 234 |
(assert_trap (invoke "as-loop-first") "unreachable") |
| 235 |
(assert_trap (invoke "as-loop-mid") "unreachable") |
| 236 |
(assert_trap (invoke "as-loop-last") "unreachable") |
| 237 |
(assert_return (invoke "as-loop-broke") (i32.const 1)) |
| 238 |
|
| 239 |
(assert_trap (invoke "as-br-value") "unreachable") |
| 240 |
|
| 241 |
(assert_trap (invoke "as-br_if-cond") "unreachable") |
| 242 |
(assert_trap (invoke "as-br_if-value") "unreachable") |
| 243 |
(assert_trap (invoke "as-br_if-value-cond") "unreachable") |
| 244 |
|
| 245 |
(assert_trap (invoke "as-br_table-index") "unreachable") |
| 246 |
(assert_trap (invoke "as-br_table-value") "unreachable") |
| 247 |
(assert_trap (invoke "as-br_table-value-2") "unreachable") |
| 248 |
(assert_trap (invoke "as-br_table-value-index") "unreachable") |
| 249 |
(assert_trap (invoke "as-br_table-value-and-index") "unreachable") |
| 250 |
|
| 251 |
(assert_trap (invoke "as-return-value") "unreachable") |
| 252 |
|
| 253 |
(assert_trap (invoke "as-if-cond") "unreachable") |
| 254 |
(assert_trap (invoke "as-if-then" (i32.const 1) (i32.const 6)) "unreachable") |
| 255 |
(assert_return (invoke "as-if-then" (i32.const 0) (i32.const 6)) (i32.const 6)) |
| 256 |
(assert_trap (invoke "as-if-else" (i32.const 0) (i32.const 6)) "unreachable") |
| 257 |
(assert_return (invoke "as-if-else" (i32.const 1) (i32.const 6)) (i32.const 6)) |
| 258 |
|
| 259 |
(assert_trap (invoke "as-select-first" (i32.const 0) (i32.const 6)) "unreachable") |
| 260 |
(assert_trap (invoke "as-select-first" (i32.const 1) (i32.const 6)) "unreachable") |
| 261 |
(assert_trap (invoke "as-select-second" (i32.const 0) (i32.const 6)) "unreachable") |
| 262 |
(assert_trap (invoke "as-select-second" (i32.const 1) (i32.const 6)) "unreachable") |
| 263 |
(assert_trap (invoke "as-select-cond") "unreachable") |
| 264 |
|
| 265 |
(assert_trap (invoke "as-call-first") "unreachable") |
| 266 |
(assert_trap (invoke "as-call-mid") "unreachable") |
| 267 |
(assert_trap (invoke "as-call-last") "unreachable") |
| 268 |
|
| 269 |
(assert_trap (invoke "as-call_indirect-func") "unreachable") |
| 270 |
(assert_trap (invoke "as-call_indirect-first") "unreachable") |
| 271 |
(assert_trap (invoke "as-call_indirect-mid") "unreachable") |
| 272 |
(assert_trap (invoke "as-call_indirect-last") "unreachable") |
| 273 |
|
| 274 |
(assert_trap (invoke "as-local.set-value") "unreachable") |
| 275 |
(assert_trap (invoke "as-local.tee-value") "unreachable") |
| 276 |
(assert_trap (invoke "as-global.set-value") "unreachable") |
| 277 |
|
| 278 |
(assert_trap (invoke "as-load-address") "unreachable") |
| 279 |
(assert_trap (invoke "as-loadN-address") "unreachable") |
| 280 |
|
| 281 |
(assert_trap (invoke "as-store-address") "unreachable") |
| 282 |
(assert_trap (invoke "as-store-value") "unreachable") |
| 283 |
(assert_trap (invoke "as-storeN-address") "unreachable") |
| 284 |
(assert_trap (invoke "as-storeN-value") "unreachable") |
| 285 |
|
| 286 |
(assert_trap (invoke "as-unary-operand") "unreachable") |
| 287 |
|
| 288 |
(assert_trap (invoke "as-binary-left") "unreachable") |
| 289 |
(assert_trap (invoke "as-binary-right") "unreachable") |
| 290 |
|
| 291 |
(assert_trap (invoke "as-test-operand") "unreachable") |
| 292 |
|
| 293 |
(assert_trap (invoke "as-compare-left") "unreachable") |
| 294 |
(assert_trap (invoke "as-compare-right") "unreachable") |
| 295 |
|
| 296 |
(assert_trap (invoke "as-convert-operand") "unreachable") |
| 297 |
|
| 298 |
(assert_trap (invoke "as-memory.grow-size") "unreachable") |
| 299 |
|