Skip to content

Commit

Permalink
Merge pull request #5139 from ognevny/update-corosensei
Browse files Browse the repository at this point in the history
deps: Update corosensei
  • Loading branch information
syrusakbary authored Oct 7, 2024
2 parents c82cded + 688cf64 commit 713e02d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 56 deletions.
53 changes: 5 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum-iterator = "0.7.0"
scopeguard = "1.1.0"
lazy_static = "1.4.0"
region = { version = "3.0.2" }
corosensei = { version = "0.1.2" }
corosensei = { version = "0.2.0" }
derivative = { version = "^2" }
fnv = "1.0.3"
# - Optional shared dependencies.
Expand Down
2 changes: 1 addition & 1 deletion lib/vm/src/instance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl Instance {

// Make the call.
unsafe {
catch_traps(trap_handler, config, || {
catch_traps(trap_handler, config, move || {
mem::transmute::<*const VMFunctionBody, unsafe extern "C" fn(VMFunctionContext)>(
callee_address,
)(callee_vmctx)
Expand Down
12 changes: 6 additions & 6 deletions lib/vm/src/trap/traphandlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use backtrace::Backtrace;
use core::ptr::{read, read_unaligned};
use corosensei::stack::DefaultStack;
use corosensei::trap::{CoroutineTrapHandler, TrapHandlerRegs};
use corosensei::{CoroutineResult, ScopedCoroutine, Yielder};
use corosensei::{Coroutine, CoroutineResult, Yielder};
use scopeguard::defer;
use std::any::Any;
use std::cell::Cell;
Expand Down Expand Up @@ -672,7 +672,7 @@ pub unsafe fn wasmer_call_trampoline(
callee: *const VMFunctionBody,
values_vec: *mut u8,
) -> Result<(), Trap> {
catch_traps(trap_handler, config, || {
catch_traps(trap_handler, config, move || {
mem::transmute::<_, extern "C" fn(VMFunctionContext, *const VMFunctionBody, *mut u8)>(
trampoline,
)(vmctx, callee, values_vec);
Expand All @@ -685,13 +685,13 @@ pub unsafe fn wasmer_call_trampoline(
/// # Safety
///
/// Highly unsafe since `closure` won't have any dtors run.
pub unsafe fn catch_traps<F, R>(
pub unsafe fn catch_traps<F, R: 'static>(
trap_handler: Option<*const TrapHandlerFn<'static>>,
config: &VMConfig,
closure: F,
) -> Result<R, Trap>
where
F: FnOnce() -> R,
F: FnOnce() -> R + 'static,
{
// Ensure that per-thread initialization is done.
lazy_per_thread_init()?;
Expand Down Expand Up @@ -914,7 +914,7 @@ unsafe fn unwind_with(reason: UnwindReason) -> ! {
/// Runs the given function on a separate stack so that its stack usage can be
/// bounded. Stack overflows and other traps can be caught and execution
/// returned to the root of the stack.
fn on_wasm_stack<F: FnOnce() -> T, T>(
fn on_wasm_stack<F: FnOnce() -> T + 'static, T: 'static>(
stack_size: usize,
trap_handler: Option<*const TrapHandlerFn<'static>>,
f: F,
Expand All @@ -932,7 +932,7 @@ fn on_wasm_stack<F: FnOnce() -> T, T>(
let mut stack = scopeguard::guard(stack, |stack| STACK_POOL.push(stack));

// Create a coroutine with a new stack to run the function on.
let mut coro = ScopedCoroutine::with_stack(&mut *stack, move |yielder, ()| {
let mut coro = Coroutine::with_stack(&mut *stack, move |yielder, ()| {
// Save the yielder to TLS so that it can be used later.
YIELDER.with(|cell| cell.set(Some(yielder.into())));

Expand Down

0 comments on commit 713e02d

Please sign in to comment.