Skip to content

Commit af0f6de

Browse files
chore: update wasmparser
Signed-off-by: Henry <mail@henrygressmann.de>
1 parent f4db548 commit af0f6de

9 files changed

Lines changed: 36 additions & 39 deletions

File tree

‎Cargo.lock‎

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

‎Cargo.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default-members = [".", "crates/parser", "crates/tinywasm", "crates/types"]
1313
[workspace.package]
1414
version = "0.11.0-pre.0"
1515
edition = "2024"
16-
rust-version = "1.95"
16+
rust-version = "1.98"
1717
repository = "https://github.com/explodingcamera/tinywasm"
1818
license = "MIT OR Apache-2.0"
1919
keywords = ["interpreter", "no-std", "tinywasm", "wasm", "webassembly"]
@@ -31,9 +31,9 @@ pretty_env_logger = "0.5"
3131
serde = { version = "1.0", features = ["derive"] }
3232
serde_json = { version = "1.0" }
3333
wasm-testsuite = { version = "0.7" }
34-
wasmparser = { version = "0.256", default-features = false }
35-
wast = "256"
36-
wat = "1.256"
34+
wasmparser = { version = "0.257", default-features = false }
35+
wast = "257"
36+
wat = "1.257"
3737

3838
criterion = { version = "0.8", default-features = false, features = ["cargo_bench_support", "rayon"] }
3939

‎crates/parser/src/conversion.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub(crate) fn convert_module_code(
164164
for (local_index, local) in locals_reader.into_iter().enumerate() {
165165
let local = local?;
166166
if let Some(validator) = validator.as_mut() {
167-
validator.define_locals(locals_position + local_index, local.0, local.1)?;
167+
validator.define_locals(locals_position + local_index as u64, local.0, local.1)?;
168168
}
169169
extend_local_types(&mut local_types, local.0, local.1)?;
170170
}

‎crates/parser/src/error.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum ParseError {
2020
/// The error message
2121
message: String,
2222
/// The offset in the module where the error occurred
23-
offset: usize,
23+
offset: u64,
2424
},
2525
/// An invalid encoding was encountered
2626
InvalidEncoding(Encoding),

‎crates/parser/src/lib.rs‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl Parser {
249249
buffer.truncate(buffer.len() - buffer_offset);
250250
buffer_offset = 0;
251251
}
252-
let read_bytes = Self::read_more(&mut stream, &mut buffer, hint as usize)?;
252+
let read_bytes = Self::read_more(&mut stream, &mut buffer, hint)?;
253253
eof = read_bytes == 0;
254254
}
255255
wasmparser::Chunk::Parsed { consumed, payload } => {
@@ -258,17 +258,12 @@ impl Parser {
258258

259259
match payload {
260260
wasmparser::Payload::CodeSectionStart { count, range, size } => {
261-
let defer = reader.begin_code_section(
262-
count,
263-
range.clone(),
264-
size,
265-
validator.as_mut(),
266-
&self.options,
267-
)?;
261+
let defer =
262+
reader.begin_code_section(count, range, size, validator.as_mut(), &self.options)?;
268263

269264
#[cfg(parallel_parser)]
270265
if defer {
271-
deferred_code_section = Some((count, range.end - size as usize, size as usize));
266+
deferred_code_section = Some((count, size as usize));
272267
}
273268

274269
#[cfg(not(parallel_parser))]
@@ -284,21 +279,21 @@ impl Parser {
284279
buffer_offset += consumed;
285280

286281
#[cfg(parallel_parser)]
287-
if let Some((count, body_offset, section_size)) = deferred_code_section {
282+
if let Some((count, section_size)) = deferred_code_section {
288283
while buffer.len() - buffer_offset < section_size {
289284
let remaining = section_size - (buffer.len() - buffer_offset);
290285
let read_bytes = Self::read_more(&mut stream, &mut buffer, remaining)?;
291286
if read_bytes == 0 {
292287
return Err(ParseError::ParseError {
293288
message: "unexpected end-of-file".into(),
294-
offset: body_offset + buffer.len() - buffer_offset,
289+
offset: parser.offset() + (buffer.len() - buffer_offset) as u64,
295290
});
296291
}
297292
}
298293

299294
let section_end = buffer_offset + section_size;
300295
let section_bytes = alloc::sync::Arc::<[u8]>::from(buffer[buffer_offset..section_end].to_vec());
301-
reader.queue_owned_code_section(count, body_offset, section_bytes, validator.as_mut())?;
296+
reader.queue_owned_code_section(count, parser.offset(), section_bytes, validator.as_mut())?;
302297
parser.skip_section();
303298
buffer_offset = section_end;
304299
continue;

‎crates/parser/src/module.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<'a> ModuleReader<'a> {
330330
pub(crate) fn begin_code_section(
331331
&mut self,
332332
count: u32,
333-
range: Range<usize>,
333+
range: Range<u64>,
334334
size: u32,
335335
validator: Option<&mut Validator>,
336336
options: &ParserOptions,
@@ -434,7 +434,7 @@ impl<'a> ModuleReader<'a> {
434434
pub(crate) fn queue_owned_code_section(
435435
&mut self,
436436
count: u32,
437-
body_offset: usize,
437+
body_offset: u64,
438438
section_bytes: Arc<[u8]>,
439439
validator: Option<&mut Validator>,
440440
) -> Result<()> {
@@ -446,6 +446,8 @@ impl<'a> ModuleReader<'a> {
446446
for _ in 0..count {
447447
let body_reader = reader.read_reader()?;
448448
let body_range = body_reader.range();
449+
let body_start = (body_range.start - body_offset) as usize;
450+
let body_end = (body_range.end - body_offset) as usize;
449451
#[cfg(feature = "validate")]
450452
let func_to_validate = {
451453
let function = wasmparser::FunctionBody::new(body_reader);
@@ -456,7 +458,7 @@ impl<'a> ModuleReader<'a> {
456458
self.queue_function(
457459
crate::parallel::FunctionBodyInput::Owned(crate::parallel::OwnedFunctionBody {
458460
section_bytes: section_bytes.clone(),
459-
body_range: (body_range.start - body_offset)..(body_range.end - body_offset),
461+
body_range: body_start..body_end,
460462
body_offset: body_range.start,
461463
}),
462464
func_to_validate,

‎crates/parser/src/parallel.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) struct OwnedFunctionBody {
1717
// function jobs from that section.
1818
pub section_bytes: Arc<[u8]>,
1919
pub body_range: Range<usize>,
20-
pub body_offset: usize,
20+
pub body_offset: u64,
2121
}
2222

2323
pub(crate) struct PendingFunction<'a> {

‎crates/parser/src/visit.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<'a> FunctionBuilder<'a> {
221221
struct ValidateThenVisit<'a, 'm> {
222222
validator: &'a mut FuncValidator<ValidatorResources>,
223223
builder: &'a mut FunctionBuilder<'m>,
224-
position: usize,
224+
position: u64,
225225
}
226226

227227
impl ModuleMetadata {

‎crates/types/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl From<&ImportKind> for ExternalKind {
700700
#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))]
701701
pub struct Data {
702702
pub data: Box<[u8]>,
703-
pub range: Range<usize>,
703+
pub range: Range<u64>,
704704
pub kind: DataKind,
705705
}
706706

@@ -718,7 +718,7 @@ pub enum DataKind {
718718
pub struct Element {
719719
pub kind: ElementKind,
720720
pub items: Box<[ElementItem]>,
721-
pub range: Range<usize>,
721+
pub range: Range<u64>,
722722
pub ty: RefType,
723723
}
724724

0 commit comments

Comments
 (0)