mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 22:51:32 +00:00
Move requires pre validation into the ModuleCodeGenerator
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
use crate::fault::FaultInfo;
|
use crate::fault::FaultInfo;
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::RunnableModule,
|
backend::RunnableModule,
|
||||||
backend::{Backend, CacheGen, Compiler, CompilerConfig, Features, Token},
|
backend::{CacheGen, Compiler, CompilerConfig, Features, Token},
|
||||||
cache::{Artifact, Error as CacheError},
|
cache::{Artifact, Error as CacheError},
|
||||||
error::{CompileError, CompileResult},
|
error::{CompileError, CompileResult},
|
||||||
module::{ModuleInfo, ModuleInner},
|
module::{ModuleInfo, ModuleInner},
|
||||||
@ -94,6 +94,11 @@ pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule,
|
|||||||
/// Returns the backend id associated with this MCG.
|
/// Returns the backend id associated with this MCG.
|
||||||
fn backend_id() -> Backend;
|
fn backend_id() -> Backend;
|
||||||
|
|
||||||
|
/// It sets if the current compiler requires validation before compilation
|
||||||
|
fn requires_pre_validation(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
/// Feeds the compiler config.
|
/// Feeds the compiler config.
|
||||||
fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> {
|
fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -222,7 +227,7 @@ impl<
|
|||||||
compiler_config: CompilerConfig,
|
compiler_config: CompilerConfig,
|
||||||
_: Token,
|
_: Token,
|
||||||
) -> CompileResult<ModuleInner> {
|
) -> CompileResult<ModuleInner> {
|
||||||
if requires_pre_validation(MCG::backend_id()) {
|
if MCG::requires_pre_validation() {
|
||||||
validate_with_features(wasm, &compiler_config.features)?;
|
validate_with_features(wasm, &compiler_config.features)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,15 +268,6 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_pre_validation(backend: Backend) -> bool {
|
|
||||||
match backend {
|
|
||||||
Backend::Cranelift => true,
|
|
||||||
Backend::LLVM => true,
|
|
||||||
Backend::Singlepass => false,
|
|
||||||
Backend::Auto => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A sink for parse events.
|
/// A sink for parse events.
|
||||||
pub struct EventSink<'a, 'b> {
|
pub struct EventSink<'a, 'b> {
|
||||||
buffer: SmallVec<[Event<'a, 'b>; 2]>,
|
buffer: SmallVec<[Event<'a, 'b>; 2]>,
|
||||||
|
@ -646,12 +646,13 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_with_target(_: Option<String>, _: Option<String>, _: Option<String>) -> Self {
|
/// Singlepass does validation as it compiles
|
||||||
unimplemented!("cross compilation is not available for singlepass backend")
|
fn requires_pre_validation(&self) -> bool {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backend_id() -> Backend {
|
fn new_with_target(_: Option<String>, _: Option<String>, _: Option<String>) -> Self {
|
||||||
Backend::Singlepass
|
unimplemented!("cross compilation is not available for singlepass backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||||
|
Reference in New Issue
Block a user