Skip to content

Commit 81dc6e7

Browse files
feat: switch back to upstream wasmparser
Signed-off-by: Henry Gressmann <[email protected]>
1 parent 704a8da commit 81dc6e7

File tree

5 files changed

+41
-56
lines changed

5 files changed

+41
-56
lines changed

Cargo.lock

Lines changed: 15 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/parser/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ authors.workspace=true
88
repository.workspace=true
99

1010
[dependencies]
11-
# fork of wasmparser with no_std support, see https://github.com/bytecodealliance/wasmtime/issues/3495
12-
wasmparser={version="0.202.0", package="tinywasm-wasmparser", default-features=false}
11+
wasmparser={version="0.206", default-features=false}
1312
log={version="0.4", optional=true}
1413
tinywasm-types={version="0.6.0", path="../types", default-features=false}
1514

1615
[features]
1716
default=["std", "logging"]
1817
logging=["log"]
19-
std=["tinywasm-types/std"]
18+
std=["tinywasm-types/std", "wasmparser/std"]

crates/parser/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use alloc::{string::ToString, vec::Vec};
3535
pub use error::*;
3636
use module::ModuleReader;
3737
use tinywasm_types::WasmFunction;
38-
use wasmparser::{Validator, WasmFeatures};
38+
use wasmparser::{Validator, WasmFeaturesInflated};
3939

4040
pub use tinywasm_types::TinyWasmModule;
4141

@@ -50,7 +50,7 @@ impl Parser {
5050
}
5151

5252
fn create_validator(&self) -> Validator {
53-
let features = WasmFeatures {
53+
let features = WasmFeaturesInflated {
5454
bulk_memory: true,
5555
floats: true,
5656
multi_value: true,
@@ -73,8 +73,10 @@ impl Parser {
7373
tail_call: false,
7474
threads: false,
7575
multi_memory: false, // should be working mostly
76+
custom_page_sizes: false,
77+
shared_everything_threads: false,
7678
};
77-
Validator::new_with_features(features)
79+
Validator::new_with_features(features.into())
7880
}
7981

8082
/// Parse a [`TinyWasmModule`] from bytes

crates/parser/src/visit.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,26 @@ impl FunctionBuilder {
117117
}
118118
}
119119

120+
macro_rules! impl_visit_operator {
121+
($(@$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => {
122+
$(impl_visit_operator!(@@$proposal $op $({ $($arg: $argty),* })? => $visit);)*
123+
};
124+
125+
(@@mvp $($rest:tt)* ) => {};
126+
(@@reference_types $($rest:tt)* ) => {};
127+
(@@sign_extension $($rest:tt)* ) => {};
128+
(@@saturating_float_to_int $($rest:tt)* ) => {};
129+
(@@bulk_memory $($rest:tt)* ) => {};
130+
(@@$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident) => {
131+
fn $visit(&mut self $($(,$arg: $argty)*)?) -> Result<()>{
132+
self.unsupported(stringify!($visit))
133+
}
134+
};
135+
}
136+
120137
impl<'a> wasmparser::VisitOperator<'a> for FunctionBuilder {
121138
type Output = Result<()>;
122-
123-
fn visit_default(&mut self, op: &str) -> Self::Output {
124-
self.unsupported(op)
125-
}
139+
wasmparser::for_each_operator!(impl_visit_operator);
126140

127141
define_primitive_operands! {
128142
visit_br, Instruction::Br, u32,

examples/rust/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exclude_wat=("tinywasm")
66
out_dir="./target/wasm32-unknown-unknown/wasm"
77
dest_dir="out"
88

9-
features="+reference-types,+bulk-memory,+mutable-globals"
9+
features="+reference-types,+bulk-memory,+mutable-globals,+multivalue"
1010

1111
# ensure out dir exists
1212
mkdir -p "$dest_dir"

0 commit comments

Comments
 (0)