diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 47207fafd..0641fae84 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -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 { if requires_pre_validation(MCG::backend_id()) { - validate(wasm)?; + validate(wasm, &compiler_config.features)?; } let mut mcg = MCG::new(); diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 282168d26..51be05641 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -85,8 +85,10 @@ pub fn read_module< custom_sections: HashMap::new(), })); - let mut parser = - wasmparser::ValidatingParser::new(wasm, Some(default_validating_parser_config())); + let mut parser = wasmparser::ValidatingParser::new( + wasm, + Some(validating_parser_config(&compiler_config.features)), + ); let mut namespace_builder = Some(StringTableBuilder::new()); let mut name_builder = Some(StringTableBuilder::new()); diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 0ac460dfc..b0ba2bde6 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -440,6 +440,9 @@ fn execute_wasm(options: &Run) -> Result<(), String> { CompilerConfig { symbol_map: em_symbol_map, track_state, + features: Features { + simd: options.features.simd || options.features.all, + }, ..Default::default() }, &*compiler,