Struct wasmtime_jit::CodeMemory
source · pub struct CodeMemory { /* private fields */ }
Expand description
Management of executable memory within a MmapVec
This type consumes ownership of a region of memory and will manage the executable permissions of the contained JIT code as necessary.
Implementations§
source§impl CodeMemory
impl CodeMemory
sourcepub fn new(mmap: MmapVec) -> Result<Self>
pub fn new(mmap: MmapVec) -> Result<Self>
Creates a new CodeMemory
by taking ownership of the provided
MmapVec
.
The returned CodeMemory
manages the internal MmapVec
and the
publish
method is used to actually make the memory executable.
sourcepub fn text(&self) -> &[u8] ⓘ
pub fn text(&self) -> &[u8] ⓘ
Returns the contents of the text section of the ELF executable this represents.
sourcepub fn func_name_data(&self) -> &[u8] ⓘ
pub fn func_name_data(&self) -> &[u8] ⓘ
Returns the data in the ELF_NAME_DATA
section.
sourcepub fn wasm_data(&self) -> &[u8] ⓘ
pub fn wasm_data(&self) -> &[u8] ⓘ
Returns the concatenated list of all data associated with this wasm module.
This is used for initialization of memories and all data ranges stored
in a Module
are relative to the slice returned here.
sourcepub fn address_map_data(&self) -> &[u8] ⓘ
pub fn address_map_data(&self) -> &[u8] ⓘ
Returns the encoded address map section used to pass to
wasmtime_environ::lookup_file_pos
.
sourcepub fn wasmtime_info(&self) -> &[u8] ⓘ
pub fn wasmtime_info(&self) -> &[u8] ⓘ
Returns the contents of the ELF_WASMTIME_INFO
section, or an empty
slice if it wasn’t found.
sourcepub fn trap_data(&self) -> &[u8] ⓘ
pub fn trap_data(&self) -> &[u8] ⓘ
Returns the contents of the ELF_WASMTIME_TRAPS
section, or an empty
slice if it wasn’t found.
sourcepub unsafe fn vmtrampoline(&self, loc: FunctionLoc) -> VMTrampoline
pub unsafe fn vmtrampoline(&self, loc: FunctionLoc) -> VMTrampoline
Returns a VMTrampoline
function pointer for the given function in the
text section.
§Unsafety
This function is unsafe as there’s no guarantee that the returned function pointer is valid.
sourcepub fn publish(&mut self) -> Result<()>
pub fn publish(&mut self) -> Result<()>
Publishes the internal ELF image to be ready for execution.
This method can only be called once and will panic if called twice. This
will parse the ELF image from the original MmapVec
and do everything
necessary to get it ready for execution, including:
- Change page protections from read/write to read/execute.
- Register unwinding information with the OS
After this function executes all JIT code should be ready to execute.