Use --enable-simd to control whether SIMD is enabled in the wasmparser.

Before this change, 'wasmer run --backend=llvm some-simd.wasm' would run without complaint.

Also, note that the flag is not part of the cache key, so after any successful run, we can run it again without passing the flag.
This commit is contained in:
Nick Lewycky
2019-07-27 11:13:13 -07:00
committed by Nick Lewycky
parent 514eb70194
commit 86316c474a
3 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,6 @@
use crate::{
backend::RunnableModule,
backend::{Backend, CacheGen, Compiler, CompilerConfig, Token},
backend::{Backend, CacheGen, Compiler, CompilerConfig, Features, Token},
cache::{Artifact, Error as CacheError},
error::{CompileError, CompileResult},
module::{ModuleInfo, ModuleInner},
@ -137,12 +137,12 @@ impl<
}
}
pub fn default_validating_parser_config() -> wasmparser::ValidatingParserConfig {
pub fn validating_parser_config(features: &Features) -> wasmparser::ValidatingParserConfig {
wasmparser::ValidatingParserConfig {
operator_config: wasmparser::OperatorValidatorConfig {
enable_threads: false,
enable_reference_types: false,
enable_simd: true,
enable_simd: features.simd,
enable_bulk_memory: false,
enable_multi_value: false,
},
@ -150,9 +150,9 @@ pub fn default_validating_parser_config() -> wasmparser::ValidatingParserConfig
}
}
fn validate(bytes: &[u8]) -> CompileResult<()> {
fn validate(bytes: &[u8], features: &Features) -> CompileResult<()> {
let mut parser =
wasmparser::ValidatingParser::new(bytes, Some(default_validating_parser_config()));
wasmparser::ValidatingParser::new(bytes, Some(validating_parser_config(features)));
loop {
let state = parser.read();
match *state {
@ -180,7 +180,7 @@ impl<
_: Token,
) -> CompileResult<ModuleInner> {
if requires_pre_validation(MCG::backend_id()) {
validate(wasm)?;
validate(wasm, &compiler_config.features)?;
}
let mut mcg = MCG::new();