| 1 |
(module |
| 2 |
(type $0 (func (param i32))) |
| 3 |
(import "env" "invoke_i" (func $invoke_i (param i32) (result i32))) |
| 4 |
(import "env" "invoke_ii" (func $invoke_ii (param i32 i32) (result i32))) |
| 5 |
(import "env" "invoke_iii" (func $invoke_iii (param i32 i32 i32) (result i32))) |
| 6 |
(import "env" "invoke_iiii" (func $invoke_iiii (param i32 i32 i32 i32) (result i32))) |
| 7 |
(import "env" "invoke_iiiii" (func $invoke_iiiii (param i32 i32 i32 i32 i32) (result i32))) |
| 8 |
(import "env" "invoke_v" (func $invoke_v (param i32))) |
| 9 |
(import "env" "invoke_vi" (func $invoke_vi (param i32 i32))) |
| 10 |
(import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) |
| 11 |
(import "env" "invoke_viii" (func $invoke_viii (param i32 i32 i32 i32))) |
| 12 |
(import "env" "invoke_viiii" (func $invoke_viiii (param i32 i32 i32 i32 i32))) |
| 13 |
(import "env" "_emscripten_throw_longjmp" (func $_emscripten_throw_longjmp)) |
| 14 |
|
| 15 |
(table 22 22 funcref) |
| 16 |
|
| 17 |
(global $__stack_pointer (mut i32) (i32.const 65536)) |
| 18 |
(func $stackSave (export "emscripten_stack_get_current") (result i32) |
| 19 |
global.get $__stack_pointer) |
| 20 |
(func $stackRestore (export "_emscripten_stack_restore") (param i32) |
| 21 |
local.get 0 |
| 22 |
global.set $__stack_pointer) |
| 23 |
(func $setThrew (export "setThrew") (param i32 i32)) |
| 24 |
|
| 25 |
(func $v_i32 (result i32) (i32.const 42)) |
| 26 |
(func $v_i32_unreachable (result i32) unreachable) |
| 27 |
|
| 28 |
(elem (i32.const 0) $v_i32 $v_i32_unreachable) |
| 29 |
|
| 30 |
;; call_v_i32 should be called with 0 or 1 and expect 42 or unreachable. |
| 31 |
(func $call_v_i32 (export "call_v_i32") (param i32) (result i32) |
| 32 |
(call $invoke_i (local.get 0))) |
| 33 |
|
| 34 |
(func $i32_i32 (param i32) (result i32) (local.get 0)) |
| 35 |
(func $i32_i32_unreachable (param i32) (result i32) unreachable) |
| 36 |
|
| 37 |
(elem (i32.const 2) $i32_i32 $i32_i32_unreachable) |
| 38 |
|
| 39 |
;; call_i32_i32 should be called with 2 or 3 followed by one number which is |
| 40 |
;; the result on $0 == 2 or unreachable on 3. |
| 41 |
(func $call_i32_i32 (export "call_i32_i32") (param i32 i32) (result i32) |
| 42 |
(call $invoke_ii (local.get 0) (local.get 1))) |
| 43 |
|
| 44 |
(func $i32i32_i32 (param i32 i32) (result i32) (i32.add (local.get 0) (local.get 1))) |
| 45 |
(func $i32i32_i32_unreachable (param i32 i32) (result i32) unreachable) |
| 46 |
|
| 47 |
(elem (i32.const 4) $i32i32_i32 $i32i32_i32_unreachable) |
| 48 |
|
| 49 |
;; call_i32i32_i32 should be called with 4 or 5 followed by two numbers |
| 50 |
;; whose sum is the result on $0 == 4 or unreachable on 5. |
| 51 |
(func $call_i32i32_i32 (export "call_i32i32_i32") (param i32 i32 i32) (result i32) |
| 52 |
(call $invoke_iii (local.get 0) (local.get 1) (local.get 2))) |
| 53 |
|
| 54 |
(func $i32i32i32_i32 (param i32 i32 i32) (result i32) |
| 55 |
(i32.add (i32.add (local.get 0) (local.get 1)) (local.get 2))) |
| 56 |
(func $i32i32i32_i32_unreachable (param i32 i32 i32) (result i32) unreachable) |
| 57 |
|
| 58 |
(elem (i32.const 6) $i32i32i32_i32 $i32i32i32_i32_unreachable) |
| 59 |
|
| 60 |
;; call_i32i32i32_i32 should be called with 6 or 7 followed by three numbers |
| 61 |
;; whose sum is the result on $0 == 6 or unreachable on 7. |
| 62 |
(func $call_i32i32i32_i32 (export "call_i32i32i32_i32") (param i32 i32 i32 i32) (result i32) |
| 63 |
(call $invoke_iiii (local.get 0) (local.get 1) (local.get 2) (local.get 3))) |
| 64 |
|
| 65 |
(func $i32i32i32i32_i32 (param i32 i32 i32 i32) (result i32) |
| 66 |
(i32.add (i32.add (i32.add (local.get 0) (local.get 1)) (local.get 2)) (local.get 3))) |
| 67 |
(func $i32i32i32i32_i32_unreachable (param i32 i32 i32 i32) (result i32) unreachable) |
| 68 |
|
| 69 |
(elem (i32.const 8) $i32i32i32i32_i32 $i32i32i32i32_i32_unreachable) |
| 70 |
|
| 71 |
;; calli32_i32i32i32i32_i32 should be called with 8 or 9 followed by four numbers |
| 72 |
;; whose sum is the result on $0 == 8 or unreachable on 9. |
| 73 |
(func $calli32_i32i32i32i32_i32 (export "calli32_i32i32i32i32_i32") (param i32 i32 i32 i32 i32) (result i32) |
| 74 |
(call $invoke_iiiii (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4))) |
| 75 |
|
| 76 |
(func $v_v) |
| 77 |
(func $v_v_unreachable unreachable) |
| 78 |
|
| 79 |
(elem (i32.const 10) $v_v $v_v_unreachable) |
| 80 |
|
| 81 |
;; call_v_v should be called with 10 or 11 and expect unreachable on 11. |
| 82 |
(func $call_v_v (export "call_v_v") (param i32) |
| 83 |
(call $invoke_v (local.get 0))) |
| 84 |
|
| 85 |
(func $i32_v (param i32)) |
| 86 |
(func $i32_v_unreachable (param i32) unreachable) |
| 87 |
|
| 88 |
(elem (i32.const 12) $i32_v $i32_v_unreachable) |
| 89 |
|
| 90 |
;; call_i32_v should be called with 12 or 13 followed by one number and |
| 91 |
;; expect unreachable on 2. |
| 92 |
(func $call_i32_v (export "call_i32_v") (param i32 i32) |
| 93 |
(call $invoke_vi (local.get 0) (local.get 1))) |
| 94 |
|
| 95 |
(func $i32i32_v (param i32 i32)) |
| 96 |
(func $i32i32_v_unreachable (param i32 i32) unreachable) |
| 97 |
|
| 98 |
(elem (i32.const 14) $i32i32_v $i32i32_v_unreachable) |
| 99 |
|
| 100 |
;; call_i32i32_v should be called with 14 or 15 followed by two numbers |
| 101 |
;; and expect unreachable on 15. |
| 102 |
(func $call_i32i32_v (export "call_i32i32_v") (param i32 i32 i32) |
| 103 |
(call $invoke_vii (local.get 0) (local.get 1) (local.get 2))) |
| 104 |
|
| 105 |
(func $i32i32i32_v (param i32 i32 i32)) |
| 106 |
(func $i32i32i32_v_unreachable (param i32 i32 i32) unreachable) |
| 107 |
|
| 108 |
(elem (i32.const 16) $i32i32i32_v $i32i32i32_v_unreachable) |
| 109 |
|
| 110 |
;; call_i32i32i32_v should be called with 16 or 17 followed by three numbers |
| 111 |
;; and expect unreachable on 17. |
| 112 |
(func $call_i32i32i32_v (export "call_i32i32i32_v") (param i32 i32 i32 i32) |
| 113 |
(call $invoke_viii (local.get 0) (local.get 1) (local.get 2) (local.get 3))) |
| 114 |
|
| 115 |
(func $i32i32i32i32_v (param i32 i32 i32 i32)) |
| 116 |
(func $i32i32i32i32_v_unreachable (param i32 i32 i32 i32) unreachable) |
| 117 |
|
| 118 |
(elem (i32.const 18) $i32i32i32i32_v $i32i32i32i32_v_unreachable) |
| 119 |
|
| 120 |
;; calli32_i32i32i32i32_v should be called with 18 or 19 followed by four |
| 121 |
;; numbers and expect unreachable on 19. |
| 122 |
(func $calli32_i32i32i32i32_v (export "calli32_i32i32i32i32_v") (param i32 i32 i32 i32 i32) |
| 123 |
(call $invoke_viiii (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4))) |
| 124 |
|
| 125 |
(func $call_longjmp_throw |
| 126 |
(call $_emscripten_throw_longjmp) |
| 127 |
(global.set $__stack_pointer (i32.const 43))) |
| 128 |
|
| 129 |
(func $call_longjmp_throw_unreachable unreachable) |
| 130 |
|
| 131 |
(elem (i32.const 20) $call_longjmp_throw $call_longjmp_throw_unreachable) |
| 132 |
|
| 133 |
;; $call_invoke_v_with_longjmp_throw should be called with 20 or 21 and |
| 134 |
;; expect unreachable on 21. $call_invoke_v_with_longjmp_throw mimics |
| 135 |
;; Emscripten by setting the stack pointer to a different value than default. |
| 136 |
;; We ensure that the stack pointer was not changed to 43 by $call_longjump. |
| 137 |
(func $call_invoke_v_with_longjmp_throw (export "call_invoke_v_with_longjmp_throw") (param i32) |
| 138 |
(global.set $__stack_pointer (i32.const 42)) |
| 139 |
(call $invoke_v (local.get 0)) |
| 140 |
global.get $__stack_pointer |
| 141 |
i32.const 42 |
| 142 |
i32.ne |
| 143 |
(if (then unreachable)) |
| 144 |
) |
| 145 |
) |