-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Per the waPC specifications it looks like after the guest is invoked initially, the supported flow is the guest is allowed to make 0..N __host_call
before returning.
There's another flow, where communication is bi-directional, or where multiple __guest_call
s occur from a single invoke
:
- Guest is invoked
- Guest does some work, and calls host
- Host starts a new
__guest_call
- ... new flow starts. Guest eventually returns results to host
- Host returns results to guest
- Guest returns
This flow currently fails for the final __guest_call
in wasmer
(assumption is it also fails in wasmtime
), but works for wazero
. This is due to the use of invokeContext
. In wasmer
/ wasmtime
this is a pointer stored on the shared instance and the response copied to it (here), but the return value of invoke
is read from the original invokeContext
(here). With multiple __guest_call
in a single flow, the shared context is replaced. The output is copied to the invokeContext
of the previous __guest_call
and the final __guest_call
in the chain returns a zero value.
wazero
supports this flow since each __guest_call
via invoke
using wazero
gets its own context, not a shared context on the instance (here).
Whew, with that out of the way. Is the above bi-directional flow supported? If not, should it be supported and the implementation for wasmer
and wasmtime
changed to allow it?