Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmparser: feature gate Wasm simd support #1903

Merged
merged 84 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
827b128
add for_each_simd_operator generator macro
Robbepop Nov 12, 2024
5944fb9
define SimdOperator enum
Robbepop Nov 12, 2024
d3e99f0
add SimdOperator::operator_arity impl
Robbepop Nov 12, 2024
9698f97
add VisitSimdOperator trait definition
Robbepop Nov 12, 2024
76557eb
define VisitSimdOperator delegates
Robbepop Nov 12, 2024
6adace1
add benchmark NopVisit impl
Robbepop Nov 12, 2024
2fa11f2
add simd crate feature
Robbepop Nov 12, 2024
baa1de5
add simd_visitor method to VisitOperator trait
Robbepop Nov 12, 2024
bb4a415
add VisitSimdOperator impl to OperatorFactory
Robbepop Nov 12, 2024
df32e79
use VisitOperator::simd_visitor in BinaryReader::visit_operator
Robbepop Nov 12, 2024
de0f049
add lifetime to return value of simd_visitor method
Robbepop Nov 12, 2024
efd1c0c
add VisitSimdOperator impl for OperatorValidator
Robbepop Nov 12, 2024
26cc42d
add Operator::Simd variant
Robbepop Nov 12, 2024
ac2d6a8
remove simd operators from for_each_operator macro
Robbepop Nov 12, 2024
531240e
adjust wasmprinter crate for simd crate feature
Robbepop Nov 19, 2024
5c94737
enable wasmparser's simd feature by default
Robbepop Nov 19, 2024
bfb354a
fix trait impl signature
Robbepop Nov 19, 2024
e257fcb
add docs to wasmparser's simd crate feature
Robbepop Nov 19, 2024
eb3845d
feature gate simd related code in wasmparser
Robbepop Nov 19, 2024
77a33de
update docs for SimdOperator
Robbepop Nov 19, 2024
7439a1f
add missing `simd` crate feature gates
Robbepop Nov 19, 2024
82412a5
Merge branch 'main' into rf-feature-gate-simd
Robbepop Nov 19, 2024
c373909
move simd op validation down in file
Robbepop Nov 19, 2024
267808c
put simd specific operator validation in separate file
Robbepop Nov 19, 2024
28e15df
add docs to for_each_simd_operator macro
Robbepop Nov 19, 2024
faa8317
move for_each_simd_operator macro into a separate file
Robbepop Nov 19, 2024
6eef116
fix docs for VisitSimdOperator
Robbepop Nov 19, 2024
cc88460
allow missing docs again for VisitSimdOperator
Robbepop Nov 19, 2024
a703340
add docs and example to VisitOperator::simd_visitor
Robbepop Nov 19, 2024
e6614e0
move visit_0xfd_operator into separate file
Robbepop Nov 19, 2024
3c9559c
apply rustftm
Robbepop Nov 19, 2024
a8f67fe
wasmprinter: fix remaining simd feature toggles
Robbepop Nov 19, 2024
c9204e6
apply rustfmt
Robbepop Nov 19, 2024
2755180
fix wasmparser benchmarks
Robbepop Nov 19, 2024
accb113
wasm-encoder: add simd support
Robbepop Nov 19, 2024
c87a791
apply rustfmt and avoid formatting some parts
Robbepop Nov 19, 2024
7b0a04b
wasm-mutate: fix compile errors
Robbepop Nov 19, 2024
76d4d6a
apply rustfmt
Robbepop Nov 19, 2024
7c7eb46
fix dev-dependencies for wasm-mutate
Robbepop Nov 19, 2024
73fb3ba
add simd_visitor impl to NopVisitor
Robbepop Nov 19, 2024
a458b3a
add missing VisitSimdOperator impl for WasmProposalValidator
Robbepop Nov 19, 2024
8924923
mark doc example as compile_fail
Robbepop Nov 20, 2024
8884f95
add simd support for VisitConstOperator
Robbepop Nov 20, 2024
0beba9e
use wasmparser/simd in validate tool
Robbepop Nov 20, 2024
351e169
add simd crate feature propagation to wasm-tools CLI tool
Robbepop Nov 20, 2024
04f34ab
wasm-smith: use wasmparser/simd crate feature
Robbepop Nov 20, 2024
c419be7
apply rustfmt
Robbepop Nov 20, 2024
5c1eeb4
feature gate simd_visitor impl
Robbepop Nov 20, 2024
cec6bb7
unconditionally enable simd for wasmprinter
Robbepop Nov 21, 2024
1dfbf6e
unconditionally enable simd for wasm-encoder
Robbepop Nov 21, 2024
a98227f
remove wasm-tools simd feature (enable by default)
Robbepop Nov 21, 2024
efa3d43
use macros generate for_each_operator macros
Robbepop Nov 21, 2024
887a8cf
remove comment out line
Robbepop Nov 21, 2024
cbbc575
put docs on the exported macros
Robbepop Nov 21, 2024
ba48386
fix macro imports
Robbepop Nov 21, 2024
6b9a883
fix bugs in generator macros
Robbepop Nov 22, 2024
91ddc75
improve compile times for macros
Robbepop Nov 23, 2024
821b34d
group macro operators together
Robbepop Nov 25, 2024
da653b6
restructure for_each_operator macros
Robbepop Nov 25, 2024
0123e1c
apply rustfmt
Robbepop Nov 25, 2024
88e447a
re-structure the new exposed macros
Robbepop Nov 26, 2024
dd7319b
fix macro doc links
Robbepop Nov 26, 2024
7e56835
fix broken doc links
Robbepop Nov 26, 2024
cbc4488
fix crate after making Operator enum inline
Robbepop Nov 26, 2024
941edc9
export all internal macro (debug)
Robbepop Nov 26, 2024
616146e
wasmprinter: use for_each_[visit[_simd]]_operator
Robbepop Nov 26, 2024
2740a31
wasm-encoder: use simd feature in dependencies
Robbepop Nov 26, 2024
d7258c8
fix wasm-encoder compilation
Robbepop Nov 26, 2024
f289121
wasmparser: use macros via crate:: namespace
Robbepop Nov 26, 2024
49455e6
expose macros via use statements
Robbepop Nov 26, 2024
3d452dc
use doc(inline)
Robbepop Nov 26, 2024
a2a1fe0
use intra-doc links
Robbepop Nov 26, 2024
bc19615
wit-component: fix wasmparser usage
Robbepop Nov 26, 2024
b7f7d43
wasm-mutate: fix wasmparser usage
Robbepop Nov 26, 2024
386ce2c
wasm-dump: fix wasmparser usage
Robbepop Nov 26, 2024
809e9c5
wasmparser: fix benchmarks
Robbepop Nov 26, 2024
4e9ec4a
fix doc tests
Robbepop Nov 26, 2024
05a94e3
change doc example for for_each_operator macro
Robbepop Nov 26, 2024
ba7d720
rename doc test macro
Robbepop Nov 26, 2024
87aba0c
fix typo
Robbepop Nov 26, 2024
c2823bc
apply rustfmt
Robbepop Nov 26, 2024
c07723b
craft new doc example for for_each_operator! macro
Robbepop Nov 26, 2024
36f024a
Minor changes
alexcrichton Nov 26, 2024
d8fddc8
A few more minor adjustments
alexcrichton Nov 26, 2024
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ wasm-metadata = { version = "0.220.0", path = "crates/wasm-metadata" }
wasm-mutate = { version = "0.220.0", path = "crates/wasm-mutate" }
wasm-shrink = { version = "0.220.0", path = "crates/wasm-shrink" }
wasm-smith = { version = "0.220.0", path = "crates/wasm-smith" }
wasmparser = { version = "0.220.0", path = "crates/wasmparser", default-features = false, features = ['std'] }
wasmparser = { version = "0.220.0", path = "crates/wasmparser", default-features = false, features = ['std','simd'] }
wasmprinter = { version = "0.220.0", path = "crates/wasmprinter", default-features = false }
wast = { version = "220.0.0", path = "crates/wast", default-features = false }
wat = { version = "1.220.0", path = "crates/wat", default-features = false }
Expand All @@ -122,7 +122,7 @@ wat = { workspace = true, features = ['dwarf', 'component-model'] }
termcolor = { workspace = true }

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

Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-encoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ leb128 = { workspace = true }

# Enable this dependency to get a bunch of `From<wasmparser::Foo> for
# wasm_encoder::Foo` impls.
wasmparser = { optional = true, workspace = true }
wasmparser = { optional = true, workspace = true, features = ["simd"] }

[dev-dependencies]
anyhow = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-encoder/src/reencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ pub mod utils {
translate!(build $op $($($arg)*)?)
}
)*
unexpected => unreachable!("encountered unexpected Wasm operator: {unexpected:?}"),
})
};

Expand Down
6 changes: 3 additions & 3 deletions crates/wasm-mutate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ workspace = true
[dependencies]
clap = { workspace = true, optional = true }
thiserror = "1.0.28"
wasmparser = { workspace = true }
wasm-encoder = { workspace = true, features = ["wasmparser"] }
wasmparser = { workspace = true, features = ['simd'] }
wasm-encoder = { workspace = true, features = ['wasmparser'] }
rand = { workspace = true }
log = { workspace = true }
egg = "0.6.0"
Expand All @@ -24,4 +24,4 @@ anyhow = { workspace = true }
wat = { workspace = true }
wasmprinter = { workspace = true }
env_logger = { workspace = true }
wasmparser = { workspace = true, features = ['validate', 'features'] }
wasmparser = { workspace = true, features = ['validate', 'features', 'simd'] }
4 changes: 2 additions & 2 deletions crates/wasm-smith/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ leb128 = { workspace = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
wasm-encoder = { workspace = true }
wasmparser = { workspace = true, optional = true, features = ['validate', 'features'] }
wasmparser = { workspace = true, optional = true, features = ['validate', 'features', 'simd'] }
wat = { workspace = true, optional = true }

[dev-dependencies]
criterion = { workspace = true }
rand = { workspace = true }
wasmparser = { workspace = true, features = ["validate", "features"] }
wasmparser = { workspace = true, features = ['validate', 'features', 'simd'] }
wasmprinter = { workspace = true }
wat = { workspace = true }

Expand Down
7 changes: 6 additions & 1 deletion crates/wasmparser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ name = "benchmark"
harness = false

[features]
default = ['std', 'validate', 'serde', 'features', 'component-model', 'hash-collections']
default = ['std', 'validate', 'serde', 'features', 'component-model', 'hash-collections', 'simd']

# A feature which enables implementations of `std::error::Error` as appropriate
# along with other convenience APIs. This additionally uses the standard
Expand Down Expand Up @@ -82,3 +82,8 @@ features = []
# WebAssembly. This is enabled by default but if your use case is only
# interested in working with core modules then this feature can be disabled.
component-model = ['dep:semver']

# A feature that enables parsing and validating the `simd` and `relaxed-simd`
# proposals for WebAssembly. This is enabled by default but if your use case is
# only interested in working on non-SIMD code then this feature can be disabled.
simd = []
12 changes: 11 additions & 1 deletion crates/wasmparser/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use once_cell::unsync::Lazy;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use wasmparser::VisitSimdOperator;
use wasmparser::{DataKind, ElementKind, Parser, Payload, Validator, VisitOperator, WasmFeatures};

/// A benchmark input.
Expand Down Expand Up @@ -364,5 +365,14 @@ macro_rules! define_visit_operator {
impl<'a> VisitOperator<'a> for NopVisit {
type Output = ();

wasmparser::for_each_operator!(define_visit_operator);
fn simd_visitor(&mut self) -> Option<&mut dyn VisitSimdOperator<'a, Output = Self::Output>> {
Some(self)
}

wasmparser::for_each_visit_operator!(define_visit_operator);
}

#[allow(unused_variables)]
impl<'a> VisitSimdOperator<'a> for NopVisit {
wasmparser::for_each_visit_simd_operator!(define_visit_operator);
}
2 changes: 1 addition & 1 deletion crates/wasmparser/src/arity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,6 @@ impl Operator<'_> {
}
);
}
for_each_operator!(define_arity)
crate::for_each_operator!(define_arity)
}
}
Loading