Skip to content

Commit

Permalink
Update deprecated API to new restrictions on dynamic envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Dec 18, 2020
1 parent 283acc5 commit 4f08f3d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
26 changes: 13 additions & 13 deletions lib/deprecated/runtime-core/Cargo.lock

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

17 changes: 11 additions & 6 deletions lib/deprecated/runtime-core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use crate::{
};
use new::wasmer::Export;
use std::{
cell::RefCell,
collections::HashMap,
convert::{AsRef, Infallible},
ptr,
sync::{Arc, Mutex},
};

pub use new::wasmer_types::{DataInitializer, ExportIndex, TableInitializer};
Expand Down Expand Up @@ -126,20 +126,22 @@ impl Module {
// is the same!
struct VMDynamicFunctionWithEnv<Env>
where
Env: Sized + 'static,
Env: Sized + 'static + Send + Sync,
{
#[allow(unused)]
function_type: FuncSig,
#[allow(unused)]
func: Box<
func: Arc<
dyn Fn(
&mut Env,
&[Value],
)
-> Result<Vec<Value>, RuntimeError>
+ 'static,
+ 'static
+ Send
+ Sync,
>,
env: RefCell<Env>,
env: Box<Mutex<Env>>,
}

// Get back the `vmctx` as it is
Expand All @@ -154,7 +156,10 @@ impl Module {
};

// Replace the environment by ours.
vmctx.ctx.env.borrow_mut().vmctx = pre_instance.vmctx();
{
let mut guard = vmctx.ctx.env.lock().unwrap();
guard.vmctx = pre_instance.vmctx();
}

// … without anyone noticing…
function.vm_function.vmctx.host_env = Box::into_raw(vmctx) as _;
Expand Down
26 changes: 13 additions & 13 deletions lib/deprecated/runtime/Cargo.lock

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

0 comments on commit 4f08f3d

Please sign in to comment.