Skip to content

Commit

Permalink
Remove all references to VM store and sys
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Apr 8, 2023
1 parent 014d113 commit 214d416
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
19 changes: 6 additions & 13 deletions lib/wasi/src/runtime/task_manager/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::pin::Pin;
use futures::Future;
#[cfg(feature = "sys-thread")]
use tokio::runtime::{Builder, Runtime};
use wasmer::{vm::VMMemory, Module, Store};
use wasmer::{Module, Store};

use crate::{WasiCallingId, WasiThreadError};

Expand Down Expand Up @@ -157,19 +157,12 @@ impl VirtualTaskManager for ThreadTaskManager {
module: Module,
spawn_type: SpawnType,
) -> Result<(), WasiThreadError> {
use wasmer::vm::VMSharedMemory;

let vm_memory: Option<Memory> = match spawn_type {
SpawnType::CreateWithType(mem) => {
let style = store.engine().tunables().memory_style(&mem.ty);
Some(
VMSharedMemory::new(&mem.ty, &style)
.map_err(|err| {
tracing::error!("failed to create memory - {}", err);
})
.unwrap()
.into(),
).map(|vm_memory| Memory::new_from_existing(&mut store, vm_memory))
SpawnType::CreateWithType(mut mem) => {
mem.shared = true;
Some(Memory::new(&mut store, mem).map_err(|err| {
tracing::error!("failed to create memory - {}", err);
}).unwrap())
},
SpawnType::NewThread(mem) => Some(mem),
SpawnType::Create => None,
Expand Down
19 changes: 5 additions & 14 deletions lib/wasi/src/syscalls/wasix/proc_fork.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::*;
use crate::{os::task::OwnedTaskStatus, syscalls::*};

use wasmer::vm::VMMemory;
use wasmer::Memory;

/// ### `proc_fork()`
/// Forks the current process into a new subprocess. If the function
Expand Down Expand Up @@ -125,21 +124,13 @@ pub fn proc_fork<M: MemorySize>(

// Fork the memory and copy the module (compiled code)
let (env, mut store) = ctx.data_and_store_mut();
let fork_memory: VMMemory = match env
.memory()
.try_clone(&store)
.ok_or_else(|| MemoryError::Generic("the memory could not be cloned".to_string()))
.and_then(|mut memory| memory.duplicate())
{
Ok(memory) => memory.into(),
Err(err) => {
warn!(
%err
);
let fork_memory: Memory = match env.memory().duplicate_in_store(&store, &mut fork_store) {
Some(memory) => memory,
None => {
warn!("Can't duplicate memory in new store");
return OnCalledAction::Trap(Box::new(WasiError::Exit(Errno::Memviolation.into())));
}
};
let fork_memory = Memory::new_from_existing(&mut fork_store, fork_memory);
let fork_module = env.inner().instance.module().clone();

// Now we use the environment and memory references
Expand Down

0 comments on commit 214d416

Please sign in to comment.