wasmtime: Make StoreContextMut accessible in epoch deadline callback (#6075)

This commit changes the signature of the `Store::epoch_deadline_callback` to
take in `StoreContextMut` instead of a mutable reference to the store's data.

This is useful in cases in which the callback definition needs access to the
Store to be able to use other methods that take in `AsContext`/`AsContextMut`,
like for example `WasmtimeBacktrace::capture`
This commit is contained in:
Saúl Cabrera
2023-03-23 15:39:36 +01:00
committed by GitHub
parent 2fde25311e
commit a6925c21c5
2 changed files with 17 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ fn make_env<T>(engine: &Engine) -> Linker<T> {
enum InterruptMode {
Trap,
Callback(fn(&mut usize) -> Result<u64>),
Callback(fn(StoreContextMut<usize>) -> Result<u64>),
Yield(u64),
}
@@ -334,7 +334,8 @@ async fn epoch_callback_continue() {
(func $subfunc))
",
1,
InterruptMode::Callback(|s| {
InterruptMode::Callback(|mut cx| {
let s = cx.data_mut();
*s += 1;
Ok(1)
}),