Browse Source

upgrade to wasm-tools 0.211.1 (#8838)

* upgrade to wasm-tools 0.211.1

* code review

* cargo vet: auto imports

* fuzzing: fix wasm-smith changes

* fuzzing: changes for HeapType

* Configure features on `Parser` when parsing

---------

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
pull/8859/head
Pat Hickey 5 months ago
committed by GitHub
parent
commit
896e25e37f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 177
      Cargo.lock
  2. 18
      Cargo.toml
  3. 5
      cranelift/wasm/src/code_translator.rs
  4. 16
      crates/component-macro/src/bindgen.rs
  5. 4
      crates/environ/src/component/translate.rs
  6. 5
      crates/explorer/src/lib.rs
  7. 20
      crates/fuzzing/src/generators/config.rs
  8. 4
      crates/fuzzing/src/generators/table_ops.rs
  9. 31
      crates/types/src/lib.rs
  10. 3
      crates/wasmtime/src/compile.rs
  11. 11
      crates/wasmtime/src/runtime/coredump.rs
  12. 20
      crates/wast/src/core.rs
  13. 55
      supply-chain/imports.lock
  14. 6
      winch/codegen/src/visitor.rs

177
Cargo.lock

@ -863,7 +863,7 @@ dependencies = [
"serde_derive",
"smallvec",
"target-lexicon",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime-types",
"wat",
]
@ -2722,9 +2722,9 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.1.3"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
@ -2773,7 +2773,7 @@ dependencies = [
"cargo_metadata",
"heck 0.4.0",
"wasmtime",
"wit-component",
"wit-component 0.211.1",
]
[[package]]
@ -3103,7 +3103,7 @@ name = "verify-component-adapter"
version = "23.0.0"
dependencies = [
"anyhow",
"wasmparser",
"wasmparser 0.211.1",
"wat",
]
@ -3196,7 +3196,7 @@ dependencies = [
"byte-array-literals",
"object 0.36.0",
"wasi",
"wasm-encoder",
"wasm-encoder 0.211.1",
"wit-bindgen-rust-macro",
]
@ -3263,6 +3263,16 @@ dependencies = [
"leb128",
]
[[package]]
name = "wasm-encoder"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e7d931a1120ef357f32b74547646b6fa68ea25e377772b72874b131a9ed70d4"
dependencies = [
"leb128",
"wasmparser 0.211.1",
]
[[package]]
name = "wasm-metadata"
version = "0.209.1"
@ -3275,36 +3285,52 @@ dependencies = [
"serde_derive",
"serde_json",
"spdx",
"wasm-encoder",
"wasmparser",
"wasm-encoder 0.209.1",
"wasmparser 0.209.1",
]
[[package]]
name = "wasm-metadata"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f56bad1c68558c44e7f60be865117dc9d8c3a066bcf3b2232cb9a9858965fd5"
dependencies = [
"anyhow",
"indexmap 2.2.6",
"serde",
"serde_derive",
"serde_json",
"spdx",
"wasm-encoder 0.211.1",
"wasmparser 0.211.1",
]
[[package]]
name = "wasm-mutate"
version = "0.209.1"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f58dddabebff47e1a4f22fbe7fbb769ab699cd9efe7552f50ce5d0881f006884"
checksum = "b4281d9c72b0a3c47eec052755ad98cb854309e3a40edf9887aa8f3ed939f7ab"
dependencies = [
"egg",
"log",
"rand",
"thiserror",
"wasm-encoder",
"wasmparser",
"wasm-encoder 0.211.1",
"wasmparser 0.211.1",
]
[[package]]
name = "wasm-smith"
version = "0.209.1"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38482bb6ce309f7b5b8a168209d0e5c1df8643f1026fc21aaa196058f16d42e8"
checksum = "94ae0d1bd7d17e7ae175f9e3cf646d9b39b7115240ed8d40141c4670bab49f96"
dependencies = [
"anyhow",
"arbitrary",
"flagset",
"indexmap 2.2.6",
"leb128",
"wasm-encoder",
"wasm-encoder 0.211.1",
]
[[package]]
@ -3352,6 +3378,19 @@ name = "wasmparser"
version = "0.209.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db"
dependencies = [
"ahash",
"bitflags 2.4.1",
"hashbrown 0.14.3",
"indexmap 2.2.6",
"semver",
]
[[package]]
name = "wasmparser"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3189cc8a91f547390e2f043ca3b3e3fe0892f7d581767fd4e4b7f3dc3fe8e561"
dependencies = [
"ahash",
"bitflags 2.4.1",
@ -3372,12 +3411,13 @@ dependencies = [
[[package]]
name = "wasmprinter"
version = "0.209.1"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceca8ae6eaa8c7c87b33c25c53bdf299f8c2a764aee1179402ff7652ef3a6859"
checksum = "23708dd7a986bd9b12fca26eff525bbc3659a336e947fd9ed9fdf79086825aec"
dependencies = [
"anyhow",
"wasmparser",
"termcolor",
"wasmparser 0.211.1",
]
[[package]]
@ -3421,8 +3461,8 @@ dependencies = [
"target-lexicon",
"tempfile",
"wasi-common",
"wasm-encoder",
"wasmparser",
"wasm-encoder 0.211.1",
"wasmparser 0.211.1",
"wasmtime-asm-macros",
"wasmtime-cache",
"wasmtime-component-macro",
@ -3564,7 +3604,7 @@ dependencies = [
"tracing",
"walkdir",
"wasi-common",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime",
"wasmtime-cache",
"wasmtime-cli-flags",
@ -3578,10 +3618,10 @@ dependencies = [
"wasmtime-wasi-nn",
"wasmtime-wasi-threads",
"wasmtime-wast",
"wast 209.0.1",
"wast 211.0.1",
"wat",
"windows-sys 0.52.0",
"wit-component",
"wit-component 0.211.1",
]
[[package]]
@ -3614,7 +3654,7 @@ dependencies = [
"wasmtime",
"wasmtime-component-util",
"wasmtime-wit-bindgen",
"wit-parser",
"wit-parser 0.211.1",
]
[[package]]
@ -3638,7 +3678,7 @@ dependencies = [
"object 0.36.0",
"target-lexicon",
"thiserror",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime-environ",
"wasmtime-versioned-export-macros",
]
@ -3663,8 +3703,8 @@ dependencies = [
"serde",
"serde_derive",
"target-lexicon",
"wasm-encoder",
"wasmparser",
"wasm-encoder 0.211.1",
"wasmparser 0.211.1",
"wasmprinter",
"wasmtime-component-util",
"wasmtime-types",
@ -3679,7 +3719,7 @@ dependencies = [
"component-fuzz-util",
"env_logger",
"libfuzzer-sys",
"wasmparser",
"wasmparser 0.211.1",
"wasmprinter",
"wasmtime-environ",
"wat",
@ -3737,7 +3777,7 @@ dependencies = [
"rand",
"smallvec",
"target-lexicon",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime",
"wasmtime-fuzzing",
]
@ -3758,12 +3798,12 @@ dependencies = [
"target-lexicon",
"tempfile",
"v8",
"wasm-encoder",
"wasm-encoder 0.211.1",
"wasm-mutate",
"wasm-smith",
"wasm-spec-interpreter",
"wasmi",
"wasmparser",
"wasmparser 0.211.1",
"wasmprinter",
"wasmtime",
"wasmtime-wast",
@ -3813,7 +3853,7 @@ dependencies = [
"serde",
"serde_derive",
"smallvec",
"wasmparser",
"wasmparser 0.211.1",
]
[[package]]
@ -3921,7 +3961,7 @@ dependencies = [
"anyhow",
"log",
"wasmtime",
"wast 209.0.1",
"wast 211.0.1",
]
[[package]]
@ -3933,7 +3973,7 @@ dependencies = [
"gimli",
"object 0.36.0",
"target-lexicon",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime-cranelift",
"wasmtime-environ",
"winch-codegen",
@ -3946,7 +3986,7 @@ dependencies = [
"anyhow",
"heck 0.4.0",
"indexmap 2.2.6",
"wit-parser",
"wit-parser 0.211.1",
]
[[package]]
@ -3964,24 +4004,24 @@ dependencies = [
[[package]]
name = "wast"
version = "209.0.1"
version = "211.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fffef2ff6147e4d12e972765fd75332c6a11c722571d4ab7a780d81ffc8f0a4"
checksum = "b25506dd82d00da6b14a87436b3d52b1d264083fa79cdb72a0d1b04a8595ccaa"
dependencies = [
"bumpalo",
"leb128",
"memchr",
"unicode-width",
"wasm-encoder",
"wasm-encoder 0.211.1",
]
[[package]]
name = "wat"
version = "1.209.1"
version = "1.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42203ec0271d113f8eb1f77ebc624886530cecb35915a7f63a497131f16e4d24"
checksum = "eb716ca6c86eecac2d82541ffc39860118fc0af9309c4f2670637bea2e1bdd7d"
dependencies = [
"wast 209.0.1",
"wast 211.0.1",
]
[[package]]
@ -4101,7 +4141,7 @@ dependencies = [
"regalloc2",
"smallvec",
"target-lexicon",
"wasmparser",
"wasmparser 0.211.1",
"wasmtime-cranelift",
"wasmtime-environ",
]
@ -4294,7 +4334,7 @@ checksum = "36d4706efb67fadfbbde77955b299b111dd096e6776d8c6561d92f6147941880"
dependencies = [
"anyhow",
"heck 0.5.0",
"wit-parser",
"wit-parser 0.209.1",
]
[[package]]
@ -4315,9 +4355,9 @@ dependencies = [
"anyhow",
"heck 0.5.0",
"indexmap 2.2.6",
"wasm-metadata",
"wasm-metadata 0.209.1",
"wit-bindgen-core",
"wit-component",
"wit-component 0.209.1",
]
[[package]]
@ -4347,10 +4387,29 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser",
"wit-parser",
"wasm-encoder 0.209.1",
"wasm-metadata 0.209.1",
"wasmparser 0.209.1",
"wit-parser 0.209.1",
]
[[package]]
name = "wit-component"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "079a38b7d679867424bf2bcbdd553a2acf364525307e43dfb910fa4a2c6fd9f2"
dependencies = [
"anyhow",
"bitflags 2.4.1",
"indexmap 2.2.6",
"log",
"serde",
"serde_derive",
"serde_json",
"wasm-encoder 0.211.1",
"wasm-metadata 0.211.1",
"wasmparser 0.211.1",
"wit-parser 0.211.1",
]
[[package]]
@ -4368,7 +4427,25 @@ dependencies = [
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser",
"wasmparser 0.209.1",
]
[[package]]
name = "wit-parser"
version = "0.211.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3cc90c50c7ec8a824b5d2cddddff13b2dc12b7a96bf8684d11474223c2ea22f"
dependencies = [
"anyhow",
"id-arena",
"indexmap 2.2.6",
"log",
"semver",
"serde",
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser 0.211.1",
]
[[package]]

18
Cargo.toml

@ -253,15 +253,15 @@ wit-bindgen = { version = "0.26.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.26.0", default-features = false }
# wasm-tools family:
wasmparser = { version = "0.209.1", default-features = false }
wat = "1.209.1"
wast = "209.0.1"
wasmprinter = "0.209.1"
wasm-encoder = "0.209.1"
wasm-smith = "0.209.1"
wasm-mutate = "0.209.1"
wit-parser = "0.209.1"
wit-component = "0.209.1"
wasmparser = { version = "0.211.1", default-features = false }
wat = "1.211.1"
wast = "211.0.1"
wasmprinter = "0.211.1"
wasm-encoder = "0.211.1"
wasm-smith = "0.211.1"
wasm-mutate = "0.211.1"
wit-parser = "0.211.1"
wit-component = "0.211.1"
# Non-Bytecode Alliance maintained dependencies:
# --------------------------

5
cranelift/wasm/src/code_translator.rs

@ -639,7 +639,6 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::CallIndirect {
type_index,
table_index,
table_byte: _,
} => {
// `type_index` is the index of the function's signature and
// `table_index` is the index of the table to search the function
@ -750,7 +749,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
* Memory management is handled by environment. It is usually translated into calls to
* special functions.
************************************************************************************/
Operator::MemoryGrow { mem, mem_byte: _ } => {
Operator::MemoryGrow { mem } => {
// The WebAssembly MVP only supports one linear memory, but we expect the reserved
// argument to be a memory index.
let heap_index = MemoryIndex::from_u32(*mem);
@ -759,7 +758,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
environ.before_memory_grow(builder, val, heap_index);
state.push1(environ.translate_memory_grow(builder.cursor(), heap_index, heap, val)?)
}
Operator::MemorySize { mem, mem_byte: _ } => {
Operator::MemorySize { mem } => {
let heap_index = MemoryIndex::from_u32(*mem);
let heap = state.get_heap(builder.func, *mem, environ)?;
state.push1(environ.translate_memory_size(builder.cursor(), heap_index, heap)?);

16
crates/component-macro/src/bindgen.rs

@ -9,7 +9,7 @@ use syn::parse::{Error, Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::{braced, token, Token};
use wasmtime_wit_bindgen::{AsyncConfig, Opts, Ownership, TrappableError, TrappableImports};
use wit_parser::{PackageId, Resolve, UnresolvedPackage, WorldId};
use wit_parser::{PackageId, Resolve, UnresolvedPackageGroup, WorldId};
pub struct Config {
opts: Opts,
@ -170,11 +170,11 @@ impl Parse for Config {
path = Some(input.parse::<syn::LitStr>()?.value());
}
}
let (resolve, pkg, files) = parse_source(&path, &inline, &features)
let (resolve, pkgs, files) = parse_source(&path, &inline, &features)
.map_err(|err| Error::new(call_site, format!("{err:?}")))?;
let world = resolve
.select_world(pkg, world.as_deref())
.select_world(&pkgs, world.as_deref())
.map_err(|e| Error::new(call_site, format!("{e:?}")))?;
Ok(Config {
opts,
@ -190,7 +190,7 @@ fn parse_source(
path: &Option<String>,
inline: &Option<String>,
features: &[String],
) -> anyhow::Result<(Resolve, PackageId, Vec<PathBuf>)> {
) -> anyhow::Result<(Resolve, Vec<PackageId>, Vec<PathBuf>)> {
let mut resolve = Resolve::default();
resolve.features.extend(features.iter().cloned());
let mut files = Vec::new();
@ -208,17 +208,17 @@ fn parse_source(
None
};
let inline_pkg = if let Some(inline) = inline {
Some(resolve.push(UnresolvedPackage::parse("macro-input".as_ref(), inline)?)?)
let inline_pkgs = if let Some(inline) = inline {
Some(resolve.push_group(UnresolvedPackageGroup::parse("macro-input", inline)?)?)
} else {
None
};
let pkg = inline_pkg
let pkgs = inline_pkgs
.or(path_pkg)
.map_or_else(|| parse(&mut resolve, &root.join("wit")), Ok)?;
Ok((resolve, pkg, files))
Ok((resolve, pkgs, files))
}
mod kw {

4
crates/environ/src/component/translate.rs

@ -273,12 +273,14 @@ impl<'a, 'data> Translator<'a, 'data> {
types: &'a mut ComponentTypesBuilder,
scope_vec: &'data ScopeVec<u8>,
) -> Self {
let mut parser = Parser::new(0);
parser.set_features(*validator.features());
Self {
result: Translation::default(),
tunables,
validator,
types: PreInliningComponentTypes::new(types),
parser: Parser::new(0),
parser,
lexical_scopes: Vec::new(),
static_components: Default::default(),
static_modules: Default::default(),

5
crates/explorer/src/lib.rs

@ -66,9 +66,10 @@ struct AnnotatedWatChunk {
}
fn annotate_wat(wasm: &[u8]) -> Result<AnnotatedWat> {
let mut printer = wasmprinter::Printer::new();
let printer = wasmprinter::Config::new();
let mut storage = String::new();
let chunks = printer
.offsets_and_lines(wasm)?
.offsets_and_lines(wasm, &mut storage)?
.map(|(offset, wat)| AnnotatedWatChunk {
wasm_offset: offset.map(|o| WasmOffset(u32::try_from(o).unwrap())),
wat: wat.to_string(),

20
crates/fuzzing/src/generators/config.rs

@ -48,8 +48,8 @@ impl Config {
// Allow a memory to be generated, but don't let it get too large.
// Additionally require the maximum size to guarantee that the growth
// behavior is consistent across engines.
config.max_memory32_pages = 10;
config.max_memory64_pages = 10;
config.max_memory32_bytes = 10 << 16;
config.max_memory64_bytes = 10 << 16;
config.memory_max_size_required = true;
// If tables are generated make sure they don't get too large to avoid
@ -428,14 +428,18 @@ impl<'a> Arbitrary<'a> for Config {
// Ensure the pooling allocator can support the maximal size of
// memory, picking the smaller of the two to win.
let min_pages = cfg.max_memory32_pages.min(cfg.max_memory64_pages);
let mut min = (min_pages << 16).min(pooling.max_memory_size as u64);
let min_bytes = cfg
.max_memory32_bytes
// memory64_bytes is a u128, but since we are taking the min
// we can truncate it down to a u64.
.min(cfg.max_memory64_bytes.try_into().unwrap_or(u64::MAX));
let mut min = min_bytes.min(pooling.max_memory_size as u64);
if let MemoryConfig::Normal(cfg) = &config.wasmtime.memory_config {
min = min.min(cfg.static_memory_maximum_size.unwrap_or(0));
}
pooling.max_memory_size = min as usize;
cfg.max_memory32_pages = min >> 16;
cfg.max_memory64_pages = min >> 16;
cfg.max_memory32_bytes = min;
cfg.max_memory64_bytes = min as u128;
// If traps are disallowed then memories must have at least one page
// of memory so if we still are only allowing 0 pages of memory then
@ -443,8 +447,8 @@ impl<'a> Arbitrary<'a> for Config {
if cfg.disallow_traps {
if pooling.max_memory_size < (1 << 16) {
pooling.max_memory_size = 1 << 16;
cfg.max_memory32_pages = 1;
cfg.max_memory64_pages = 1;
cfg.max_memory32_bytes = 1 << 16;
cfg.max_memory64_bytes = 1 << 16;
if let MemoryConfig::Normal(cfg) = &mut config.wasmtime.memory_config {
match &mut cfg.static_memory_maximum_size {
Some(size) => *size = (*size).max(pooling.max_memory_size as u64),

4
crates/fuzzing/src/generators/table_ops.rs

@ -97,7 +97,7 @@ impl TableOps {
mutable: true,
shared: false,
},
&ConstExpr::ref_null(wasm_encoder::HeapType::Extern),
&ConstExpr::ref_null(wasm_encoder::HeapType::EXTERN),
);
}
@ -263,7 +263,7 @@ impl TableOp {
func.instruction(&Instruction::Drop);
}
Self::Null => {
func.instruction(&Instruction::RefNull(wasm_encoder::HeapType::Extern));
func.instruction(&Instruction::RefNull(wasm_encoder::HeapType::EXTERN));
}
}
}

31
crates/types/src/lib.rs

@ -1735,21 +1735,24 @@ pub trait TypeConvert {
/// Converts a wasmparser heap type to a wasmtime type
fn convert_heap_type(&self, ty: wasmparser::HeapType) -> WasmHeapType {
match ty {
wasmparser::HeapType::Extern => WasmHeapType::Extern,
wasmparser::HeapType::NoExtern => WasmHeapType::NoExtern,
wasmparser::HeapType::Func => WasmHeapType::Func,
wasmparser::HeapType::NoFunc => WasmHeapType::NoFunc,
wasmparser::HeapType::Concrete(i) => self.lookup_heap_type(i),
wasmparser::HeapType::Any => WasmHeapType::Any,
wasmparser::HeapType::Eq => WasmHeapType::Eq,
wasmparser::HeapType::I31 => WasmHeapType::I31,
wasmparser::HeapType::Array => WasmHeapType::Array,
wasmparser::HeapType::Struct => WasmHeapType::Struct,
wasmparser::HeapType::None => WasmHeapType::None,
wasmparser::HeapType::Exn | wasmparser::HeapType::NoExn => {
unimplemented!("unsupported heap type {ty:?}");
}
wasmparser::HeapType::Abstract { ty, shared: false } => match ty {
wasmparser::AbstractHeapType::Extern => WasmHeapType::Extern,
wasmparser::AbstractHeapType::NoExtern => WasmHeapType::NoExtern,
wasmparser::AbstractHeapType::Func => WasmHeapType::Func,
wasmparser::AbstractHeapType::NoFunc => WasmHeapType::NoFunc,
wasmparser::AbstractHeapType::Any => WasmHeapType::Any,
wasmparser::AbstractHeapType::Eq => WasmHeapType::Eq,
wasmparser::AbstractHeapType::I31 => WasmHeapType::I31,
wasmparser::AbstractHeapType::Array => WasmHeapType::Array,
wasmparser::AbstractHeapType::Struct => WasmHeapType::Struct,
wasmparser::AbstractHeapType::None => WasmHeapType::None,
wasmparser::AbstractHeapType::Exn | wasmparser::AbstractHeapType::NoExn => {
unimplemented!("unsupported heap type {ty:?}");
}
},
_ => unimplemented!("unsupported heap type {ty:?}"),
}
}

3
crates/wasmtime/src/compile.rs

@ -69,8 +69,9 @@ pub(crate) fn build_artifacts<T: FinishedObject>(
// about the wasm module. This is where the WebAssembly is parsed and
// validated. Afterwards `types` will have all the type information for
// this module.
let parser = wasmparser::Parser::new(0);
let mut parser = wasmparser::Parser::new(0);
let mut validator = wasmparser::Validator::new_with_features(engine.config().features.clone());
parser.set_features(*validator.features());
let mut types = ModuleTypesBuilder::new(&validator);
let mut translation = ModuleEnvironment::new(tunables, &mut validator, &mut types)
.translate(parser, wasm)

11
crates/wasmtime/src/runtime/coredump.rs

@ -181,10 +181,7 @@ impl WasmCoreDump {
HeapType::Func => wasm_encoder::ValType::FUNCREF,
HeapType::Any => wasm_encoder::ValType::Ref(wasm_encoder::RefType {
nullable: true,
heap_type: wasm_encoder::HeapType::Any,
}),
HeapType::Any => wasm_encoder::ValType::Ref(wasm_encoder::RefType::ANYREF),
ty => unreachable!("not a top type: {ty:?}"),
},
@ -200,13 +197,13 @@ impl WasmCoreDump {
}
Val::V128(x) => wasm_encoder::ConstExpr::v128_const(x.as_u128() as i128),
Val::FuncRef(_) => {
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::Func)
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::FUNC)
}
Val::ExternRef(_) => {
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::Extern)
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::EXTERN)
}
Val::AnyRef(_) => {
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::Any)
wasm_encoder::ConstExpr::ref_null(wasm_encoder::HeapType::ANY)
}
};
globals.global(

20
crates/wast/src/core.rs

@ -1,7 +1,7 @@
use anyhow::{bail, Context, Result};
use std::fmt::{Display, LowerHex};
use wasmtime::{ExternRef, Store, Val};
use wast::core::{HeapType, NanPattern, V128Pattern, WastArgCore, WastRetCore};
use wast::core::{AbstractHeapType, HeapType, NanPattern, V128Pattern, WastArgCore, WastRetCore};
use wast::token::{F32, F64};
/// Translate from a `script::Value` to a `RuntimeValue`.
@ -14,8 +14,14 @@ pub fn val<T>(store: &mut Store<T>, v: &WastArgCore<'_>) -> Result<Val> {
F32(x) => Val::F32(x.bits),
F64(x) => Val::F64(x.bits),
V128(x) => Val::V128(u128::from_le_bytes(x.to_le_bytes()).into()),
RefNull(HeapType::Extern) => Val::ExternRef(None),
RefNull(HeapType::Func) => Val::FuncRef(None),
RefNull(HeapType::Abstract {
ty: AbstractHeapType::Extern,
shared: false,
}) => Val::ExternRef(None),
RefNull(HeapType::Abstract {
ty: AbstractHeapType::Func,
shared: false,
}) => Val::FuncRef(None),
RefExtern(x) => Val::ExternRef(Some(ExternRef::new(store, *x)?)),
other => bail!("couldn't convert {:?} to a runtime value", other),
})
@ -68,7 +74,13 @@ pub fn match_val<T>(store: &Store<T>, actual: &Val, expected: &WastRetCore) -> R
(Val::ExternRef(None), WastRetCore::RefExtern(Some(_))) => {
bail!("expected non-null reference, found null")
}
(Val::ExternRef(Some(x)), WastRetCore::RefNull(Some(HeapType::Extern))) => {
(
Val::ExternRef(Some(x)),
WastRetCore::RefNull(Some(HeapType::Abstract {
ty: AbstractHeapType::Extern,
shared: false,
})),
) => {
let x = x
.data(store)?
.downcast_ref::<u32>()

55
supply-chain/imports.lock

@ -1662,6 +1662,13 @@ user-id = 189
user-login = "BurntSushi"
user-name = "Andrew Gallant"
[[publisher.termcolor]]
version = "1.4.1"
when = "2024-01-10"
user-id = 189
user-login = "BurntSushi"
user-name = "Andrew Gallant"
[[publisher.thiserror]]
version = "1.0.43"
when = "2023-07-07"
@ -1831,6 +1838,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasm-encoder]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasm-metadata]]
version = "0.201.0"
when = "2024-02-27"
@ -1885,6 +1898,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasm-metadata]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasm-mutate]]
version = "0.201.0"
when = "2024-02-27"
@ -2011,6 +2030,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasmparser]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasmprinter]]
version = "0.201.0"
when = "2024-02-27"
@ -2065,6 +2090,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasmprinter]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wasmtime]]
version = "18.0.2"
when = "2024-02-28"
@ -2671,6 +2702,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wast]]
version = "211.0.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wat]]
version = "1.201.0"
when = "2024-02-27"
@ -2725,6 +2762,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wat]]
version = "1.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wiggle]]
version = "18.0.2"
when = "2024-02-28"
@ -3157,6 +3200,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wit-component]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wit-parser]]
version = "0.201.0"
when = "2024-02-27"
@ -3211,6 +3260,12 @@ when = "2024-05-29"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.wit-parser]]
version = "0.211.1"
when = "2024-06-19"
user-id = 73222
user-login = "wasmtime-publish"
[[publisher.witx]]
version = "0.9.1"
when = "2021-06-22"

6
winch/codegen/src/visitor.rs

@ -1357,7 +1357,7 @@ where
FnCall::emit::<M>(&mut self.env, self.masm, &mut self.context, callee)
}
fn visit_call_indirect(&mut self, type_index: u32, table_index: u32, _: u8) {
fn visit_call_indirect(&mut self, type_index: u32, table_index: u32) {
// Spill now because `emit_lazy_init_funcref` and the `FnCall::emit`
// invocations will both trigger spills since they both call functions.
// However, the machine instructions for the spill emitted by
@ -1603,12 +1603,12 @@ where
)
}
fn visit_memory_size(&mut self, mem: u32, _: u8) {
fn visit_memory_size(&mut self, mem: u32) {
let heap = self.env.resolve_heap(MemoryIndex::from_u32(mem));
self.emit_compute_memory_size(&heap);
}
fn visit_memory_grow(&mut self, mem: u32, _: u8) {
fn visit_memory_grow(&mut self, mem: u32) {
debug_assert!(self.context.stack.len() >= 1);
// The stack at this point contains: [ delta ]
// The desired state is

Loading…
Cancel
Save