| 1 |
(module $example |
| 2 |
(type $func (;0;) (func)) |
| 3 |
(type $cont (;1;) (cont $func)) |
| 4 |
(type (;2;) (func (param (ref $cont)))) |
| 5 |
(type (;3;) (func (param i32))) |
| 6 |
(import "lwt" "yield" (tag $yield (;0;) (type $func))) |
| 7 |
(import "lwt" "fork" (tag $fork (;1;) (type 2) (param (ref $cont)))) |
| 8 |
(import "spectest" "print_i32" (func $log (;0;) (type 3))) |
| 9 |
(export "main" (func $main)) |
| 10 |
(elem (;0;) declare func $thread1 $thread2 $thread3) |
| 11 |
(func $main (;1;) (type $func) |
| 12 |
i32.const 0 |
| 13 |
call $log |
| 14 |
ref.func $thread1 |
| 15 |
cont.new $cont |
| 16 |
suspend $fork |
| 17 |
i32.const 1 |
| 18 |
call $log |
| 19 |
ref.func $thread2 |
| 20 |
cont.new $cont |
| 21 |
suspend $fork |
| 22 |
i32.const 2 |
| 23 |
call $log |
| 24 |
ref.func $thread3 |
| 25 |
cont.new $cont |
| 26 |
suspend $fork |
| 27 |
i32.const 3 |
| 28 |
call $log |
| 29 |
) |
| 30 |
(func $thread1 (;2;) (type $func) |
| 31 |
i32.const 10 |
| 32 |
call $log |
| 33 |
suspend $yield |
| 34 |
i32.const 11 |
| 35 |
call $log |
| 36 |
suspend $yield |
| 37 |
i32.const 12 |
| 38 |
call $log |
| 39 |
) |
| 40 |
(func $thread2 (;3;) (type $func) |
| 41 |
i32.const 20 |
| 42 |
call $log |
| 43 |
suspend $yield |
| 44 |
i32.const 21 |
| 45 |
call $log |
| 46 |
suspend $yield |
| 47 |
i32.const 22 |
| 48 |
call $log |
| 49 |
) |
| 50 |
(func $thread3 (;4;) (type $func) |
| 51 |
i32.const 30 |
| 52 |
call $log |
| 53 |
suspend $yield |
| 54 |
i32.const 31 |
| 55 |
call $log |
| 56 |
suspend $yield |
| 57 |
i32.const 32 |
| 58 |
call $log |
| 59 |
) |
| 60 |
) |