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

deps: update to wasmparser@0.100.0 #262

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
with:
repository: WebAssembly/wabt
ref: aa0515b3c808da880942db8658abeaa969534667
ref: f02fa321d5f8392fcb02f0a5d5ff72b901e29a78
path: wabt
- name: Build wabt
run: |
Expand Down Expand Up @@ -51,8 +51,8 @@ jobs:
- name: Install wabt
run: |
set -e
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.13/wabt-1.0.13-linux.tar.gz | tar xzf -
echo "`pwd`/wabt-1.0.13" > $GITHUB_PATH
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz | tar xzf -
echo "`pwd`/wabt-1.0.33" > $GITHUB_PATH
- name: Install binaryen
run: |
set -e
Expand All @@ -78,8 +78,8 @@ jobs:
- name: Install wabt
run: |
set -e
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.13/wabt-1.0.13-linux.tar.gz | tar xzf -
echo "`pwd`/wabt-1.0.13" > $GITHUB_PATH
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz | tar xzf -
echo "`pwd`/wabt-1.0.33" > $GITHUB_PATH
- name: Install binaryen
run: |
set -e
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ log = "0.4.8"
rayon = { version = "1.1.0", optional = true }
walrus-macro = { path = './crates/macro', version = '=0.19.0' }
wasm-encoder = "0.41.0"
wasmparser = "0.80.2"
wasmparser = "0.100.0"
gimli = "0.26.0"

[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/tests/spec-tests
Submodule spec-tests updated 232 files
28 changes: 17 additions & 11 deletions crates/tests/tests/spec-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,29 @@ fn run(wast: &Path) -> Result<(), anyhow::Error> {
.skip(1)
.next()
.map(|s| s.to_str().unwrap());

let mut config = walrus::ModuleConfig::new();
let extra_args: &[&str] = match proposal {
// stable features
None
| Some("multi-value")
Some("multi-value")
| Some("nontrapping-float-to-int-conversions")
| Some("sign-extension-ops")
| Some("mutable-global") => &[],
| Some("mutable-global")
| Some("simd") => {
config.only_stable_features(true);
&[]
}

None | Some("bulk-memory-operations") => &[],

Some("multi-memory") => &["--enable-multi-memory"],

Some("simd") => &["--enable-simd"],
Some("bulk-memory-operations") => &["--enable-bulk-memory"],
Some("reference-types") => &[],

Some("reference-types") => &["--enable-reference-types", "--enable-bulk-memory"],
Some("extended-const") => &["--enable-extended-const"],

Some("relaxed-simd") => return Ok(()),
Some("gc") => return Ok(()),

// TODO: should get threads working
Some("threads") => return Ok(()),
Expand Down Expand Up @@ -69,11 +80,6 @@ fn run(wast: &Path) -> Result<(), anyhow::Error> {
let test: Test = serde_json::from_str(&contents).context("failed to parse file")?;
let mut files = Vec::new();

let mut config = walrus::ModuleConfig::new();
if extra_args.len() == 0 {
config.only_stable_features(true);
}

for command in test.commands {
let filename = match command.get("filename") {
Some(name) => name.as_str().unwrap().to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/init_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum InitExpr {
}

impl InitExpr {
pub(crate) fn eval(init: &wasmparser::InitExpr, ids: &IndicesToIds) -> Result<InitExpr> {
pub(crate) fn eval(init: &wasmparser::ConstExpr, ids: &IndicesToIds) -> Result<InitExpr> {
use wasmparser::Operator::*;
let mut reader = init.get_operators_reader();
let val = match reader.read()? {
Expand Down
25 changes: 22 additions & 3 deletions src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ pub enum Instr {
},

/// The `atomic.fence` instruction
AtomicFence {},
AtomicFence,

/// `table.get`
TableGet {
Expand Down Expand Up @@ -717,6 +717,10 @@ pub enum BinaryOp {
I64x2ReplaceLane { idx: u8 },
F32x4ReplaceLane { idx: u8 },
F64x2ReplaceLane { idx: u8 },
I8x16RelaxedLaneselect,
I16x8RelaxedLaneselect,
I32x4RelaxedLaneselect,
I64x2RelaxedLaneselect,

I8x16Eq,
I8x16Ne,
Expand Down Expand Up @@ -817,6 +821,8 @@ pub enum BinaryOp {
F32x4Max,
F32x4PMin,
F32x4PMax,
F32x4RelaxedFma,
F32x4RelaxedFnma,
F64x2Add,
F64x2Sub,
F64x2Mul,
Expand All @@ -825,13 +831,18 @@ pub enum BinaryOp {
F64x2Max,
F64x2PMin,
F64x2PMax,
F64x2RelaxedFma,
F64x2RelaxedFnma,
F64x2MinRelaxed,
F64x2MaxRelaxed,

I8x16RelaxedSwizzle,
I8x16NarrowI16x8S,
I8x16NarrowI16x8U,
I16x8NarrowI32x4S,
I16x8NarrowI32x4U,
I8x16RoundingAverageU,
I16x8RoundingAverageU,
I8x16AvgrU,
I16x8AvgrU,

I8x16MinS,
I8x16MinU,
Expand Down Expand Up @@ -970,6 +981,10 @@ pub enum UnaryOp {
F32x4Floor,
F32x4Trunc,
F32x4Nearest,
F32x4FmaRelaxed,
F32x4FmsRelaxed,
F32x4MinRelaxed,
F32x4MaxRelaxed,
F64x2Abs,
F64x2Neg,
F64x2Sqrt,
Expand All @@ -982,6 +997,10 @@ pub enum UnaryOp {
I16x8ExtAddPairwiseI8x16U,
I32x4ExtAddPairwiseI16x8S,
I32x4ExtAddPairwiseI16x8U,
I32x4TruncSatF32x4SRelaxed,
I32x4TruncSatF32x4URelaxed,
I32x4TruncSatF64x2SZeroRelaxed,
I32x4TruncSatF64x2UZeroRelaxed,
I64x2ExtendLowI32x4S,
I64x2ExtendHighI32x4S,
I64x2ExtendLowI32x4U,
Expand Down
7 changes: 4 additions & 3 deletions src/module/data.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//! Data segments within a wasm module.

use crate::emit::{Emit, EmitContext};
use crate::init_expr::InitExpr;
use crate::ir::Value;
use crate::parse::IndicesToIds;
use crate::tombstone_arena::{Id, Tombstone, TombstoneArena};
use crate::{GlobalId, InitExpr, MemoryId, Module, Result, ValType};
use crate::{GlobalId, MemoryId, Module, Result, ValType};
use anyhow::{bail, Context};

/// A passive element segment identifier
Expand Down Expand Up @@ -222,15 +223,15 @@ impl Module {
}
wasmparser::DataKind::Active {
memory_index,
init_expr,
offset_expr,
} => {
data.value = segment.data.to_vec();

let memory_id = ids.get_memory(memory_index)?;
let memory = self.memories.get_mut(memory_id);
memory.data_segments.insert(data.id);

let offset = InitExpr::eval(&init_expr, ids)
let offset = InitExpr::eval(&offset_expr, ids)
.with_context(|| format!("in segment {}", i))?;
data.kind = DataKind::Active(ActiveData {
memory: memory_id,
Expand Down
16 changes: 8 additions & 8 deletions src/module/debug/expression.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{CodeTransform, Function, InstrLocId, ModuleFunctions};
use id_arena::Id;
use std::cmp::Ordering;
use std::{cmp::Ordering, ops::Range};

use super::dwarf::AddressSearchPreference;

Expand All @@ -22,7 +22,7 @@ pub(crate) enum CodeAddress {
/// Converts original code address to CodeAddress
pub(crate) struct CodeAddressGenerator {
/// Function range based convert table
address_convert_table: Vec<(wasmparser::Range, Id<Function>)>,
address_convert_table: Vec<(Range<usize>, Id<Function>)>,
/// Instrument based convert table
instrument_address_convert_table: Vec<(usize, InstrLocId)>,
}
Expand All @@ -31,7 +31,7 @@ impl CodeAddressGenerator {
pub(crate) fn new(funcs: &ModuleFunctions) -> Self {
let mut address_convert_table = funcs
.iter_local()
.filter_map(|(func_id, func)| func.original_range.map(|range| (range, func_id)))
.filter_map(|(func_id, func)| func.original_range.clone().map(|range| (range, func_id)))
.collect::<Vec<_>>();

let mut instrument_address_convert_table = funcs
Expand Down Expand Up @@ -75,7 +75,7 @@ impl CodeAddressGenerator {
};

// If the address is not mapped to any instruction, falling back to function-range-based comparison.
let inclusive_range_comparor = |range: &(wasmparser::Range, Id<Function>)| {
let inclusive_range_comparor = |range: &(Range<usize>, Id<Function>)| {
// range.start < address <= range.end
if range.0.end < address {
Ordering::Less
Expand All @@ -85,7 +85,7 @@ impl CodeAddressGenerator {
Ordering::Equal
}
};
let exclusive_range_comparor = |range: &(wasmparser::Range, Id<Function>)| {
let exclusive_range_comparor = |range: &(Range<usize>, Id<Function>)| {
// normal comparison: range.start <= address < range.end
if range.0.end <= address {
Ordering::Less
Expand Down Expand Up @@ -189,7 +189,7 @@ mod tests {
crate::FunctionBuilder::new(&mut module.types, &[], &[]),
);

func1.original_range = Some(wasmparser::Range { start: 20, end: 30 });
func1.original_range = Some(Range { start: 20, end: 30 });

let id1 = module.funcs.add_local(func1);

Expand All @@ -198,7 +198,7 @@ mod tests {
crate::FunctionBuilder::new(&mut module.types, &[], &[]),
);

func2.original_range = Some(wasmparser::Range { start: 30, end: 50 });
func2.original_range = Some(Range { start: 30, end: 50 });

let id2 = module.funcs.add_local(func2);

Expand Down Expand Up @@ -262,7 +262,7 @@ mod tests {
{
code_transform
.function_ranges
.push((id1, wasmparser::Range { start: 50, end: 80 }));
.push((id1, Range { start: 50, end: 80 }));
code_transform.instruction_map.push((instr_id1, 60));
code_transform.instruction_map.push((instr_id2, 65));
}
Expand Down
27 changes: 13 additions & 14 deletions src/module/elements.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Table elements within a wasm module.

use crate::emit::{Emit, EmitContext};
use crate::init_expr::InitExpr;
use crate::parse::IndicesToIds;
use crate::tombstone_arena::{Id, Tombstone, TombstoneArena};
use crate::{ir::Value, FunctionId, InitExpr, Module, Result, TableId, ValType};
use crate::{ir::Value, FunctionId, Module, Result, TableId, ValType};
use anyhow::{bail, Context};

/// A passive element segment identifier
Expand Down Expand Up @@ -116,30 +117,28 @@ impl Module {
ValType::Funcref => {}
_ => bail!("only funcref type allowed in element segments"),
}
let members = segment
.items
.get_items_reader()?
.into_iter()
.map(|e| -> Result<_> {
Ok(match e? {
wasmparser::ElementItem::Func(f) => Some(ids.get_func(f)?),
wasmparser::ElementItem::Null(_) => None,
})
})
.collect::<Result<_>>()?;
let members = match segment.items {
wasmparser::ElementItems::Functions(funcs) => funcs
.into_iter()
.map(|f| Ok(Some(ids.get_func(f?)?)))
.collect::<Result<_>>()?,
wasmparser::ElementItems::Expressions(exprs) => {
exprs.into_iter().map(|_| Ok(None)).collect::<Result<_>>()?
}
};
let id = self.elements.arena.next_id();

let kind = match segment.kind {
wasmparser::ElementKind::Passive => ElementKind::Passive,
wasmparser::ElementKind::Declared => ElementKind::Declared,
wasmparser::ElementKind::Active {
table_index,
init_expr,
offset_expr,
} => {
let table = ids.get_table(table_index)?;
self.tables.get_mut(table).elem_segments.insert(id);

let offset = InitExpr::eval(&init_expr, ids)
let offset = InitExpr::eval(&offset_expr, ids)
.with_context(|| format!("in segment {}", i))?;
match offset {
InitExpr::Value(Value::I32(_)) => {}
Expand Down
7 changes: 2 additions & 5 deletions src/module/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,17 @@ impl Module {
for entry in section {
let entry = entry?;
let item = match entry.kind {
Function => ExportItem::Function(ids.get_func(entry.index)?),
Func => ExportItem::Function(ids.get_func(entry.index)?),
Table => ExportItem::Table(ids.get_table(entry.index)?),
Memory => ExportItem::Memory(ids.get_memory(entry.index)?),
Global => ExportItem::Global(ids.get_global(entry.index)?),
Type | Module | Instance => {
unimplemented!("module linking not supported");
}
Tag => {
unimplemented!("exception handling not supported");
}
};
self.exports.arena.alloc_with_id(|id| Export {
id,
name: entry.field.to_string(),
name: entry.name.to_string(),
item,
});
}
Expand Down
Loading
Loading