Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ env_logger = { workspace = true }
log = { workspace = true }
tempfile = "3.2.0"
termcolor = { workspace = true }
wasmparser = { workspace = true, features = ['std', 'component-model', 'simd'] }
wat = { workspace = true, features = ['dwarf', 'component-model'] }

# Dependencies of `validate`
bitflags = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }
wasmparser = { workspace = true, optional = true, features = ['std', 'component-model', 'simd'] }

# Dependencies of `print`
wasmprinter = { workspace = true, features = ['component-model'] }
Expand Down Expand Up @@ -191,6 +191,8 @@ pretty_assertions = { workspace = true }
serde_json = "1.0"
tempfile = "3.1"
wast = { workspace = true }
arbitrary = { workspace = true }
wasm-smith = { workspace = true }

[[test]]
name = "cli"
Expand Down Expand Up @@ -221,7 +223,6 @@ default = [

# Each subcommand is gated behind a feature and lists the dependencies it needs
validate = [
'dep:wasmparser',
'rayon',
'dep:addr2line',
'dep:gimli',
Expand All @@ -234,23 +235,22 @@ parse = []
smith = ['wasm-smith', 'arbitrary', 'dep:serde', 'dep:serde_derive', 'dep:serde_json']
shrink = ['wasm-shrink', 'is_executable']
mutate = ['wasm-mutate']
dump = ['dep:wasmparser']
objdump = ['dep:wasmparser']
strip = ['wasm-encoder', 'dep:wasmparser', 'regex']
compose = ['wasm-compose', 'dep:wasmparser']
demangle = ['rustc-demangle', 'cpp_demangle', 'dep:wasmparser', 'wasm-encoder']
dump = []
objdump = []
strip = ['wasm-encoder', 'regex']
compose = ['wasm-compose']
demangle = ['rustc-demangle', 'cpp_demangle', 'wasm-encoder']
component = [
'wit-component',
'wit-encoder',
'wit-parser',
'dep:wast',
'wasm-encoder',
'dep:wasmparser',
'dep:serde_json',
]
metadata = ['dep:wasmparser', 'wasm-metadata', 'dep:serde_json']
metadata = ['wasm-metadata', 'dep:serde_json']
wit-smith = ['dep:wit-smith', 'arbitrary']
addr2line = ['dep:addr2line', 'dep:gimli', 'dep:wasmparser']
addr2line = ['dep:addr2line', 'dep:gimli']
completion = ['dep:clap_complete']
json-from-wast = ['dep:serde_derive', 'dep:serde_json', 'dep:wast', 'dep:serde']
wast = [
Expand Down
6 changes: 6 additions & 0 deletions ci/generate-spec-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ fn copy_test(src: &Path, dst: &Path) {

let mut contents = format!(";; RUN: wast \\\n");
contents.push_str(";; --assert default \\\n");

// Allow certain assert_malformed tests to be interpreted as assert_invalid
if src.iter().any(|p| p == "binary.wast") {
contents.push_str(";; --assert permissive \\\n");
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh I like this, nice idea 👍

contents.push_str(";; --snapshot tests/snapshots \\\n");

// This test specifically tests various forms of unicode which are
Expand Down
12 changes: 6 additions & 6 deletions crates/wasmparser/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ fn read_all_wasm(wasm: &[u8]) -> Result<()> {
}
}
CodeSectionEntry(body) => {
let mut reader = body.get_binary_reader();
for _ in 0..reader.read_var_u32()? {
reader.read_var_u32()?;
reader.read::<wasmparser::ValType>()?;
for item in body.get_locals_reader()? {
let _ = item?;
}
while !reader.eof() {
reader.visit_operator(&mut NopVisit)?;
let mut ops = body.get_operators_reader()?;
while !ops.eof() {
ops.visit_operator(&mut NopVisit)?;
}
ops.finish()?;
}

// Component sections
Expand Down
15 changes: 6 additions & 9 deletions crates/wasmparser/src/arity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/

use crate::{
BinaryReader, BinaryReaderError, BlockType, CompositeInnerType, ContType, FrameKind, FuncType,
Operator, RefType, Result, SubType,
BinaryReaderError, BlockType, CompositeInnerType, ContType, FrameKind, FuncType, Operator,
OperatorsReader, RefType, Result, SubType,
};

/// To compute the arity (param and result counts) of "variable-arity"
Expand Down Expand Up @@ -69,15 +69,12 @@ pub trait ModuleArity {
}
}

impl BinaryReader<'_> {
impl OperatorsReader<'_> {
/// Read the next operator and compute its arity (param and result counts)
pub fn operator_arity(&self, module: &impl ModuleArity) -> Result<(u32, u32)> {
self.clone()
.read_operator()?
.operator_arity(module)
.ok_or_else(|| {
BinaryReaderError::new("operator arity is unknown", self.original_position())
})
self.clone().read()?.operator_arity(module).ok_or_else(|| {
BinaryReaderError::new("operator arity is unknown", self.original_position())
})
}
}

Expand Down
Loading