Update wasmparser to 0.59.0 (#2013)
This commit is intended to update wasmparser to 0.59.0. This primarily includes bytecodealliance/wasm-tools#40 which is a large update to how parsing and validation works. The impact on Wasmtime is pretty small at this time, but over time I'd like to refactor the internals here to lean more heavily on that upstream wasmparser refactoring. For now, though, the intention is to get on the train of wasmparser's latest `main` branch to ensure we get bug fixes and such. As part of this update a few other crates and such were updated. This is primarily to handle the new encoding of `ref.is_null` where the type is not part of the instruction encoding any more.
This commit is contained in:
@@ -14,7 +14,7 @@ wasmtime-runtime = { path = "../runtime", version = "0.18.0" }
|
||||
wasmtime-environ = { path = "../environ", version = "0.18.0" }
|
||||
wasmtime-jit = { path = "../jit", version = "0.18.0" }
|
||||
wasmtime-profiling = { path = "../profiling", version = "0.18.0" }
|
||||
wasmparser = "0.58.0"
|
||||
wasmparser = "0.59.0"
|
||||
target-lexicon = { version = "0.10.0", default-features = false }
|
||||
anyhow = "1.0.19"
|
||||
region = "2.2.0"
|
||||
|
||||
@@ -66,7 +66,7 @@ fn instantiate(
|
||||
let instance = store.add_instance(instance);
|
||||
instance
|
||||
.initialize(
|
||||
config.validating_config.operator_config.enable_bulk_memory,
|
||||
config.wasm_bulk_memory,
|
||||
&compiled_module.data_initializers(),
|
||||
)
|
||||
.map_err(|e| -> Error {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use crate::frame_info::GlobalFrameInfoRegistration;
|
||||
use crate::runtime::Engine;
|
||||
use crate::types::{EntityType, ExportType, ExternType, ImportType};
|
||||
use anyhow::{Error, Result};
|
||||
use anyhow::Result;
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use wasmparser::validate;
|
||||
use wasmtime_jit::CompiledModule;
|
||||
|
||||
/// A compiled WebAssembly module, ready to be instantiated.
|
||||
@@ -296,8 +295,8 @@ impl Module {
|
||||
///
|
||||
/// [binary]: https://webassembly.github.io/spec/core/binary/index.html
|
||||
pub fn validate(engine: &Engine, binary: &[u8]) -> Result<()> {
|
||||
let config = engine.config().validating_config.clone();
|
||||
validate(binary, Some(config)).map_err(Error::new)
|
||||
engine.config().validator().validate_all(binary)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
unsafe fn compile(engine: &Engine, binary: &[u8]) -> Result<Self> {
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::hash::{Hash, Hasher};
|
||||
use std::path::Path;
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::sync::Arc;
|
||||
use wasmparser::{OperatorValidatorConfig, ValidatingParserConfig};
|
||||
use wasmparser::Validator;
|
||||
use wasmtime_environ::settings::{self, Configurable, SetError};
|
||||
use wasmtime_environ::{ir, isa, isa::TargetIsa, wasm, CacheConfig, Tunables};
|
||||
use wasmtime_jit::{native, CompilationStrategy, Compiler};
|
||||
@@ -34,13 +34,17 @@ use wasmtime_runtime::{
|
||||
pub struct Config {
|
||||
pub(crate) flags: settings::Builder,
|
||||
pub(crate) isa_flags: isa::Builder,
|
||||
pub(crate) validating_config: ValidatingParserConfig,
|
||||
pub(crate) tunables: Tunables,
|
||||
pub(crate) strategy: CompilationStrategy,
|
||||
pub(crate) cache_config: CacheConfig,
|
||||
pub(crate) profiler: Arc<dyn ProfilingAgent>,
|
||||
pub(crate) memory_creator: Option<MemoryCreatorProxy>,
|
||||
pub(crate) max_wasm_stack: usize,
|
||||
wasm_threads: bool,
|
||||
wasm_reference_types: bool,
|
||||
pub(crate) wasm_bulk_memory: bool,
|
||||
wasm_simd: bool,
|
||||
wasm_multi_value: bool,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -81,17 +85,6 @@ impl Config {
|
||||
|
||||
Config {
|
||||
tunables,
|
||||
validating_config: ValidatingParserConfig {
|
||||
operator_config: OperatorValidatorConfig {
|
||||
enable_threads: false,
|
||||
enable_reference_types: false,
|
||||
enable_bulk_memory: false,
|
||||
enable_simd: false,
|
||||
enable_multi_value: true,
|
||||
enable_tail_call: false,
|
||||
enable_module_linking: false,
|
||||
},
|
||||
},
|
||||
flags,
|
||||
isa_flags: native::builder(),
|
||||
strategy: CompilationStrategy::Auto,
|
||||
@@ -99,6 +92,11 @@ impl Config {
|
||||
profiler: Arc::new(NullProfilerAgent),
|
||||
memory_creator: None,
|
||||
max_wasm_stack: 1 << 20,
|
||||
wasm_threads: false,
|
||||
wasm_reference_types: false,
|
||||
wasm_bulk_memory: false,
|
||||
wasm_simd: false,
|
||||
wasm_multi_value: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +161,7 @@ impl Config {
|
||||
///
|
||||
/// [threads]: https://github.com/webassembly/threads
|
||||
pub fn wasm_threads(&mut self, enable: bool) -> &mut Self {
|
||||
self.validating_config.operator_config.enable_threads = enable;
|
||||
self.wasm_threads = enable;
|
||||
// The threads proposal depends on the bulk memory proposal
|
||||
if enable {
|
||||
self.wasm_bulk_memory(true);
|
||||
@@ -193,9 +191,7 @@ impl Config {
|
||||
///
|
||||
/// [proposal]: https://github.com/webassembly/reference-types
|
||||
pub fn wasm_reference_types(&mut self, enable: bool) -> &mut Self {
|
||||
self.validating_config
|
||||
.operator_config
|
||||
.enable_reference_types = enable;
|
||||
self.wasm_reference_types = enable;
|
||||
|
||||
self.flags
|
||||
.set("enable_safepoints", if enable { "true" } else { "false" })
|
||||
@@ -230,7 +226,7 @@ impl Config {
|
||||
///
|
||||
/// [proposal]: https://github.com/webassembly/simd
|
||||
pub fn wasm_simd(&mut self, enable: bool) -> &mut Self {
|
||||
self.validating_config.operator_config.enable_simd = enable;
|
||||
self.wasm_simd = enable;
|
||||
let val = if enable { "true" } else { "false" };
|
||||
self.flags
|
||||
.set("enable_simd", val)
|
||||
@@ -254,7 +250,7 @@ impl Config {
|
||||
///
|
||||
/// [proposal]: https://github.com/webassembly/bulk-memory-operations
|
||||
pub fn wasm_bulk_memory(&mut self, enable: bool) -> &mut Self {
|
||||
self.validating_config.operator_config.enable_bulk_memory = enable;
|
||||
self.wasm_bulk_memory = enable;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -268,7 +264,7 @@ impl Config {
|
||||
///
|
||||
/// [proposal]: https://github.com/webassembly/multi-value
|
||||
pub fn wasm_multi_value(&mut self, enable: bool) -> &mut Self {
|
||||
self.validating_config.operator_config.enable_multi_value = enable;
|
||||
self.wasm_multi_value = enable;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -613,6 +609,16 @@ impl Config {
|
||||
.finish(settings::Flags::new(self.flags.clone()))
|
||||
}
|
||||
|
||||
pub(crate) fn validator(&self) -> Validator {
|
||||
let mut ret = Validator::new();
|
||||
ret.wasm_threads(self.wasm_threads)
|
||||
.wasm_bulk_memory(self.wasm_bulk_memory)
|
||||
.wasm_multi_value(self.wasm_multi_value)
|
||||
.wasm_reference_types(self.wasm_reference_types)
|
||||
.wasm_simd(self.wasm_simd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
fn build_compiler(&self) -> Compiler {
|
||||
let isa = self.target_isa();
|
||||
Compiler::new(
|
||||
@@ -640,15 +646,14 @@ impl Default for Config {
|
||||
|
||||
impl fmt::Debug for Config {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let features = &self.validating_config.operator_config;
|
||||
f.debug_struct("Config")
|
||||
.field("debug_info", &self.tunables.debug_info)
|
||||
.field("strategy", &self.strategy)
|
||||
.field("wasm_threads", &features.enable_threads)
|
||||
.field("wasm_reference_types", &features.enable_reference_types)
|
||||
.field("wasm_bulk_memory", &features.enable_bulk_memory)
|
||||
.field("wasm_simd", &features.enable_simd)
|
||||
.field("wasm_multi_value", &features.enable_multi_value)
|
||||
.field("wasm_threads", &self.wasm_threads)
|
||||
.field("wasm_reference_types", &self.wasm_reference_types)
|
||||
.field("wasm_bulk_memory", &self.wasm_bulk_memory)
|
||||
.field("wasm_simd", &self.wasm_simd)
|
||||
.field("wasm_multi_value", &self.wasm_multi_value)
|
||||
.field(
|
||||
"flags",
|
||||
&settings::Flags::new(self.flags.clone()).to_string(),
|
||||
|
||||
Reference in New Issue
Block a user