mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 05:08:19 +00:00
Rename fork() to duplicate()
Renames all the memory fork() functions to duplicate(), since this is what they actually do. They enable forking, but that is a seprate functionality.
This commit is contained in:
@@ -54,7 +54,7 @@ impl VMMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
pub fn fork(&self) -> Result<VMMemory, wasmer_types::MemoryError> {
|
pub fn duplicate(&self) -> Result<VMMemory, wasmer_types::MemoryError> {
|
||||||
let new_memory = crate::Memory::new_internal(self.ty.clone())?;
|
let new_memory = crate::Memory::new_internal(self.ty.clone())?;
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
|
|||||||
4
lib/api/src/js/externals/memory.rs
vendored
4
lib/api/src/js/externals/memory.rs
vendored
@@ -265,9 +265,9 @@ impl Memory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
pub fn fork(&mut self, store: &impl AsStoreRef) -> Result<VMMemory, MemoryError> {
|
pub fn duplicate(&mut self, store: &impl AsStoreRef) -> Result<VMMemory, MemoryError> {
|
||||||
let mem = self.handle.get(store.as_store_ref().objects());
|
let mem = self.handle.get(store.as_store_ref().objects());
|
||||||
mem.fork()
|
mem.duplicate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,10 +117,12 @@ mod tests {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
|
||||||
|
fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
||||||
let mem = self.mem.clone();
|
let mem = self.mem.clone();
|
||||||
Ok(Box::new(Self {
|
Ok(Box::new(Self {
|
||||||
memory_definition: Some(UnsafeCell::new(VMMemoryDefinition {
|
memory_definition: Some(UnsafeCell::new(VMMemoryDefinition {
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ impl WasmMmap {
|
|||||||
|
|
||||||
/// Copies the memory
|
/// Copies the memory
|
||||||
/// (in this case it performs a copy-on-write to save memory)
|
/// (in this case it performs a copy-on-write to save memory)
|
||||||
pub fn fork(&mut self) -> Result<Self, MemoryError> {
|
pub fn duplicate(&mut self) -> Result<Self, MemoryError> {
|
||||||
let mem_length = self.size.bytes().0;
|
let mem_length = self.size.bytes().0;
|
||||||
let mut alloc = self
|
let mut alloc = self
|
||||||
.alloc
|
.alloc
|
||||||
.fork(Some(mem_length))
|
.duplicate(Some(mem_length))
|
||||||
.map_err(MemoryError::Generic)?;
|
.map_err(MemoryError::Generic)?;
|
||||||
let base_ptr = alloc.as_mut_ptr();
|
let base_ptr = alloc.as_mut_ptr();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
@@ -289,9 +289,9 @@ impl VMOwnedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
pub fn fork(&mut self) -> Result<Self, MemoryError> {
|
pub fn duplicate(&mut self) -> Result<Self, MemoryError> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mmap: self.mmap.fork()?,
|
mmap: self.mmap.duplicate()?,
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -333,8 +333,8 @@ impl LinearMemory for VMOwnedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
||||||
let forked = Self::fork(self)?;
|
let forked = Self::duplicate(self)?;
|
||||||
Ok(Box::new(forked))
|
Ok(Box::new(forked))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,10 +376,10 @@ impl VMSharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
pub fn fork(&mut self) -> Result<Self, MemoryError> {
|
pub fn duplicate(&mut self) -> Result<Self, MemoryError> {
|
||||||
let mut guard = self.mmap.write().unwrap();
|
let mut guard = self.mmap.write().unwrap();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mmap: Arc::new(RwLock::new(guard.fork()?)),
|
mmap: Arc::new(RwLock::new(guard.duplicate()?)),
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -427,8 +427,8 @@ impl LinearMemory for VMSharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
||||||
let forked = Self::fork(self)?;
|
let forked = Self::duplicate(self)?;
|
||||||
Ok(Box::new(forked))
|
Ok(Box::new(forked))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,8 +495,8 @@ impl LinearMemory for VMMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
||||||
self.0.fork()
|
self.0.duplicate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,8 +558,8 @@ impl VMMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
pub fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
pub fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError> {
|
||||||
LinearMemory::fork(self)
|
LinearMemory::duplicate(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,5 +615,5 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Copies this memory to a new memory
|
/// Copies this memory to a new memory
|
||||||
fn fork(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError>;
|
fn duplicate(&mut self) -> Result<Box<dyn LinearMemory + 'static>, MemoryError>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ impl Mmap {
|
|||||||
|
|
||||||
/// Copies the memory to a new swap file (using copy-on-write if available)
|
/// Copies the memory to a new swap file (using copy-on-write if available)
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
pub fn fork(&mut self, hint_used: Option<usize>) -> Result<Self, String> {
|
pub fn duplicate(&mut self, hint_used: Option<usize>) -> Result<Self, String> {
|
||||||
// Empty memory is an edge case
|
// Empty memory is an edge case
|
||||||
|
|
||||||
use std::os::unix::prelude::FromRawFd;
|
use std::os::unix::prelude::FromRawFd;
|
||||||
@@ -395,7 +395,7 @@ impl Mmap {
|
|||||||
|
|
||||||
/// Copies the memory to a new swap file (using copy-on-write if available)
|
/// Copies the memory to a new swap file (using copy-on-write if available)
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn fork(&mut self, hint_used: Option<usize>) -> Result<Self, String> {
|
pub fn duplicate(&mut self, hint_used: Option<usize>) -> Result<Self, String> {
|
||||||
// Create a new memory which we will copy to
|
// Create a new memory which we will copy to
|
||||||
let new_mmap = Self::with_at_least(self.len)?;
|
let new_mmap = Self::with_at_least(self.len)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user