Debian Codegraph @

tests/snapshots/cli/stack-switching/actor.wast/4.print

raw
1 (module $queue
2 (type $func (;0;) (func))
3 (type $cont (;1;) (cont $func))
4 (type (;2;) (func (param i32)))
5 (type (;3;) (func (result i32)))
6 (type (;4;) (func (result (ref null $cont))))
7 (type (;5;) (func (param (ref $cont))))
8 (import "spectest" "print_i32" (func $log (;0;) (type 2)))
9 (table $queue (;0;) 0 (ref null $cont))
10 (memory (;0;) 1)
11 (tag $too-many-mailboxes (;0;) (type $func))
12 (global $qdelta (;0;) i32 i32.const 10)
13 (global $qback-k (;1;) (mut i32) i32.const 0)
14 (global $qfront-k (;2;) (mut i32) i32.const 0)
15 (global $qback-mb (;3;) (mut i32) i32.const 0)
16 (global $qfront-mb (;4;) (mut i32) i32.const 0)
17 (export "queue-empty" (func $queue-empty-k))
18 (export "dequeue-k" (func $dequeue-k))
19 (export "enqueue-k" (func $enqueue-k))
20 (export "queue-empty-mb" (func $queue-empty-mb))
21 (export "dequeue-mb" (func $dequeue-mb))
22 (export "enqueue-mb" (func $enqueue-mb))
23 (func $queue-empty-k (;1;) (type 3) (result i32)
24 global.get $qfront-k
25 global.get $qback-k
26 i32.eq
27 )
28 (func $dequeue-k (;2;) (type 4) (result (ref null $cont))
29 (local $i i32)
30 call $queue-empty-k
31 if ;; label = @1
32 ref.null $cont
33 return
34 end
35 global.get $qfront-k
36 local.set $i
37 local.get $i
38 i32.const 1
39 i32.add
40 global.set $qfront-k
41 local.get $i
42 table.get $queue
43 )
44 (func $enqueue-k (;3;) (type 5) (param $k (ref $cont))
45 global.get $qback-k
46 table.size $queue
47 i32.eq
48 if ;; label = @1
49 global.get $qfront-k
50 global.get $qdelta
51 i32.lt_u
52 if ;; label = @2
53 ref.null $cont
54 global.get $qdelta
55 table.grow $queue
56 drop
57 else
58 global.get $qback-k
59 global.get $qfront-k
60 i32.sub
61 global.set $qback-k
62 i32.const 0
63 global.get $qfront-k
64 global.get $qback-k
65 table.copy
66 global.get $qback-k
67 ref.null $cont
68 global.get $qfront-k
69 table.fill $queue
70 i32.const 0
71 global.set $qfront-k
72 end
73 end
74 global.get $qback-k
75 local.get $k
76 table.set $queue
77 global.get $qback-k
78 i32.const 1
79 i32.add
80 global.set $qback-k
81 )
82 (func $queue-empty-mb (;4;) (type 3) (result i32)
83 global.get $qfront-mb
84 global.get $qback-mb
85 i32.eq
86 )
87 (func $dequeue-mb (;5;) (type 3) (result i32)
88 (local $i i32) (local $mb i32)
89 call $queue-empty-mb
90 if ;; label = @1
91 i32.const -1
92 return
93 end
94 global.get $qfront-mb
95 local.set $i
96 local.get $i
97 i32.const 1
98 i32.add
99 global.set $qfront-mb
100 local.get $i
101 i32.const 4
102 i32.mul
103 i32.load
104 local.set $mb
105 local.get $mb
106 return
107 )
108 (func $enqueue-mb (;6;) (type 2) (param $mb i32)
109 global.get $qback-mb
110 i32.const 16383
111 i32.eq
112 if ;; label = @1
113 global.get $qfront-mb
114 global.get $qdelta
115 i32.lt_u
116 if ;; label = @2
117 throw $too-many-mailboxes
118 else
119 global.get $qback-mb
120 global.get $qfront-mb
121 i32.sub
122 global.set $qback-mb
123 i32.const 0
124 global.get $qfront-mb
125 i32.const 4
126 i32.mul
127 global.get $qback-mb
128 i32.const 4
129 i32.mul
130 memory.copy
131 global.get $qback-mb
132 i32.const 4
133 i32.mul
134 i32.const -1
135 global.get $qfront-mb
136 i32.const 4
137 i32.mul
138 memory.fill
139 i32.const 0
140 global.set $qfront-mb
141 end
142 end
143 global.get $qback-mb
144 i32.const 4
145 i32.mul
146 local.get $mb
147 i32.store
148 global.get $qback-mb
149 i32.const 1
150 i32.add
151 global.set $qback-mb
152 )
153 )