Skip to content

Commit be0de78

Browse files
authored
Shuffle call state event codes (#1274)
Updating for WebAssembly/component-model#500
1 parent b8d39b3 commit be0de78

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

crates/guest-rust/rt/src/async_support.rs

+17-29
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,17 @@ impl FutureState {
117117

118118
fn callback(&mut self, event0: u32, event1: u32, event2: u32) -> u32 {
119119
match event0 {
120-
EVENT_NONE => {
121-
rtdebug!("EVENT_NONE");
122-
}
123-
EVENT_CALL_STARTED => {
124-
rtdebug!("EVENT_CALL_STARTED({event1:#x})");
125-
self.deliver_waitable_event(event1, STATUS_STARTED)
126-
}
127-
EVENT_CALL_RETURNED => {
128-
rtdebug!("EVENT_CALL_RETURNED({event1:#x})");
129-
self.deliver_waitable_event(event1, STATUS_RETURNED)
130-
}
131-
132-
EVENT_STREAM_READ | EVENT_STREAM_WRITE | EVENT_FUTURE_READ | EVENT_FUTURE_WRITE => {
133-
rtdebug!(
134-
"EVENT_{{STREAM,FUTURE}}_{{READ,WRITE}}({event0:#x}, {event1:#x}, {event2:#x})"
135-
);
136-
self.deliver_waitable_event(event1, event2)
137-
}
138-
120+
EVENT_NONE => rtdebug!("EVENT_NONE"),
121+
EVENT_SUBTASK => rtdebug!("EVENT_SUBTASK({event1:#x}, {event2:#x})"),
122+
EVENT_STREAM_READ => rtdebug!("EVENT_STREAM_READ({event1:#x}, {event2:#x})"),
123+
EVENT_STREAM_WRITE => rtdebug!("EVENT_STREAM_WRITE({event1:#x}, {event2:#x})"),
124+
EVENT_FUTURE_READ => rtdebug!("EVENT_FUTURE_READ({event1:#x}, {event2:#x})"),
125+
EVENT_FUTURE_WRITE => rtdebug!("EVENT_FUTURE_WRITE({event1:#x}, {event2:#x})"),
139126
_ => unreachable!(),
140127
}
128+
if event0 != EVENT_NONE {
129+
self.deliver_waitable_event(event1, event2)
130+
}
141131

142132
loop {
143133
match self.poll() {
@@ -270,22 +260,20 @@ impl Wake for FutureWaker {
270260
static mut SPAWNED: Vec<BoxFuture> = Vec::new();
271261

272262
const EVENT_NONE: u32 = 0;
273-
const _EVENT_CALL_STARTING: u32 = 1;
274-
const EVENT_CALL_STARTED: u32 = 2;
275-
const EVENT_CALL_RETURNED: u32 = 3;
276-
const EVENT_STREAM_READ: u32 = 5;
277-
const EVENT_STREAM_WRITE: u32 = 6;
278-
const EVENT_FUTURE_READ: u32 = 7;
279-
const EVENT_FUTURE_WRITE: u32 = 8;
263+
const EVENT_SUBTASK: u32 = 1;
264+
const EVENT_STREAM_READ: u32 = 2;
265+
const EVENT_STREAM_WRITE: u32 = 3;
266+
const EVENT_FUTURE_READ: u32 = 4;
267+
const EVENT_FUTURE_WRITE: u32 = 5;
280268

281269
const CALLBACK_CODE_EXIT: u32 = 0;
282270
const CALLBACK_CODE_YIELD: u32 = 1;
283271
const CALLBACK_CODE_WAIT: u32 = 2;
284272
const _CALLBACK_CODE_POLL: u32 = 3;
285273

286-
const STATUS_STARTING: u32 = 1;
287-
const STATUS_STARTED: u32 = 2;
288-
const STATUS_RETURNED: u32 = 3;
274+
const STATUS_STARTING: u32 = 0;
275+
const STATUS_STARTED: u32 = 1;
276+
const STATUS_RETURNED: u32 = 2;
289277

290278
const BLOCKED: u32 = 0xffff_ffff;
291279
const COMPLETED: u32 = 0x0;

0 commit comments

Comments
 (0)