|
4 | 4 | ;; $Tester is created to run each test. |
5 | 5 | (component definition $Tester |
6 | 6 | (component $C |
| 7 | + (core module $Memory (memory (export "mem") 1)) |
| 8 | + (core instance $memory (instantiate $Memory)) |
7 | 9 | (core module $CM |
| 10 | + (import "" "waitable-set.new" (func $waitable-set.new (result i32))) |
| 11 | + (import "" "waitable-set.wait" (func $waitable-set.wait (param i32 i32) (result i32))) |
8 | 12 | (func (export "sync-async-func") |
9 | 13 | unreachable |
10 | 14 | ) |
|
14 | 18 | (func (export "async-async-func-cb") (param i32 i32 i32) (result i32) |
15 | 19 | unreachable |
16 | 20 | ) |
| 21 | + (func (export "sync-blocks-and-traps") |
| 22 | + (call $waitable-set.wait (call $waitable-set.new) (i32.const 0xdeadbeef)) |
| 23 | + unreachable |
| 24 | + ) |
17 | 25 | ) |
18 | | - (core instance $cm (instantiate $CM)) |
| 26 | + (canon waitable-set.new (core func $waitable-set.new)) |
| 27 | + (canon waitable-set.wait (memory $memory "mem") (core func $waitable-set.wait)) |
| 28 | + (core instance $cm (instantiate $CM (with "" (instance |
| 29 | + (export "waitable-set.new" (func $waitable-set.new)) |
| 30 | + (export "waitable-set.wait" (func $waitable-set.wait)) |
| 31 | + )))) |
19 | 32 | (func (export "sync-async-func") async (canon lift (core func $cm "sync-async-func"))) |
20 | 33 | (func (export "async-async-func") async (canon lift (core func $cm "async-async-func") async (callback (func $cm "async-async-func-cb")))) |
| 34 | + (func (export "sync-blocks-and-traps") (canon lift (core func $cm "sync-blocks-and-traps"))) |
21 | 35 | ) |
22 | 36 | (component $D |
23 | 37 | (import "c" (instance $c |
24 | 38 | (export "sync-async-func" (func async)) |
25 | 39 | (export "async-async-func" (func async)) |
| 40 | + (export "sync-blocks-and-traps" (func)) |
26 | 41 | )) |
27 | 42 |
|
28 | 43 | (core module $Memory (memory (export "mem") 1)) |
|
55 | 70 | (import "" "future.cancel-write" (func $future.cancel-write (param i32) (result i32))) |
56 | 71 | (import "" "await-sync-async-func" (func $await-sync-async-func)) |
57 | 72 | (import "" "await-async-async-func" (func $await-async-async-func)) |
| 73 | + (import "" "sync-blocks-and-traps" (func $sync-blocks-and-traps)) |
58 | 74 | (import "" "__indirect_function_table" (table $indirect-function-table 2 funcref)) |
59 | 75 |
|
60 | 76 | (func (export "unreachable-cb") (param i32 i32 i32) (result i32) |
|
71 | 87 | (func (export "trap-if-sync-call-async2") |
72 | 88 | (call $await-async-async-func) |
73 | 89 | ) |
| 90 | + (func (export "trap-if-async-calls-sync-and-blocks") (result i32) |
| 91 | + (call $sync-blocks-and-traps) |
| 92 | + unreachable |
| 93 | + ) |
74 | 94 | (func (export "trap-if-suspend") |
75 | 95 | (call $thread.suspend) |
76 | 96 | unreachable |
|
192 | 212 | (canon future.cancel-write $FT (core func $future.cancel-write)) |
193 | 213 | (canon lower (func $c "sync-async-func") (core func $await-sync-async-func')) |
194 | 214 | (canon lower (func $c "async-async-func") (core func $await-async-async-func')) |
| 215 | + (canon lower (func $c "sync-blocks-and-traps") (core func $sync-blocks-and-traps')) |
195 | 216 | (core instance $core (instantiate $Core (with "" (instance |
196 | 217 | (export "mem" (memory $memory "mem")) |
197 | 218 | (export "task.return" (func $task.return)) |
|
217 | 238 | (export "future.cancel-write" (func $future.cancel-write)) |
218 | 239 | (export "await-sync-async-func" (func $await-sync-async-func')) |
219 | 240 | (export "await-async-async-func" (func $await-async-async-func')) |
| 241 | + (export "sync-blocks-and-traps" (func $sync-blocks-and-traps')) |
220 | 242 | (export "__indirect_function_table" (table $indirect-function-table)) |
221 | 243 | )))) |
222 | 244 | (func (export "trap-if-suspend") (canon lift (core func $core "trap-if-suspend"))) |
|
231 | 253 | (func (export "resume-later-is-fine") (result u32) (canon lift (core func $core "resume-later-is-fine"))) |
232 | 254 | (func (export "trap-if-sync-call-async1") (canon lift (core func $core "trap-if-sync-call-async1"))) |
233 | 255 | (func (export "trap-if-sync-call-async2") (canon lift (core func $core "trap-if-sync-call-async2"))) |
| 256 | + (func (export "trap-if-async-calls-sync-and-blocks") (canon lift (core func $core "trap-if-async-calls-sync-and-blocks") async (callback (func $core "unreachable-cb")))) |
234 | 257 | (func (export "trap-if-sync-cancel") (canon lift (core func $core "trap-if-sync-cancel"))) |
235 | 258 | (func (export "trap-if-sync-stream-read") (canon lift (core func $core "trap-if-sync-stream-read"))) |
236 | 259 | (func (export "trap-if-sync-stream-write") (canon lift (core func $core "trap-if-sync-stream-write"))) |
|
245 | 268 | (instance $d (instantiate $D (with "c" (instance $c)))) |
246 | 269 | (func (export "trap-if-sync-call-async1") (alias export $d "trap-if-sync-call-async1")) |
247 | 270 | (func (export "trap-if-sync-call-async2") (alias export $d "trap-if-sync-call-async2")) |
| 271 | + (func (export "trap-if-async-calls-sync-and-blocks") (alias export $d "trap-if-async-calls-sync-and-blocks")) |
248 | 272 | (func (export "trap-if-suspend") (alias export $d "trap-if-suspend")) |
249 | 273 | (func (export "trap-if-wait") (alias export $d "trap-if-wait")) |
250 | 274 | (func (export "trap-if-wait-cb") (alias export $d "trap-if-wait-cb")) |
|
271 | 295 | (component instance $i $Tester) |
272 | 296 | (assert_trap (invoke "trap-if-sync-call-async2") "cannot block a synchronous task before returning") |
273 | 297 | (component instance $i $Tester) |
| 298 | +(assert_trap (invoke "trap-if-async-calls-sync-and-blocks") "cannot block a synchronous task before returning") |
| 299 | +(component instance $i $Tester) |
274 | 300 | (assert_trap (invoke "trap-if-suspend") "cannot block a synchronous task before returning") |
275 | 301 | (component instance $i $Tester) |
276 | 302 | (assert_trap (invoke "trap-if-wait") "cannot block a synchronous task before returning") |
|
0 commit comments