Skip to content

Commit

Permalink
Update wasmparser to a version with the latest encoding of multi-me…
Browse files Browse the repository at this point in the history
…mory

This commit further updates the `wasmparser` dependency across some
versions with minor renamings and structuring of the API. This pulls in
enough support to get the `multi_memory` test passing.
  • Loading branch information
alexcrichton authored and JakeChampion committed Apr 14, 2023
1 parent d6c3dea commit f7ffac0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rayon = "1.5.0"
structopt = { version = "0.3.21", optional = true }
wasi-cap-std-sync = "3.0.0"
wasm-encoder = "0.10.0"
wasmparser = "0.84.0"
wasmparser = "0.87.0"
wasmtime = "3.0.0"
wasmtime-wasi = "3.0.0"

Expand Down
10 changes: 5 additions & 5 deletions src/info.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::convert::TryFrom;
use std::ops::Range;
use types_interner::{EntityType, TypeId, TypesInterner};
use wasm_encoder::SectionId;

pub mod types_interner;

use std::convert::TryFrom;
use types_interner::{EntityType, TypeId, TypesInterner};

/// A collection of info about modules within a module linking bundle.
pub(crate) struct ModuleContext<'a> {
arena: Vec<ModuleInfo<'a>>,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl Module {
self,
cx: &mut ModuleContext<'a>,
id: SectionId,
range: wasmparser::Range,
range: Range<usize>,
full_wasm: &'a [u8],
) {
cx.defined_mut(self)
Expand All @@ -146,7 +146,7 @@ impl Module {
}

/// Push a new type into this module's types space.
pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::TypeDef) {
pub fn push_type<'a>(self, cx: &mut ModuleContext<'a>, ty: wasmparser::Type) {
let types_space = match &cx.arena[self.id] {
ModuleInfo::Defined(d) => &d.types,
};
Expand Down
8 changes: 2 additions & 6 deletions src/info/types_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ impl TypesInterner {
///
/// If the type has already been inserted and assigned an id before, then
/// that entry and its id are reused.
pub fn insert_wasmparser(
&mut self,
ty: wasmparser::TypeDef,
_types_space: &[TypeId],
) -> TypeId {
pub fn insert_wasmparser(&mut self, ty: wasmparser::Type, _types_space: &[TypeId]) -> TypeId {
match ty {
wasmparser::TypeDef::Func(func_ty) => self.insert(Type::Func(func_ty)),
wasmparser::Type::Func(func_ty) => self.insert(Type::Func(func_ty)),
}
}

Expand Down
23 changes: 13 additions & 10 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result<ModuleContext<'a>
data.range(),
full_wasm,
),
CustomSection { range, .. } => {
stack
.top_mut()
.module
.add_raw_section(&mut cx, SectionId::Custom, range, full_wasm)
}
CustomSection(c) => stack.top_mut().module.add_raw_section(
&mut cx,
SectionId::Custom,
c.range(),
full_wasm,
),
CodeSectionStart {
range,
count: _,
Expand All @@ -106,13 +106,16 @@ pub(crate) fn parse<'a>(full_wasm: &'a [u8]) -> anyhow::Result<ModuleContext<'a>

ComponentTypeSection(_)
| ComponentImportSection(_)
| ComponentFunctionSection(_)
| ComponentExportSection(_)
| ComponentStartSection(_)
| ComponentAliasSection(_)
| CoreTypeSection(_)
| InstanceSection(_)
| ComponentInstanceSection(_)
| ComponentCanonicalSection(_)
| AliasSection(_)
| ModuleSection { .. }
| ComponentSection { .. }
| InstanceSection(_) => {
| ComponentSection { .. } => {
unreachable!()
}
}
Expand All @@ -134,7 +137,7 @@ fn type_section<'a>(
for _ in 0..count {
let ty = types.read()?;
match ty {
wasmparser::TypeDef::Func(_) => {
wasmparser::Type::Func(_) => {
module.push_type(cx, ty);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/translate.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Type translator functions from `wasmparser` to `wasm_encoder`.
pub(crate) fn val_type(ty: wasmparser::Type) -> wasm_encoder::ValType {
pub(crate) fn val_type(ty: wasmparser::ValType) -> wasm_encoder::ValType {
use wasm_encoder::ValType;
use wasmparser::Type::*;
use wasmparser::ValType::*;
match ty {
I32 => ValType::I32,
I64 => ValType::I64,
Expand Down

0 comments on commit f7ffac0

Please sign in to comment.