|
1 | 1 | ;; This test contains 3 components, $AsyncInner, $SyncMiddle and $AsyncOuter, |
2 | 2 | ;; where there are two instances of $SyncMiddle that import a single instance |
3 | 3 | ;; of $AsyncInner, and $AsyncOuter imports all 3 preceding instances. |
4 | | -;; |
| 4 | +;; |
5 | 5 | ;; $AsyncOuter.run asynchronously calls $SyncMiddle.sync-func twice concurrently |
6 | 6 | ;; in each instance (4 total calls), hitting the synchronous backpressure case |
7 | 7 | ;; in 2 of the 4 calls. |
|
19 | 19 |
|
20 | 20 | (memory 1) |
21 | 21 | (global $blocked (mut i32) (i32.const 1)) |
22 | | - (global $counter (mut i32) (i32.const 3)) |
| 22 | + (global $counter (mut i32) (i32.const 2)) |
23 | 23 |
|
24 | 24 | ;; 'blocking-call' cooperatively "spin-waits" until $blocked is 0. |
25 | 25 | (func $blocking-call (export "blocking-call") (result i32) |
|
136 | 136 | ;; (on $AsyncInner.blocking-call). because 'sync-func1/2' are in different instances, |
137 | 137 | ;; both calls will reach the STARTED state. |
138 | 138 | (local.set $ret (call $sync-func1 (i32.const 8))) |
139 | | - (if (i32.ne (i32.const 0x31 (; STARTED=1 | (subtask=3 << 4) ;)) (local.get $ret)) |
| 139 | + (if (i32.ne (i32.const 0x21 (; STARTED=1 | (subtask=2 << 4) ;)) (local.get $ret)) |
140 | 140 | (then unreachable)) |
141 | | - (call $waitable.join (i32.const 3) (global.get $ws)) |
| 141 | + (call $waitable.join (i32.const 2) (global.get $ws)) |
142 | 142 | (local.set $ret (call $sync-func2 (i32.const 12))) |
143 | | - (if (i32.ne (i32.const 0x41 (; STARTED=1 | (subtask=4 << 4) ;)) (local.get $ret)) |
| 143 | + (if (i32.ne (i32.const 0x31 (; STARTED=1 | (subtask=3 << 4) ;)) (local.get $ret)) |
144 | 144 | (then unreachable)) |
145 | | - (call $waitable.join (i32.const 4) (global.get $ws)) |
| 145 | + (call $waitable.join (i32.const 3) (global.get $ws)) |
146 | 146 |
|
147 | 147 | ;; now start another pair of 'sync-func1/2' calls, both of which should see auto |
148 | 148 | ;; backpressure and get stuck in the STARTING state. |
149 | 149 | (local.set $ret (call $sync-func1 (i32.const 16))) |
150 | | - (if (i32.ne (i32.const 0x50 (; STARTING=0 | (subtask=5 << 4) ;)) (local.get $ret)) |
| 150 | + (if (i32.ne (i32.const 0x40 (; STARTING=0 | (subtask=4 << 4) ;)) (local.get $ret)) |
151 | 151 | (then unreachable)) |
152 | | - (call $waitable.join (i32.const 5) (global.get $ws)) |
| 152 | + (call $waitable.join (i32.const 4) (global.get $ws)) |
153 | 153 | (local.set $ret (call $sync-func2 (i32.const 20))) |
154 | | - (if (i32.ne (i32.const 0x60 (; STARTING=0 | (subtask=6 << 4) ;)) (local.get $ret)) |
| 154 | + (if (i32.ne (i32.const 0x50 (; STARTING=0 | (subtask=5 << 4) ;)) (local.get $ret)) |
155 | 155 | (then unreachable)) |
156 | | - (call $waitable.join (i32.const 6) (global.get $ws)) |
| 156 | + (call $waitable.join (i32.const 5) (global.get $ws)) |
157 | 157 |
|
158 | 158 | ;; unblock all the tasks and start waiting to complete |
159 | 159 | (call $unblock) |
|
167 | 167 | (then unreachable)) |
168 | 168 |
|
169 | 169 | ;; if we receive a SUBTASK STARTED event, it should only be for the 3rd or |
170 | | - ;; 4th subtask (at indices 5/6, resp), so keep waiting for completion |
| 170 | + ;; 4th subtask (at indices 4/5, resp), so keep waiting for completion |
171 | 171 | (if (i32.eq (local.get $payload) (i32.const 1 (; STARTED ;))) (then |
172 | 172 | (if (i32.and |
173 | | - (i32.ne (local.get $index) (i32.const 5)) |
174 | | - (i32.ne (local.get $index) (i32.const 6))) |
| 173 | + (i32.ne (local.get $index) (i32.const 4)) |
| 174 | + (i32.ne (local.get $index) (i32.const 5))) |
175 | 175 | (then unreachable)) |
176 | 176 | (return (i32.or (i32.const 2 (; WAIT ;)) (i32.shl (global.get $ws) (i32.const 4)))) |
177 | 177 | )) |
178 | 178 |
|
179 | 179 | ;; when we receive a SUBTASK RETURNED event, check the return value is equal to the |
180 | | - ;; subtask index (which we've ensured by having $AsyncInner.$counter start at 3, the |
181 | | - ;; first subtask index. The address of the return buffer is the index-1*4. |
| 180 | + ;; subtask index (which we've ensured by having $AsyncInner.$counter start at 2, the |
| 181 | + ;; first subtask index. The address of the return buffer is the index*4. |
182 | 182 | (if (i32.ne (local.get $payload) (i32.const 2 (; RETURNED ;))) |
183 | 183 | (then unreachable)) |
184 | | - (if (i32.ne (local.get $index) (i32.load (i32.mul (i32.sub (local.get $index) (i32.const 1)) (i32.const 4)))) |
| 184 | + (if (i32.ne (local.get $index) (i32.load (i32.mul (local.get $index) (i32.const 4)))) |
185 | 185 | (then unreachable)) |
186 | 186 |
|
187 | 187 | ;; decrement $remain and exit if 0 |
|
0 commit comments