diff --git a/crates/jit/src/code_memory.rs b/crates/jit/src/code_memory.rs index 5b4909b481..517b5d1b97 100644 --- a/crates/jit/src/code_memory.rs +++ b/crates/jit/src/code_memory.rs @@ -149,22 +149,26 @@ impl CodeMemory { } /// Returns a reference to the underlying `MmapVec` this memory owns. + #[inline] pub fn mmap(&self) -> &MmapVec { &self.mmap } /// Returns the contents of the text section of the ELF executable this /// represents. + #[inline] pub fn text(&self) -> &[u8] { &self.mmap[self.text.clone()] } /// Returns the contents of the `ELF_WASMTIME_DWARF` section. + #[inline] pub fn dwarf(&self) -> &[u8] { &self.mmap[self.dwarf.clone()] } /// Returns the data in the `ELF_NAME_DATA` section. + #[inline] pub fn func_name_data(&self) -> &[u8] { &self.mmap[self.func_name_data.clone()] } @@ -174,24 +178,28 @@ impl CodeMemory { /// /// This is used for initialization of memories and all data ranges stored /// in a `Module` are relative to the slice returned here. + #[inline] pub fn wasm_data(&self) -> &[u8] { &self.mmap[self.wasm_data.clone()] } /// Returns the encoded address map section used to pass to /// `wasmtime_environ::lookup_file_pos`. + #[inline] pub fn address_map_data(&self) -> &[u8] { &self.mmap[self.address_map_data.clone()] } /// Returns the contents of the `ELF_WASMTIME_INFO` section, or an empty /// slice if it wasn't found. + #[inline] pub fn wasmtime_info(&self) -> &[u8] { &self.mmap[self.info_data.clone()] } /// Returns the contents of the `ELF_WASMTIME_TRAPS` section, or an empty /// slice if it wasn't found. + #[inline] pub fn trap_data(&self) -> &[u8] { &self.mmap[self.trap_data.clone()] } diff --git a/crates/runtime/src/mmap.rs b/crates/runtime/src/mmap.rs index 4f9f4c64d4..341cd4deea 100644 --- a/crates/runtime/src/mmap.rs +++ b/crates/runtime/src/mmap.rs @@ -146,11 +146,13 @@ impl Mmap { } /// Return the allocated memory as a pointer to u8. + #[inline] pub fn as_ptr(&self) -> *const u8 { self.sys.as_ptr() } /// Return the allocated memory as a mutable pointer to u8. + #[inline] pub fn as_mut_ptr(&mut self) -> *mut u8 { self.sys.as_mut_ptr() } @@ -159,6 +161,7 @@ impl Mmap { /// /// This is the byte length of this entire mapping which includes both /// addressible and non-addressible memory. + #[inline] pub fn len(&self) -> usize { self.sys.len() } diff --git a/crates/runtime/src/mmap/unix.rs b/crates/runtime/src/mmap/unix.rs index 3227ec3a02..97de914dae 100644 --- a/crates/runtime/src/mmap/unix.rs +++ b/crates/runtime/src/mmap/unix.rs @@ -84,14 +84,17 @@ impl Mmap { Ok(()) } + #[inline] pub fn as_ptr(&self) -> *const u8 { self.memory.as_ptr() as *const u8 } + #[inline] pub fn as_mut_ptr(&mut self) -> *mut u8 { self.memory.as_ptr().cast() } + #[inline] pub fn len(&self) -> usize { unsafe { (*self.memory.as_ptr()).len() } } diff --git a/crates/runtime/src/mmap/windows.rs b/crates/runtime/src/mmap/windows.rs index 5ca208b337..4a8396c442 100644 --- a/crates/runtime/src/mmap/windows.rs +++ b/crates/runtime/src/mmap/windows.rs @@ -147,14 +147,17 @@ impl Mmap { Ok(()) } + #[inline] pub fn as_ptr(&self) -> *const u8 { self.memory.as_ptr() as *const u8 } + #[inline] pub fn as_mut_ptr(&mut self) -> *mut u8 { self.memory.as_ptr().cast() } + #[inline] pub fn len(&self) -> usize { unsafe { (*self.memory.as_ptr()).len() } }