Return a closure which will call the specified function in the scope of the specified task. This will use `GuestTask::lower_params` to lower the parameters, but will not lift the result; instead, it returns a `[MaybeUninit ; MAX_FLAT_PARAMS]` from which the result, if any, may be lifted. Note that an async-lifted export will have returned its result using the `task.return` intrinsic (or n
(
store: StoreContextMut<T>,
guest_thread: QualifiedThreadId,
callee: SendSyncPtr<VMFuncRef>,
param_count: usize,
result_count: usize,
| 2366 | /// SAFETY: `callee` must be a valid `*mut VMFuncRef` at the time when |
| 2367 | /// the returned closure is called. |
| 2368 | unsafe fn make_call<T: 'static>( |
| 2369 | store: StoreContextMut<T>, |
| 2370 | guest_thread: QualifiedThreadId, |
| 2371 | callee: SendSyncPtr<VMFuncRef>, |
| 2372 | param_count: usize, |
| 2373 | result_count: usize, |
| 2374 | ) -> impl FnOnce(&mut dyn VMStore) -> Result<[MaybeUninit<ValRaw>; MAX_FLAT_PARAMS]> |
| 2375 | + Send |
| 2376 | + Sync |
| 2377 | + 'static |
| 2378 | + use<T> { |
| 2379 | let token = StoreToken::new(store); |
| 2380 | move |store: &mut dyn VMStore| { |
| 2381 | let mut storage = [MaybeUninit::uninit(); MAX_FLAT_PARAMS]; |
| 2382 | |
| 2383 | store |
| 2384 | .concurrent_state_mut() |
| 2385 | .get_mut(guest_thread.thread)? |
| 2386 | .state = GuestThreadState::Running; |
| 2387 | let task = store.concurrent_state_mut().get_mut(guest_thread.task)?; |
| 2388 | let lower = match task.lower_params.take() { |
| 2389 | Some(l) => l, |
| 2390 | None => bail_bug!("lower_params missing"), |
| 2391 | }; |
| 2392 | |
| 2393 | lower(store, &mut storage[..param_count])?; |
| 2394 | |
| 2395 | let mut store = token.as_context_mut(store); |
| 2396 | |
| 2397 | // SAFETY: Per the contract documented in `make_call's` |
| 2398 | // documentation, `callee` must be a valid pointer. |
| 2399 | unsafe { |
| 2400 | crate::Func::call_unchecked_raw( |
| 2401 | &mut store, |
| 2402 | callee.as_non_null(), |
| 2403 | NonNull::new( |
| 2404 | &mut storage[..param_count.max(result_count)] |
| 2405 | as *mut [MaybeUninit<ValRaw>] as _, |
| 2406 | ) |
| 2407 | .unwrap(), |
| 2408 | )?; |
| 2409 | } |
| 2410 | |
| 2411 | Ok(storage) |
| 2412 | } |
| 2413 | } |
| 2414 | |
| 2415 | // SAFETY: Per the contract described in this function documentation, |
| 2416 | // the `callee` pointer which `call` closes over must be valid when |
nothing calls this directly
no test coverage detected