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:
Christoph Herzog
2022-12-19 18:04:00 +01:00
parent 11774ee5b4
commit 9c12b87eb0
5 changed files with 23 additions and 21 deletions

View File

@@ -54,7 +54,7 @@ impl VMMemory {
}
/// 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())?;
#[cfg(feature = "tracing")]

View File

@@ -265,9 +265,9 @@ impl 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());
mem.fork()
mem.duplicate()
}
}

View File

@@ -117,10 +117,12 @@ mod tests {
.unwrap()
}
}
fn try_clone(&self) -> Option<Box<dyn LinearMemory + 'static>> {
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();
Ok(Box::new(Self {
memory_definition: Some(UnsafeCell::new(VMMemoryDefinition {