Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07bd52f
generalize async fiber abstraction
dicej Jun 17, 2025
66ce1cd
address review feedback
dicej Jun 24, 2025
ae227b6
fix miri-flagged stacked borrow violation
dicej Jun 24, 2025
8b8ecb1
remove unneeded `Send` bounds
dicej Jun 24, 2025
bd20d14
address more review feedback
dicej Jun 24, 2025
45859eb
address more review feedback
dicej Jun 24, 2025
77d0a80
update `impl Send For StoreFiber` comment
dicej Jun 24, 2025
8a8768e
Remove currently-extraneous `Result<()>` from fibers
alexcrichton Jun 25, 2025
b67b8b8
Use safe pointers instead of raw pointers
alexcrichton Jun 25, 2025
fee87ee
Fold more responsibility into `resume_fiber_raw`
alexcrichton Jun 25, 2025
3de8282
Remove channels from async fibers
alexcrichton Jun 25, 2025
dbc0b7d
Fold `on_fiber_raw` directly into `on_fiber`
alexcrichton Jun 25, 2025
7562905
Don't use `Option` in `FiberFuture`
alexcrichton Jun 25, 2025
b9926c6
Fold `suspend` functions together
alexcrichton Jun 25, 2025
44c96f8
Move stack limit management to `FiberResumeState`
alexcrichton Jun 25, 2025
97e6aef
add some doc comments to `fiber.rs`
dicej Jun 25, 2025
9d95bbb
update `fiber.rs` and friends to match CM async requirements
dicej Jun 25, 2025
8edeb24
fix non-component-model-async build warnings
dicej Jun 25, 2025
3806f68
make `resume_fiber` private in `fiber.rs`
dicej Jun 25, 2025
7afd823
Shrink `PollContext` state
alexcrichton Jun 25, 2025
057a923
Refactor `AsyncCx`, reduce `unsafe`
alexcrichton Jun 25, 2025
2942248
Adjust some lint attributes
alexcrichton Jun 26, 2025
3e92492
Make manipulation of `AsyncState` safe
alexcrichton Jun 26, 2025
f45ea3a
Fix dead code warning
alexcrichton Jun 26, 2025
37630c0
More dead code warnings
alexcrichton Jun 26, 2025
c28dfaa
Cut down on raw pointers in fiber.rs
alexcrichton Jun 26, 2025
8adfffb
Move executor save/restore to normal fiber state save/restore
alexcrichton Jun 26, 2025
141d70e
Bikeshed a method name
alexcrichton Jun 26, 2025
691e58f
update comment in make_fiber
dicej Jun 26, 2025
c3cb184
fix machports build
dicej Jun 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions crates/wasmtime/src/runtime/component/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use crate::component::types;
use crate::component::{
Component, ComponentNamedList, Instance, InstancePre, Lift, Lower, ResourceType, Val,
};
#[cfg(feature = "async")]
use crate::fiber::AsyncCx;
use crate::hash_map::HashMap;
use crate::prelude::*;
use crate::{AsContextMut, Engine, Module, StoreContextMut};
Expand Down Expand Up @@ -443,12 +441,8 @@ impl<T: 'static> LinkerInstance<'_, T> {
self.engine.config().async_support,
"cannot use `func_wrap_async` without enabling async support in the config"
);
let ff = move |mut store: StoreContextMut<'_, T>, params: Params| -> Result<Return> {
let async_cx = AsyncCx::new(&mut store.0);
let mut future = Pin::from(f(store.as_context_mut(), params));
// SAFETY: The `Store` we used to create the `AsyncCx` above remains
// valid.
unsafe { async_cx.block_on(future.as_mut())? }
let ff = move |store: StoreContextMut<'_, T>, params: Params| -> Result<Return> {
store.block_on(|store| f(store, params).into())?
};
self.func_wrap(name, ff)
}
Expand Down Expand Up @@ -607,14 +601,10 @@ impl<T: 'static> LinkerInstance<'_, T> {
self.engine.config().async_support,
"cannot use `func_new_async` without enabling async support in the config"
);
let ff = move |mut store: StoreContextMut<'_, T>, params: &[Val], results: &mut [Val]| {
let async_cx = AsyncCx::new(&mut store.0);
let mut future = Pin::from(f(store.as_context_mut(), params, results));
// SAFETY: The `Store` we used to create the `AsyncCx` above remains
// valid.
unsafe { async_cx.block_on(future.as_mut())? }
let ff = move |store: StoreContextMut<'_, T>, params: &[Val], results: &mut [Val]| {
store.with_blocking(|store, cx| cx.block_on(Pin::from(f(store, params, results)))?)
};
self.func_new(name, ff)
return self.func_new(name, ff);
}

/// Defines a [`Module`] within this instance.
Expand Down Expand Up @@ -682,14 +672,8 @@ impl<T: 'static> LinkerInstance<'_, T> {
let dtor = Arc::new(crate::func::HostFunc::wrap_inner(
&self.engine,
move |mut cx: crate::Caller<'_, T>, (param,): (u32,)| {
let async_cx = AsyncCx::new(&mut cx.as_context_mut().0);
let mut future = Pin::from(dtor(cx.as_context_mut(), param));
// SAFETY: The `Store` we used to create the `AsyncCx` above
// remains valid.
match unsafe { async_cx.block_on(future.as_mut()) } {
Ok(Ok(())) => Ok(()),
Ok(Err(trap)) | Err(trap) => Err(trap),
}
cx.as_context_mut()
.block_on(|store| dtor(store, param).into())?
},
));
self.insert(name, Definition::Resource(ty, dtor))?;
Expand Down
Loading