Skip to content

Update to wasm-tools v229 #1501

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cf75f95
bump wasm-tools dependencies to v229
Robbepop May 5, 2025
8e43ed1
fix some compile errors after the update
Robbepop May 5, 2025
5f2eae4
restructure buffered Module parsing
Robbepop May 5, 2025
5754704
merge parse_buffered_impl and parse_buffered_header
Robbepop May 5, 2025
795a7cd
move utility methods to the bottom of the file
Robbepop May 5, 2025
2366264
simplify buffered parsing code
Robbepop May 5, 2025
929143e
remove consume_buffer utility method
Robbepop May 5, 2025
85d150d
set wasmparser::Parser WasmFeatures properly
Robbepop May 5, 2025
fc5e51d
refactor next_payload code
Robbepop May 5, 2025
9166388
refactor and clean-up buffered module parsing
Robbepop May 5, 2025
63f0b4d
move ModuleParser::finish to parser.rs
Robbepop May 6, 2025
ecd7ec2
apply rustfmt
Robbepop May 6, 2025
f49fc18
update Module::new_streaming impl to work with the new wasmparser
Robbepop May 6, 2025
c6a316e
remove Deref[Mut] impls from ParseBuffer
Robbepop May 6, 2025
34c9aa6
apply rustfmt
Robbepop May 6, 2025
e75dc59
use self method calling style for ParseBuffer
Robbepop May 6, 2025
a32b000
move eof into ParseBuffer
Robbepop May 6, 2025
72d451a
remove bool return value of pull_bytes
Robbepop May 6, 2025
dcf597a
add doc to eof method
Robbepop May 6, 2025
901534a
remove unnecessary comments
Robbepop May 6, 2025
f604cc5
Merge branch 'main' into rf-update-to-wasm-tools-v229
Robbepop May 6, 2025
0d86ab8
Merge branch 'main' into rf-update-to-wasm-tools-v229
Robbepop May 9, 2025
7cbfd1e
fix Cargo.lock
Robbepop May 9, 2025
d5c2418
apply cargo update
Robbepop May 9, 2025
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
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ wasmi_fuzz = { version = "0.46.0", path = "crates/fuzz" }
wasmi_wast = { version = "0.46.0", path = "crates/wast" }

# wasm-tools dependencies
wat = { version = "1.228.0", default-features = false }
wast = { version = "228.0.0", default-features = false }
wasmparser = { version = "0.228.0", default-features = false }
wasm-smith = "0.228.0"
wasmprinter = { version = "0.228.0", default-features = false }
wat = { version = "1.229.0", default-features = false }
wast = { version = "229.0.0", default-features = false }
wasmparser = { version = "0.229.0", default-features = false }
wasm-smith = "0.229.0"
wasmprinter = { version = "0.229.0", default-features = false }

# Wasmtime dependencies
wasi-common = { version = "31.0.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmi/src/engine/translator/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
self.translator.update_pos(pos);
reader.visit_operator(&mut self.translator)??;
}
reader.ensure_end()?;
reader.finish()?;
Ok(reader.original_position())
}
}
7 changes: 1 addition & 6 deletions crates/wasmi/src/engine/translator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,7 @@ where
self.pos = pos;
}

fn finish(
mut self,
finalize: impl FnOnce(CompiledFuncEntity),
) -> Result<Self::Allocations, Error> {
let pos = self.current_pos();
self.validator.finish(pos)?;
fn finish(self, finalize: impl FnOnce(CompiledFuncEntity)) -> Result<Self::Allocations, Error> {
let translation = self.translator.finish(finalize)?;
let validation = self.validator.into_allocations();
let allocations = ReusableAllocations {
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmi/src/module/init_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl ConstExpr {
};
}
reader
.ensure_end()
.finish()
.expect("due to Wasm validation this is guaranteed to succeed");
let op = stack
.pop()
Expand Down
16 changes: 9 additions & 7 deletions crates/wasmi/src/module/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
Error,
FuncType,
MemoryType,
Module,
TableType,
};
use alloc::boxed::Box;
Expand All @@ -38,9 +39,6 @@ use wasmparser::{
Validator,
};

#[cfg(doc)]
use crate::Module;

mod buffered;
mod streaming;

Expand All @@ -54,8 +52,6 @@ pub struct ModuleParser {
parser: WasmParser,
/// The number of compiled or processed functions.
engine_funcs: u32,
/// Flag, `true` when `stream` is at the end.
eof: bool,
}

impl ModuleParser {
Expand All @@ -68,10 +64,16 @@ impl ModuleParser {
validator: None,
parser,
engine_funcs: 0,
eof: false,
}
}

/// Finish Wasm module parsing and returns the resulting [`Module`].
fn finish(&mut self, offset: usize, builder: ModuleBuilder) -> Result<Module, Error> {
self.process_end(offset)?;
let module = builder.finish(&self.engine);
Ok(module)
}

/// Processes the end of the Wasm binary.
fn process_end(&mut self, offset: usize) -> Result<(), Error> {
if let Some(validator) = &mut self.validator {
Expand Down Expand Up @@ -455,7 +457,7 @@ impl ModuleParser {
}
}
if let Some(validator) = &mut self.validator {
validator.code_section_start(count, &range)?;
validator.code_section_start(&range)?;
}
Ok(())
}
Expand Down
Loading