Trait wasmer_compiler::Compiler
source · pub trait Compiler: Send {
// Required methods
fn name(&self) -> &str;
fn compile_module(
&self,
target: &Target,
module: &CompileModuleInfo,
module_translation: &ModuleTranslationState,
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
) -> Result<Compilation, CompileError>;
fn get_middlewares(&self) -> &[Arc<dyn ModuleMiddleware>];
// Provided methods
fn validate_module(
&self,
features: &Features,
data: &[u8],
) -> Result<(), CompileError> { ... }
fn experimental_native_compile_module(
&self,
_target: &Target,
_module: &CompileModuleInfo,
_module_translation: &ModuleTranslationState,
_function_body_inputs: &PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
_symbol_registry: &dyn SymbolRegistry,
_wasmer_metadata: &[u8],
) -> Option<Result<Vec<u8>, CompileError>> { ... }
fn get_cpu_features_used(
&self,
cpu_features: &EnumSet<CpuFeature>,
) -> EnumSet<CpuFeature> { ... }
}
Expand description
An implementation of a Compiler from parsed WebAssembly module to Compiled native code.
Required Methods§
sourcefn name(&self) -> &str
fn name(&self) -> &str
Returns a descriptive name for this compiler.
Note that this is an API breaking change since 3.0
sourcefn compile_module(
&self,
target: &Target,
module: &CompileModuleInfo,
module_translation: &ModuleTranslationState,
function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
) -> Result<Compilation, CompileError>
fn compile_module( &self, target: &Target, module: &CompileModuleInfo, module_translation: &ModuleTranslationState, function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>, ) -> Result<Compilation, CompileError>
Compiles a parsed module.
It returns the Compilation
or a [CompileError
].
sourcefn get_middlewares(&self) -> &[Arc<dyn ModuleMiddleware>]
fn get_middlewares(&self) -> &[Arc<dyn ModuleMiddleware>]
Get the middlewares for this compiler
Provided Methods§
sourcefn validate_module(
&self,
features: &Features,
data: &[u8],
) -> Result<(), CompileError>
fn validate_module( &self, features: &Features, data: &[u8], ) -> Result<(), CompileError>
Validates a module.
It returns the a succesful Result in case is valid, CompileError
in case is not.
sourcefn experimental_native_compile_module(
&self,
_target: &Target,
_module: &CompileModuleInfo,
_module_translation: &ModuleTranslationState,
_function_body_inputs: &PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>,
_symbol_registry: &dyn SymbolRegistry,
_wasmer_metadata: &[u8],
) -> Option<Result<Vec<u8>, CompileError>>
fn experimental_native_compile_module( &self, _target: &Target, _module: &CompileModuleInfo, _module_translation: &ModuleTranslationState, _function_body_inputs: &PrimaryMap<LocalFunctionIndex, FunctionBodyData<'_>>, _symbol_registry: &dyn SymbolRegistry, _wasmer_metadata: &[u8], ) -> Option<Result<Vec<u8>, CompileError>>
Compiles a module into a native object file.
It returns the bytes as a &[u8]
or a [CompileError
].
sourcefn get_cpu_features_used(
&self,
cpu_features: &EnumSet<CpuFeature>,
) -> EnumSet<CpuFeature>
fn get_cpu_features_used( &self, cpu_features: &EnumSet<CpuFeature>, ) -> EnumSet<CpuFeature>
Get the CpuFeatues used by the compiler