Struct cranelift_wasm::DummyEnvironment
source · [−]pub struct DummyEnvironment {
pub info: DummyModuleInfo,
pub func_bytecode_sizes: Vec<usize>,
pub module_name: Option<String>,
/* private fields */
}
Expand description
This ModuleEnvironment
implementation is a “naïve” one, doing essentially nothing and
emitting placeholders when forced to. Don’t try to execute code translated for this
environment, essentially here for translation debug purposes.
Fields
info: DummyModuleInfo
Module information.
func_bytecode_sizes: Vec<usize>
Vector of wasm bytecode size for each function.
module_name: Option<String>
Name of the module from the wasm file.
Implementations
sourceimpl DummyEnvironment
impl DummyEnvironment
sourcepub fn new(config: TargetFrontendConfig, debug_info: bool) -> Self
pub fn new(config: TargetFrontendConfig, debug_info: bool) -> Self
Creates a new DummyEnvironment
instance.
sourcepub fn func_env(&self) -> DummyFuncEnvironment<'_>
pub fn func_env(&self) -> DummyFuncEnvironment<'_>
Return a DummyFuncEnvironment
for translating functions within this
DummyEnvironment
.
sourcepub fn get_num_func_imports(&self) -> usize
pub fn get_num_func_imports(&self) -> usize
Return the number of imported functions within this DummyEnvironment
.
sourcepub fn get_func_name(&self, func_index: FuncIndex) -> Option<&str>
pub fn get_func_name(&self, func_index: FuncIndex) -> Option<&str>
Return the name of the function, if a name for the function with the corresponding index exists.
sourcepub fn test_expected_reachability(&mut self, reachability: Vec<(bool, bool)>)
pub fn test_expected_reachability(&mut self, reachability: Vec<(bool, bool)>)
Test reachability bits before and after every opcode during translation, as provided by the
FuncTranslationState
. This is generally used only for unit tests. This is applied to
every function in the module (so is likely only useful for test modules with one function).
Trait Implementations
sourceimpl<'data> ModuleEnvironment<'data> for DummyEnvironment
impl<'data> ModuleEnvironment<'data> for DummyEnvironment
sourcefn declare_type_func(&mut self, wasm: WasmFuncType) -> WasmResult<()>
fn declare_type_func(&mut self, wasm: WasmFuncType) -> WasmResult<()>
Declares a function signature to the environment.
sourcefn declare_func_import(
&mut self,
index: TypeIndex,
module: &'data str,
field: &'data str
) -> WasmResult<()>
fn declare_func_import(
&mut self,
index: TypeIndex,
module: &'data str,
field: &'data str
) -> WasmResult<()>
Declares a function import to the environment.
sourcefn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>
Declares the type (signature) of a local function in the module.
sourcefn declare_global(&mut self, global: Global) -> WasmResult<()>
fn declare_global(&mut self, global: Global) -> WasmResult<()>
Declares a global to the environment.
sourcefn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: &'data str
) -> WasmResult<()>
fn declare_global_import(
&mut self,
global: Global,
module: &'data str,
field: &'data str
) -> WasmResult<()>
Declares a global import to the environment.
sourcefn declare_table(&mut self, table: Table) -> WasmResult<()>
fn declare_table(&mut self, table: Table) -> WasmResult<()>
Declares a table to the environment.
sourcefn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: &'data str
) -> WasmResult<()>
fn declare_table_import(
&mut self,
table: Table,
module: &'data str,
field: &'data str
) -> WasmResult<()>
Declares a table import to the environment.
sourcefn declare_table_elements(
&mut self,
_table_index: TableIndex,
_base: Option<GlobalIndex>,
_offset: u32,
_elements: Box<[FuncIndex]>
) -> WasmResult<()>
fn declare_table_elements(
&mut self,
_table_index: TableIndex,
_base: Option<GlobalIndex>,
_offset: u32,
_elements: Box<[FuncIndex]>
) -> WasmResult<()>
Fills a declared table with references to functions in the module.
sourcefn declare_passive_element(
&mut self,
_elem_index: ElemIndex,
_segments: Box<[FuncIndex]>
) -> WasmResult<()>
fn declare_passive_element(
&mut self,
_elem_index: ElemIndex,
_segments: Box<[FuncIndex]>
) -> WasmResult<()>
Declare a passive element segment.
sourcefn declare_passive_data(
&mut self,
_elem_index: DataIndex,
_segments: &'data [u8]
) -> WasmResult<()>
fn declare_passive_data(
&mut self,
_elem_index: DataIndex,
_segments: &'data [u8]
) -> WasmResult<()>
Declare a passive data segment.
sourcefn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>
Declares a memory to the environment
sourcefn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: &'data str
) -> WasmResult<()>
fn declare_memory_import(
&mut self,
memory: Memory,
module: &'data str,
field: &'data str
) -> WasmResult<()>
Declares a memory import to the environment.
sourcefn declare_data_initialization(
&mut self,
_memory_index: MemoryIndex,
_base: Option<GlobalIndex>,
_offset: u64,
_data: &'data [u8]
) -> WasmResult<()>
fn declare_data_initialization(
&mut self,
_memory_index: MemoryIndex,
_base: Option<GlobalIndex>,
_offset: u64,
_data: &'data [u8]
) -> WasmResult<()>
Fills a declared memory with bytes at module instantiation.
sourcefn declare_func_export(
&mut self,
func_index: FuncIndex,
name: &'data str
) -> WasmResult<()>
fn declare_func_export(
&mut self,
func_index: FuncIndex,
name: &'data str
) -> WasmResult<()>
Declares a function export to the environment.
sourcefn declare_table_export(
&mut self,
table_index: TableIndex,
name: &'data str
) -> WasmResult<()>
fn declare_table_export(
&mut self,
table_index: TableIndex,
name: &'data str
) -> WasmResult<()>
Declares a table export to the environment.
sourcefn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &'data str
) -> WasmResult<()>
fn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &'data str
) -> WasmResult<()>
Declares a memory export to the environment.
sourcefn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &'data str
) -> WasmResult<()>
fn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &'data str
) -> WasmResult<()>
Declares a global export to the environment.
sourcefn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>
Declares the optional start function.
sourcefn define_function_body(
&mut self,
validator: FuncValidator<ValidatorResources>,
body: FunctionBody<'data>
) -> WasmResult<()>
fn define_function_body(
&mut self,
validator: FuncValidator<ValidatorResources>,
body: FunctionBody<'data>
) -> WasmResult<()>
Provides the contents of a function body.
sourcefn declare_module_name(&mut self, name: &'data str)
fn declare_module_name(&mut self, name: &'data str)
Declares the name of a module to the environment. Read more
sourcefn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
fn declare_func_name(&mut self, func_index: FuncIndex, name: &'data str)
Declares the name of a function to the environment. Read more
sourcefn wasm_features(&self) -> WasmFeatures
fn wasm_features(&self) -> WasmFeatures
Returns the list of enabled wasm features this translation will be using.
sourcefn reserve_types(&mut self, _num: u32) -> WasmResult<()>
fn reserve_types(&mut self, _num: u32) -> WasmResult<()>
Provides the number of types up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
sourcefn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>
Translates a type index to its signature index, only called for type indices which point to functions. Read more
sourcefn reserve_imports(&mut self, _num: u32) -> WasmResult<()>
fn reserve_imports(&mut self, _num: u32) -> WasmResult<()>
Provides the number of imports up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
sourcefn declare_tag_import(
&mut self,
tag: Tag,
module: &'data str,
field: &'data str
) -> WasmResult<()>
fn declare_tag_import(
&mut self,
tag: Tag,
module: &'data str,
field: &'data str
) -> WasmResult<()>
Declares an tag import to the environment.
sourcefn finish_imports(&mut self) -> WasmResult<()>
fn finish_imports(&mut self) -> WasmResult<()>
Notifies the implementation that all imports have been declared.
sourcefn reserve_func_types(&mut self, _num: u32) -> WasmResult<()>
fn reserve_func_types(&mut self, _num: u32) -> WasmResult<()>
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
sourcefn reserve_tables(&mut self, _num: u32) -> WasmResult<()>
fn reserve_tables(&mut self, _num: u32) -> WasmResult<()>
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
sourcefn reserve_memories(&mut self, _num: u32) -> WasmResult<()>
fn reserve_memories(&mut self, _num: u32) -> WasmResult<()>
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
Provides the number of defined tags up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
sourcefn declare_tag(&mut self, tag: Tag) -> WasmResult<()>
fn declare_tag(&mut self, tag: Tag) -> WasmResult<()>
Declares an tag to the environment
sourcefn reserve_globals(&mut self, _num: u32) -> WasmResult<()>
fn reserve_globals(&mut self, _num: u32) -> WasmResult<()>
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
sourcefn reserve_exports(&mut self, _num: u32) -> WasmResult<()>
fn reserve_exports(&mut self, _num: u32) -> WasmResult<()>
Provides the number of exports up front. By default this does nothing, but implementations can use this to preallocate memory if desired. Read more
sourcefn declare_tag_export(
&mut self,
tag_index: TagIndex,
name: &'data str
) -> WasmResult<()>
fn declare_tag_export(
&mut self,
tag_index: TagIndex,
name: &'data str
) -> WasmResult<()>
Declares an tag export to the environment.
sourcefn finish_exports(&mut self) -> WasmResult<()>
fn finish_exports(&mut self) -> WasmResult<()>
Notifies the implementation that all exports have been declared.
sourcefn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()>
fn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()>
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
sourcefn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()>
fn declare_elements(&mut self, elements: Box<[FuncIndex]>) -> WasmResult<()>
Indicates that a declarative element segment was seen in the wasm module. Read more
sourcefn reserve_passive_data(&mut self, count: u32) -> WasmResult<()>
fn reserve_passive_data(&mut self, count: u32) -> WasmResult<()>
Provides the number of passive data segments up front. Read more
sourcefn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64)
fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64)
Indicates how many functions the code section reports and the byte offset of where the code sections starts. Read more
sourcefn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()>
fn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()>
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
sourcefn declare_local_name(
&mut self,
_func_index: FuncIndex,
_local_index: u32,
_name: &'data str
)
fn declare_local_name(
&mut self,
_func_index: FuncIndex,
_local_index: u32,
_name: &'data str
)
Declares the name of a function’s local to the environment. Read more
sourcefn custom_section(
&mut self,
_name: &'data str,
_data: &'data [u8]
) -> WasmResult<()>
fn custom_section(
&mut self,
_name: &'data str,
_data: &'data [u8]
) -> WasmResult<()>
Indicates that a custom section has been found in the wasm file
sourceimpl TargetEnvironment for DummyEnvironment
impl TargetEnvironment for DummyEnvironment
sourcefn target_config(&self) -> TargetFrontendConfig
fn target_config(&self) -> TargetFrontendConfig
Get the information needed to produce Cranelift IR for the given target.
sourcefn pointer_type(&self) -> Type
fn pointer_type(&self) -> Type
Get the Cranelift integer type to use for native pointers. Read more
sourcefn pointer_bytes(&self) -> u8
fn pointer_bytes(&self) -> u8
Get the size of a native pointer, in bytes.
sourcefn reference_type(&self, ty: WasmType) -> Type
fn reference_type(&self, ty: WasmType) -> Type
Get the Cranelift reference type to use for the given Wasm reference type. Read more
Auto Trait Implementations
impl RefUnwindSafe for DummyEnvironment
impl Send for DummyEnvironment
impl Sync for DummyEnvironment
impl Unpin for DummyEnvironment
impl UnwindSafe for DummyEnvironment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more