-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relaxing static lifetime of Func::wrap arguments #2159
Comments
The wasmtime/crates/wasmtime/src/func.rs Line 1554 in c7cd70f
wasmtime/crates/wasmtime/src/func.rs Line 1586 in c7cd70f
|
This bound is necessary because wasmtime/crates/wasmtime/src/func.rs Lines 144 to 148 in c7cd70f
|
Which in turn is necessary because wasmtime/crates/wasmtime/src/instance.rs Lines 99 to 103 in c7cd70f
|
Due to the memory management of wasm objects right now (e.g. instances and stores) everything must live for the It's worth noting though that a form of stack switching like you're trying to use is something we're interested in providing first-class support for. There's a few wasm proposals in flight but we'd like to have something at least for async in the meantime as well. Basically just to say that this is likely to be supported in some fashion in the future. |
Thank you for the feedback! I will probably just cast it to a pointer and back to "cheat" the lifetime. The function will be only called while inside the closure, so it should be safe.
I'm really interested in this. Are there maybe some issues open where I could follow the development of this or some places where the discussion was started? I could not find any active proposals regarding it. |
Andreas Rossberg has presented at several CG meetings in the past year about approaches to stack switching based on delimited continuations. It does not appear that there is any formal proposal work in https://github.com/WebAssembly/proposals at this time, but the work is something the Bytecode Alliance is very interested in implementing. Lucet already has some limited support for stack switching (it is not as general or powerful as Andreas's proposal) and this PR uses it to enable async computations which suspend the wasm stack. We will need to implement something similar in Wasmtime as part of our plans to merge the features of the two runtimes. bytecodealliance/lucet#551 |
I've also toyed with using a generator (from the I am looking forward to first-class support for this in Wasmtime. |
Thank you everyone for the discussion. The restrictions are much clearer to me now. I will close this issue as I don't think there is any straightforward way right now to reduce the lifetime from |
Hi! I'm trying to use Wasmtime inside a generator. I would like to provide a host function to suspend the execution by yielding from the generator. This is my current attempt:
I had now multiple attempts of passing
yielder
inside the closure, but nothing worked. I always get a lifetime related error:It's not clear to me why the passed in closure needs to be static. Can this requirement be relaxed? Or is there maybe a better way of approaching this?
Could
yielder
be attached toCaller
and then later accessed?The text was updated successfully, but these errors were encountered: