Skip to content

Commit 42e78f3

Browse files
committed
Async CABI: add <memidx> to task.poll/task.wait instead of using Task.opts.memory
1 parent a618ba8 commit 42e78f3

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

design/mvp/Binary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
287287
| 0x06 => (canon thread.hw_concurrency (core func)) 🧵
288288
| 0x08 => (canon task.backpressure (core func)) 🔀
289289
| 0x09 ft:<core:typeidx> => (canon task.return ft (core func)) 🔀
290-
| 0x0a => (canon task.wait (core func)) 🔀
291-
| 0x0b => (canon task.poll (core func)) 🔀
290+
| 0x0a m:<core:memdix> => (canon task.wait (memory m) (core func)) 🔀
291+
| 0x0b m:<core:memidx> => (canon task.poll (memory m) (core func)) 🔀
292292
| 0x0c => (canon task.yield (core func)) 🔀
293293
| 0x0d => (canon subtask.drop (core func)) 🔀
294294
opts ::= opt*:vec(<canonopt>) => opt*

design/mvp/CanonicalABI.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,11 +2353,12 @@ Calling `$f` waits for progress to be made in a subtask of the current task,
23532353
returning the event (which is currently simply an `CallState` value)
23542354
and writing the subtask index as an outparam:
23552355
```python
2356-
async def canon_task_wait(task, ptr):
2356+
async def canon_task_wait(opts, task, ptr):
23572357
trap_if(not task.inst.may_leave)
23582358
trap_if(task.opts.callback is not None)
23592359
event, payload = await task.wait()
2360-
store(task, payload, U32Type(), ptr)
2360+
cx = CallContext(opts, task.inst, task)
2361+
store(cx, payload, U32Type(), ptr)
23612362
return [event]
23622363
```
23632364
The `trap_if` ensures that, when a component uses a `callback` all events flow

design/mvp/Explainer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,8 @@ canon ::= ...
13131313
| (canon resource.rep <typeidx> (core func <id>?))
13141314
| (canon task.backpressure (core func <id>?)) 🔀
13151315
| (canon task.return <core:typeidx> (core func <id>?)) 🔀
1316-
| (canon task.wait (core func <id>?)) 🔀
1317-
| (canon task.poll (core func <id>?)) 🔀
1316+
| (canon task.wait (memory <core:memidx>) (core func <id>?)) 🔀
1317+
| (canon task.poll (memory <core:memidx>) (core func <id>?)) 🔀
13181318
| (canon task.yield (core func <id>?)) 🔀
13191319
| (canon subtask.drop (core func <id>?)) 🔀
13201320
| (canon thread.spawn <typeidx> (core func <id>?)) 🧵

design/mvp/canonical-abi/definitions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,21 +1530,23 @@ async def canon_task_return(task, core_ft, flat_args):
15301530

15311531
### 🔀 `canon task.wait`
15321532

1533-
async def canon_task_wait(task, ptr):
1533+
async def canon_task_wait(opts, task, ptr):
15341534
trap_if(not task.inst.may_leave)
15351535
trap_if(task.opts.callback is not None)
15361536
event, payload = await task.wait()
1537-
store(task, payload, U32Type(), ptr)
1537+
cx = CallContext(opts, task.inst, task)
1538+
store(cx, payload, U32Type(), ptr)
15381539
return [event]
15391540

15401541
### 🔀 `canon task.poll`
15411542

1542-
async def canon_task_poll(task, ptr):
1543+
async def canon_task_poll(opts, task, ptr):
15431544
trap_if(not task.inst.may_leave)
15441545
ret = await task.poll()
15451546
if ret is None:
15461547
return [0]
1547-
store(task, ret, TupleType([U32Type(), U32Type()]), ptr)
1548+
cx = CallContext(opts, task.inst, task)
1549+
store(cx, ret, TupleType([U32Type(), U32Type()]), ptr)
15481550
return [1]
15491551

15501552
### 🔀 `canon task.yield`

0 commit comments

Comments
 (0)