Struct wasmtime_environ::ModuleEnvironment [−][src]
pub struct ModuleEnvironment<'data> { /* fields omitted */ }
Expand description
Object containing the standalone environment information.
Implementations
impl<'data> ModuleEnvironment<'data>
[src]
impl<'data> ModuleEnvironment<'data>
[src]pub fn new(
target_config: TargetFrontendConfig,
tunables: &Tunables,
features: &WasmFeatures
) -> Self
[src]
pub fn new(
target_config: TargetFrontendConfig,
tunables: &Tunables,
features: &WasmFeatures
) -> Self
[src]Allocates the environment data structures.
pub fn translate(
self,
data: &'data [u8]
) -> WasmResult<(usize, Vec<ModuleTranslation<'data>>, TypeTables)>
[src]
pub fn translate(
self,
data: &'data [u8]
) -> WasmResult<(usize, Vec<ModuleTranslation<'data>>, TypeTables)>
[src]Translate a wasm module using this environment.
This consumes the ModuleEnvironment
and produces a list of
ModuleTranslation
s as well as a TypeTables
. The list of module
translations corresponds to all wasm modules found in the input data
.
Note that for MVP modules this will always be a list with one element,
but with the module linking proposal this may have many elements.
For the module linking proposal the top-level module is returned as the first return value.
The TypeTables
structure returned contains intern’d versions of types
referenced from each module translation. This primarily serves as the
source of truth for module-linking use cases where modules can refer to
other module’s types. All SignatureIndex
, ModuleTypeIndex
, and
InstanceTypeIndex
values are resolved through the returned tables.
Trait Implementations
impl<'data> ModuleEnvironment<'data> for ModuleEnvironment<'data>
[src]
impl<'data> ModuleEnvironment<'data> for ModuleEnvironment<'data>
[src]This trait is useful for translate_module
because it tells how to translate
environment-dependent wasm instructions. These functions should not be called by the user.
fn reserve_types(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_types(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of types up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_type_func(
&mut self,
wasm: WasmFuncType,
sig: Signature
) -> WasmResult<()>
[src]
fn declare_type_func(
&mut self,
wasm: WasmFuncType,
sig: Signature
) -> WasmResult<()>
[src]Declares a function signature to the environment.
fn declare_type_module(
&mut self,
declared_imports: &[(&'data str, Option<&'data str>, EntityType)],
exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]
fn declare_type_module(
&mut self,
declared_imports: &[(&'data str, Option<&'data str>, EntityType)],
exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]Declares a module type signature to the environment.
fn declare_type_instance(
&mut self,
exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]
fn declare_type_instance(
&mut self,
exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]Declares an instance type signature to the environment.
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
[src]
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
[src]Translates a type index to its signature index, only called for type indices which point to functions. Read more
fn type_to_module_type(&self, index: TypeIndex) -> WasmResult<ModuleTypeIndex>
[src]
fn type_to_module_type(&self, index: TypeIndex) -> WasmResult<ModuleTypeIndex>
[src]Translates a type index to its module type index, only called for type indices which point to modules. Read more
fn type_to_instance_type(
&self,
index: TypeIndex
) -> WasmResult<InstanceTypeIndex>
[src]
fn type_to_instance_type(
&self,
index: TypeIndex
) -> WasmResult<InstanceTypeIndex>
[src]Translates a type index to its instance type index, only called for type indices which point to instances. Read more
fn reserve_imports(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_imports(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of imports up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_func_import(
&mut self,
index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_func_import(
&mut self,
index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares a function import to the environment.
fn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares a table import to the environment.
fn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares a memory import to the environment.
fn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares a global import to the environment.
fn declare_module_import(
&mut self,
ty_index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_module_import(
&mut self,
ty_index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares a module import to the environment.
fn declare_instance_import(
&mut self,
ty_index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]
fn declare_instance_import(
&mut self,
ty_index: TypeIndex,
module: &'data str,
field: Option<&'data str>
) -> WasmResult<()>
[src]Declares an instance import to the environment.
fn reserve_func_types(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_func_types(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of defined functions up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
[src]
fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
[src]Declares the type (signature) of a local function in the module.
fn reserve_tables(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_tables(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of defined tables up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_table(&mut self, table: Table) -> WasmResult<()>
[src]
fn declare_table(&mut self, table: Table) -> WasmResult<()>
[src]Declares a table to the environment.
fn reserve_memories(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_memories(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of defined memories up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
[src]
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
[src]Declares a memory to the environment
fn reserve_globals(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_globals(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of defined globals up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_global(&mut self, global: Global) -> WasmResult<()>
[src]
fn declare_global(&mut self, global: Global) -> WasmResult<()>
[src]Declares a global to the environment.
fn reserve_exports(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_exports(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of exports up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_func_export(
&mut self,
func_index: FuncIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_func_export(
&mut self,
func_index: FuncIndex,
name: &str
) -> WasmResult<()>
[src]Declares a function export to the environment.
fn declare_table_export(
&mut self,
table_index: TableIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_table_export(
&mut self,
table_index: TableIndex,
name: &str
) -> WasmResult<()>
[src]Declares a table export to the environment.
fn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &str
) -> WasmResult<()>
[src]Declares a memory export to the environment.
fn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &str
) -> WasmResult<()>
[src]Declares a global export to the environment.
fn declare_module_export(
&mut self,
index: ModuleIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_module_export(
&mut self,
index: ModuleIndex,
name: &str
) -> WasmResult<()>
[src]Declares an instance export to the environment.
fn declare_instance_export(
&mut self,
index: InstanceIndex,
name: &str
) -> WasmResult<()>
[src]
fn declare_instance_export(
&mut self,
index: InstanceIndex,
name: &str
) -> WasmResult<()>
[src]Declares an instance export to the environment.
fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
[src]
fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
[src]Declares the optional start function.
fn reserve_table_elements(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_table_elements(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of element initializers up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Box<[FuncIndex]>
) -> WasmResult<()>
[src]
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Box<[FuncIndex]>
) -> WasmResult<()>
[src]Fills a declared table with references to functions in the module.
fn declare_passive_element(
&mut self,
elem_index: ElemIndex,
segments: Box<[FuncIndex]>
) -> WasmResult<()>
[src]
fn declare_passive_element(
&mut self,
elem_index: ElemIndex,
segments: Box<[FuncIndex]>
) -> WasmResult<()>
[src]Declare a passive element segment.
fn reserve_function_bodies(&mut self, _count: u32, offset: u64)
[src]
fn reserve_function_bodies(&mut self, _count: u32, offset: u64)
[src]Indicates how many functions the code section reports and the byte offset of where the code sections starts. Read more
fn define_function_body(
&mut self,
validator: FuncValidator<ValidatorResources>,
body: FunctionBody<'data>
) -> WasmResult<()>
[src]
fn define_function_body(
&mut self,
validator: FuncValidator<ValidatorResources>,
body: FunctionBody<'data>
) -> WasmResult<()>
[src]Provides the contents of a function body.
fn reserve_data_initializers(&mut self, num: u32) -> WasmResult<()>
[src]
fn reserve_data_initializers(&mut self, num: u32) -> WasmResult<()>
[src]Provides the number of data initializers up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
) -> WasmResult<()>
[src]
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
) -> WasmResult<()>
[src]Fills a declared memory with bytes at module instantiation.
fn reserve_passive_data(&mut self, _count: u32) -> WasmResult<()>
[src]
fn reserve_passive_data(&mut self, _count: u32) -> WasmResult<()>
[src]Provides the number of passive data segments up front. Read more
fn declare_passive_data(
&mut self,
data_index: DataIndex,
data: &'data [u8]
) -> WasmResult<()>
[src]
fn declare_passive_data(
&mut self,
data_index: DataIndex,
data: &'data [u8]
) -> WasmResult<()>
[src]Declare a passive data segment.
fn declare_module_name(&mut self, name: &'data str)
[src]
fn declare_module_name(&mut self, name: &'data str)
[src]Declares the name of a module to the environment. Read more
fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
[src]
fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
[src]Declares the name of a function to the environment. Read more
fn declare_local_name(
&mut self,
func_index: FuncIndex,
local: u32,
name: &'data str
)
[src]
fn declare_local_name(
&mut self,
func_index: FuncIndex,
local: u32,
name: &'data str
)
[src]Declares the name of a function’s local to the environment. Read more
fn custom_section(
&mut self,
name: &'data str,
data: &'data [u8]
) -> WasmResult<()>
[src]
fn custom_section(
&mut self,
name: &'data str,
data: &'data [u8]
) -> WasmResult<()>
[src]Indicates that a custom section has been found in the wasm file
fn wasm_features(&self) -> WasmFeatures
[src]
fn wasm_features(&self) -> WasmFeatures
[src]Returns the list of enabled wasm features this translation will be using.
fn reserve_modules(&mut self, amount: u32)
[src]
fn reserve_modules(&mut self, amount: u32)
[src]Indicates that this module will have amount
submodules. Read more
fn module_start(&mut self)
[src]
fn module_start(&mut self)
[src]Called at the beginning of translating a module. Read more
fn module_end(&mut self)
[src]
fn module_end(&mut self)
[src]Called at the end of translating a module. Read more
fn reserve_instances(&mut self, amt: u32)
[src]
fn reserve_instances(&mut self, amt: u32)
[src]Indicates that this module will have amount
instances.
fn declare_instance(
&mut self,
module: ModuleIndex,
args: Vec<(&'data str, EntityIndex)>
) -> WasmResult<()>
[src]
fn declare_instance(
&mut self,
module: ModuleIndex,
args: Vec<(&'data str, EntityIndex)>
) -> WasmResult<()>
[src]Declares a new instance which this module will instantiate before it’s instantiated. Read more
fn declare_alias(&mut self, alias: Alias<'_>) -> WasmResult<()>
[src]
fn declare_alias(&mut self, alias: Alias<'_>) -> WasmResult<()>
[src]Declares a new alias being added to this module. Read more
fn declare_event_import(
&mut self,
event: Event,
module: &'data str,
field: Option<&'data str>
) -> Result<(), WasmError>
[src]
fn declare_event_import(
&mut self,
event: Event,
module: &'data str,
field: Option<&'data str>
) -> Result<(), WasmError>
[src]Declares an event import to the environment.
fn finish_imports(&mut self) -> Result<(), WasmError>
[src]
fn finish_imports(&mut self) -> Result<(), WasmError>
[src]Notifies the implementation that all imports have been declared.
fn reserve_events(&mut self, _num: u32) -> Result<(), WasmError>
[src]
fn reserve_events(&mut self, _num: u32) -> Result<(), WasmError>
[src]Provides the number of defined events up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
fn declare_event(&mut self, event: Event) -> Result<(), WasmError>
[src]
fn declare_event(&mut self, event: Event) -> Result<(), WasmError>
[src]Declares an event to the environment
fn declare_event_export(
&mut self,
event_index: EventIndex,
name: &'data str
) -> Result<(), WasmError>
[src]
fn declare_event_export(
&mut self,
event_index: EventIndex,
name: &'data str
) -> Result<(), WasmError>
[src]Declares an event export to the environment.
fn finish_exports(&mut self) -> Result<(), WasmError>
[src]
fn finish_exports(&mut self) -> Result<(), WasmError>
[src]Notifies the implementation that all exports have been declared.
impl<'data> TargetEnvironment for ModuleEnvironment<'data>
[src]
impl<'data> TargetEnvironment for ModuleEnvironment<'data>
[src]fn target_config(&self) -> TargetFrontendConfig
[src]
fn target_config(&self) -> TargetFrontendConfig
[src]Get the information needed to produce Cranelift IR for the given target.
fn reference_type(&self, ty: WasmType) -> Type
[src]
fn reference_type(&self, ty: WasmType) -> Type
[src]Get the Cranelift reference type to use for the given Wasm reference type. Read more
fn pointer_type(&self) -> Type
[src]
fn pointer_type(&self) -> Type
[src]Get the Cranelift integer type to use for native pointers. Read more
fn pointer_bytes(&self) -> u8
[src]
fn pointer_bytes(&self) -> u8
[src]Get the size of a native pointer, in bytes.