Move requires pre validation into the ModuleCodeGenerator

This commit is contained in:
Syrus
2019-12-20 19:32:06 -08:00
parent 303d44cb0f
commit d4e964519d
2 changed files with 12 additions and 15 deletions

View File

@ -4,7 +4,7 @@
use crate::fault::FaultInfo;
use crate::{
backend::RunnableModule,
backend::{Backend, CacheGen, Compiler, CompilerConfig, Features, Token},
backend::{CacheGen, Compiler, CompilerConfig, Features, Token},
cache::{Artifact, Error as CacheError},
error::{CompileError, CompileResult},
module::{ModuleInfo, ModuleInner},
@ -94,6 +94,11 @@ pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule,
/// Returns the backend id associated with this MCG.
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.
fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> {
Ok(())
@ -222,7 +227,7 @@ impl<
compiler_config: CompilerConfig,
_: Token,
) -> CompileResult<ModuleInner> {
if requires_pre_validation(MCG::backend_id()) {
if MCG::requires_pre_validation() {
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.
pub struct EventSink<'a, 'b> {
buffer: SmallVec<[Event<'a, 'b>; 2]>,