(module (type $proc (;0;) (func)) (type $pproc (;1;) (func (param i32))) (type $cont (;2;) (cont $proc)) (type $pcont (;3;) (cont $pproc)) (type (;4;) (func (param (ref $cont)))) (type (;5;) (func (param i32 i32))) (import "scheduler" "yield" (tag $yield (;0;) (type $proc))) (import "scheduler" "spawn" (tag $spawn (;1;) (type 4) (param (ref $cont)))) (import "scheduler" "scheduler" (func $scheduler (;0;) (type 4))) (import "spectest" "print_i32" (func $log (;1;) (type $pproc))) (global $width (;0;) (mut i32) i32.const 0) (global $depth (;1;) (mut i32) i32.const 0) (export "run" (func 6)) (elem (;0;) declare func $main $thread1 $thread2 $thread3) (func $main (;2;) (type $proc) i32.const 0 call $log ref.func $thread1 cont.new $cont suspend $spawn i32.const 1 call $log global.get $depth ref.func $thread2 cont.new $pcont cont.bind $pcont $cont suspend $spawn i32.const 2 call $log ref.func $thread3 cont.new $cont suspend $spawn i32.const 3 call $log ) (func $thread1 (;3;) (type $proc) i32.const 10 call $log suspend $yield i32.const 11 call $log suspend $yield i32.const 12 call $log suspend $yield i32.const 13 call $log ) (func $thread2 (;4;) (type $pproc) (param $d i32) (local $w i32) global.get $width local.set $w i32.const 20 call $log local.get $d i32.eqz br_if 0 i32.const 21 call $log loop $l local.get $w if ;; label = @2 i32.const 22 call $log suspend $yield i32.const 23 call $log local.get $d i32.const 1 i32.sub ref.func $thread2 cont.new $pcont cont.bind $pcont $cont suspend $spawn i32.const 24 call $log local.get $w i32.const 1 i32.sub local.set $w br $l end end i32.const 25 call $log ) (func $thread3 (;5;) (type $proc) i32.const 30 call $log suspend $yield i32.const 31 call $log suspend $yield i32.const 32 call $log ) (func (;6;) (type 5) (param $width i32) (param $depth i32) local.get $depth global.set $depth local.get $width global.set $width i32.const -1 call $log ref.func $main cont.new $cont call $scheduler i32.const -2 call $log ) )