Skip to content

Commit 16f069c

Browse files
authored
Make a couple vm::Memory methods take &self instead of &mut self (#10543)
The `&mut self` was not necessary and also did not provide any help with using the resulting `VMMemoryDefinition`s and their raw pointers, so just make these methods take `&self`.
1 parent da8aa9c commit 16f069c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/wasmtime/src/runtime/vm/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl Memory {
356356
}
357357
}
358358

359-
/// Returns the number of allocated wasm pages.
359+
/// Returns the size of this memory, in bytes.
360360
pub fn byte_size(&self) -> usize {
361361
match self {
362362
Memory::Local(mem) => mem.byte_size(),
@@ -407,7 +407,7 @@ impl Memory {
407407
}
408408

409409
/// Return a `VMMemoryDefinition` for exposing the memory to compiled wasm code.
410-
pub fn vmmemory(&mut self) -> VMMemoryDefinition {
410+
pub fn vmmemory(&self) -> VMMemoryDefinition {
411411
match self {
412412
Memory::Local(mem) => mem.vmmemory(),
413413
// `vmmemory()` is used for writing the `VMMemoryDefinition` of a
@@ -701,7 +701,7 @@ impl LocalMemory {
701701
}
702702
}
703703

704-
pub fn vmmemory(&mut self) -> VMMemoryDefinition {
704+
pub fn vmmemory(&self) -> VMMemoryDefinition {
705705
VMMemoryDefinition {
706706
base: self.alloc.base().as_non_null().into(),
707707
current_length: self.alloc.byte_size().into(),

crates/wasmtime/src/runtime/vm/memory/shared_memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl SharedMemory {
4040
}
4141

4242
/// Wrap an existing [Memory] with the locking provided by a [SharedMemory].
43-
pub fn wrap(ty: &wasmtime_environ::Memory, mut memory: LocalMemory) -> Result<Self> {
43+
pub fn wrap(ty: &wasmtime_environ::Memory, memory: LocalMemory) -> Result<Self> {
4444
if !ty.shared {
4545
bail!("shared memory must have a `shared` memory type");
4646
}

0 commit comments

Comments
 (0)