| 1 |
(module $example |
| 2 |
(type $func (;0;) (func)) |
| 3 |
(type $cont (;1;) (cont $func)) |
| 4 |
(type $cont-func (;2;) (func (param (ref $cont)))) |
| 5 |
(type $cont-cont (;3;) (cont $cont-func)) |
| 6 |
(type $func-cont-func-func (;4;) (func (param (ref $func) (ref $cont-func)))) |
| 7 |
(type $func-cont-func-cont (;5;) (cont $func-cont-func-func)) |
| 8 |
(type (;6;) (func (param i32))) |
| 9 |
(import "spectest" "print_i32" (func $log (;0;) (type 6))) |
| 10 |
(export "main" (func $main)) |
| 11 |
(elem (;0;) declare func $main $thread1 $thread2 $thread3) |
| 12 |
(func $main (;1;) (type $func-cont-func-func) (param $yield (ref $func)) (param $fork (ref $cont-func)) |
| 13 |
i32.const 0 |
| 14 |
call $log |
| 15 |
local.get $yield |
| 16 |
local.get $fork |
| 17 |
ref.func $thread1 |
| 18 |
cont.new $func-cont-func-cont |
| 19 |
cont.bind $func-cont-func-cont $cont |
| 20 |
local.get $fork |
| 21 |
call_ref $cont-func |
| 22 |
i32.const 1 |
| 23 |
call $log |
| 24 |
local.get $yield |
| 25 |
local.get $fork |
| 26 |
ref.func $thread2 |
| 27 |
cont.new $func-cont-func-cont |
| 28 |
cont.bind $func-cont-func-cont $cont |
| 29 |
local.get $fork |
| 30 |
call_ref $cont-func |
| 31 |
i32.const 2 |
| 32 |
call $log |
| 33 |
local.get $yield |
| 34 |
local.get $fork |
| 35 |
ref.func $thread3 |
| 36 |
cont.new $func-cont-func-cont |
| 37 |
cont.bind $func-cont-func-cont $cont |
| 38 |
local.get $fork |
| 39 |
call_ref $cont-func |
| 40 |
i32.const 3 |
| 41 |
call $log |
| 42 |
) |
| 43 |
(func $thread1 (;2;) (type $func-cont-func-func) (param $yield (ref $func)) (param $fork (ref $cont-func)) |
| 44 |
i32.const 10 |
| 45 |
call $log |
| 46 |
local.get $yield |
| 47 |
call_ref $func |
| 48 |
i32.const 11 |
| 49 |
call $log |
| 50 |
local.get $yield |
| 51 |
call_ref $func |
| 52 |
i32.const 12 |
| 53 |
call $log |
| 54 |
) |
| 55 |
(func $thread2 (;3;) (type $func-cont-func-func) (param $yield (ref $func)) (param $fork (ref $cont-func)) |
| 56 |
i32.const 20 |
| 57 |
call $log |
| 58 |
local.get $yield |
| 59 |
call_ref $func |
| 60 |
i32.const 21 |
| 61 |
call $log |
| 62 |
local.get $yield |
| 63 |
call_ref $func |
| 64 |
i32.const 22 |
| 65 |
call $log |
| 66 |
) |
| 67 |
(func $thread3 (;4;) (type $func-cont-func-func) (param $yield (ref $func)) (param $fork (ref $cont-func)) |
| 68 |
i32.const 30 |
| 69 |
call $log |
| 70 |
local.get $yield |
| 71 |
call_ref $func |
| 72 |
i32.const 31 |
| 73 |
call $log |
| 74 |
local.get $yield |
| 75 |
call_ref $func |
| 76 |
i32.const 32 |
| 77 |
call $log |
| 78 |
) |
| 79 |
) |