Struct wasmtime_environ::ModuleEnvironment
source · pub struct ModuleEnvironment<'data, 'module> { /* private fields */ }
Expand description
Object containing the standalone environment information. To be passed after creation as
argument to compile_module
.
Implementations§
source§impl<'data, 'module> ModuleEnvironment<'data, 'module>
impl<'data, 'module> ModuleEnvironment<'data, 'module>
sourcepub fn new(
isa: &'module dyn TargetIsa,
module: &'module mut Module,
tunables: Tunables
) -> Self
pub fn new(
isa: &'module dyn TargetIsa,
module: &'module mut Module,
tunables: Tunables
) -> Self
Allocates the enironment data structures with the given isa.
sourcepub fn translate(
self,
data: &'data [u8]
) -> WasmResult<ModuleTranslation<'data, 'module>>
pub fn translate(
self,
data: &'data [u8]
) -> WasmResult<ModuleTranslation<'data, 'module>>
Translate the given wasm module data using this environment. This consumes the
ModuleEnvironment
with its mutable reference to the Module
and produces a
ModuleTranslation
with an immutable reference to the Module
(which has
become fully populated).
Trait Implementations§
source§impl<'data, 'module> ModuleEnvironment<'data> for ModuleEnvironment<'data, 'module>
impl<'data, 'module> ModuleEnvironment<'data> for ModuleEnvironment<'data, 'module>
This trait is useful for translate_module
because it tells how to translate
enironment-dependent wasm instructions. These functions should not be called by the user.
source§fn target_config(&self) -> TargetFrontendConfig
fn target_config(&self) -> TargetFrontendConfig
Get the information needed to produce Cranelift IR for the current target.
source§fn declare_signature(&mut self, sig: &Signature)
fn declare_signature(&mut self, sig: &Signature)
Declares a function signature to the environment.
source§fn get_signature(&self, sig_index: SignatureIndex) -> &Signature
fn get_signature(&self, sig_index: SignatureIndex) -> &Signature
Return the signature with the given index.
source§fn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &str,
field: &str
)
fn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &str,
field: &str
)
Declares a function import to the environment.
source§fn get_num_func_imports(&self) -> usize
fn get_num_func_imports(&self) -> usize
Return the number of imported funcs.
source§fn declare_func_type(&mut self, sig_index: SignatureIndex)
fn declare_func_type(&mut self, sig_index: SignatureIndex)
Declares the type (signature) of a local function in the module.
source§fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex
fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex
Return the signature index for the given function index.
source§fn declare_global_import(&mut self, global: Global, module: &str, field: &str)
fn declare_global_import(&mut self, global: Global, module: &str, field: &str)
Declares a global import to the environment.
source§fn declare_global(&mut self, global: Global)
fn declare_global(&mut self, global: Global)
Declares a global to the environment.
source§fn get_global(&self, global_index: GlobalIndex) -> &Global
fn get_global(&self, global_index: GlobalIndex) -> &Global
Return the global for the given global index.
source§fn declare_table_import(&mut self, table: Table, module: &str, field: &str)
fn declare_table_import(&mut self, table: Table, module: &str, field: &str)
Declares a table import to the environment.
source§fn declare_table(&mut self, table: Table)
fn declare_table(&mut self, table: Table)
Declares a table to the environment.
source§fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>
)
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>
)
Fills a declared table with references to functions in the module.
source§fn declare_memory_import(&mut self, memory: Memory, module: &str, field: &str)
fn declare_memory_import(&mut self, memory: Memory, module: &str, field: &str)
Declares a memory import to the environment.
source§fn declare_memory(&mut self, memory: Memory)
fn declare_memory(&mut self, memory: Memory)
Declares a memory to the environment
source§fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
Fills a declared memory with bytes at module instantiation.
source§fn declare_func_export(&mut self, func_index: FuncIndex, name: &str)
fn declare_func_export(&mut self, func_index: FuncIndex, name: &str)
Declares a function export to the environment.
source§fn declare_table_export(&mut self, table_index: TableIndex, name: &str)
fn declare_table_export(&mut self, table_index: TableIndex, name: &str)
Declares a table export to the environment.
source§fn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &str)
fn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &str)
Declares a memory export to the environment.
source§fn declare_global_export(&mut self, global_index: GlobalIndex, name: &str)
fn declare_global_export(&mut self, global_index: GlobalIndex, name: &str)
Declares a global export to the environment.
source§fn declare_start_func(&mut self, func_index: FuncIndex)
fn declare_start_func(&mut self, func_index: FuncIndex)
Declares a start function.
source§fn define_function_body(&mut self, body_bytes: &'data [u8]) -> WasmResult<()>
fn define_function_body(&mut self, body_bytes: &'data [u8]) -> WasmResult<()>
Provides the contents of a function body.