Upgrade to latest wasmparser/wasmencoder.
This commit is contained in:
parent
4bdc602ef9
commit
efa07f16cf
|
@ -7,8 +7,8 @@ license = "Apache-2.0 WITH LLVM-exception"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
wasmparser = "0.202"
|
||||
wasm-encoder = "0.202"
|
||||
wasmparser = { path = "../wasm-tools/crates/wasmparser" }
|
||||
wasm-encoder = { path = "../wasm-tools/crates/wasm-encoder" }
|
||||
anyhow = "1.0"
|
||||
structopt = "0.3"
|
||||
log = "0.4"
|
||||
|
|
|
@ -8,6 +8,7 @@ use anyhow::Result;
|
|||
use rayon::prelude::*;
|
||||
use std::borrow::Cow;
|
||||
use wasm_encoder::CustomSection;
|
||||
use wasm_encoder::Encode;
|
||||
|
||||
pub mod stackify;
|
||||
use stackify::{Context as StackifyContext, WasmBlock};
|
||||
|
@ -1144,6 +1145,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
.map(|elts| elts.len() as u32)
|
||||
.unwrap_or(table.initial),
|
||||
maximum: table.max,
|
||||
table64: false,
|
||||
})
|
||||
}
|
||||
&ImportKind::Global(global) => {
|
||||
|
@ -1152,6 +1154,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
wasm_encoder::EntityType::Global(wasm_encoder::GlobalType {
|
||||
val_type: wasm_encoder::ValType::from(global.ty),
|
||||
mutable: global.mutable,
|
||||
shared: false,
|
||||
})
|
||||
}
|
||||
&ImportKind::Memory(mem) => {
|
||||
|
@ -1162,6 +1165,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
shared: mem.shared,
|
||||
minimum: mem.initial_pages as u64,
|
||||
maximum: mem.maximum_pages.map(|val| val as u64),
|
||||
page_size_log2: None,
|
||||
})
|
||||
}
|
||||
};
|
||||
|
@ -1194,6 +1198,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
.map(|elt| elt.len())
|
||||
.unwrap_or(0) as u32,
|
||||
maximum: table_data.max,
|
||||
table64: false,
|
||||
});
|
||||
}
|
||||
into_mod.section(&tables);
|
||||
|
@ -1205,6 +1210,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
maximum: mem_data.maximum_pages.map(|val| val as u64),
|
||||
memory64: mem_data.memory64,
|
||||
shared: mem_data.shared,
|
||||
page_size_log2: None,
|
||||
});
|
||||
}
|
||||
into_mod.section(&memories);
|
||||
|
@ -1215,6 +1221,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<wasm_encoder::Module> {
|
|||
wasm_encoder::GlobalType {
|
||||
val_type: wasm_encoder::ValType::from(global_data.ty),
|
||||
mutable: global_data.mutable,
|
||||
shared: false,
|
||||
},
|
||||
&const_init(global_data.ty, global_data.value),
|
||||
);
|
||||
|
|
|
@ -13,9 +13,7 @@ use anyhow::{bail, Result};
|
|||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use log::trace;
|
||||
use std::convert::TryFrom;
|
||||
use wasmparser::{
|
||||
BlockType, DataKind, ExternalKind, Name, NameSectionReader, Parser, Payload, TypeRef,
|
||||
};
|
||||
use wasmparser::{BlockType, DataKind, ExternalKind, KnownCustom, Name, Parser, Payload, TypeRef};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct FrontendOptions {
|
||||
|
@ -255,8 +253,8 @@ fn handle_payload<'a>(
|
|||
}
|
||||
}
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == "name" => {
|
||||
let name_reader = NameSectionReader::new(reader.data(), reader.data_offset());
|
||||
Payload::CustomSection(reader) => match reader.as_known() {
|
||||
KnownCustom::Name(name_reader) => {
|
||||
for subsection in name_reader {
|
||||
let subsection = subsection?;
|
||||
match subsection {
|
||||
|
@ -270,57 +268,53 @@ fn handle_payload<'a>(
|
|||
}
|
||||
}
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_info" => {
|
||||
KnownCustom::Unknown => {
|
||||
if reader.name() == ".debug_info" {
|
||||
dwarf.debug_info = gimli::DebugInfo::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_abbrev" => {
|
||||
dwarf.debug_abbrev = gimli::DebugAbbrev::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_addr" => {
|
||||
dwarf.debug_addr =
|
||||
gimli::DebugAddr::from(gimli::EndianSlice::new(reader.data(), gimli::LittleEndian));
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_aranges" => {
|
||||
dwarf.debug_aranges = gimli::DebugAranges::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_line" => {
|
||||
dwarf.debug_line = gimli::DebugLine::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_line_str" => {
|
||||
dwarf.debug_line_str = gimli::DebugLineStr::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_str" => {
|
||||
dwarf.debug_str = gimli::DebugStr::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_str_offsets" => {
|
||||
dwarf.debug_str_offsets = gimli::DebugStrOffsets::from(gimli::EndianSlice::new(
|
||||
} else if reader.name() == ".debug_abbrev" {
|
||||
dwarf.debug_abbrev =
|
||||
gimli::DebugAbbrev::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_addr" {
|
||||
dwarf.debug_addr = gimli::DebugAddr::from(gimli::EndianSlice::new(
|
||||
reader.data(),
|
||||
gimli::LittleEndian,
|
||||
));
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_types" => {
|
||||
} else if reader.name() == ".debug_aranges" {
|
||||
dwarf.debug_aranges =
|
||||
gimli::DebugAranges::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_line" {
|
||||
dwarf.debug_line = gimli::DebugLine::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_line_str" {
|
||||
dwarf.debug_line_str =
|
||||
gimli::DebugLineStr::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_str" {
|
||||
dwarf.debug_str = gimli::DebugStr::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_str_offsets" {
|
||||
dwarf.debug_str_offsets = gimli::DebugStrOffsets::from(
|
||||
gimli::EndianSlice::new(reader.data(), gimli::LittleEndian),
|
||||
);
|
||||
} else if reader.name() == ".debug_types" {
|
||||
dwarf.debug_types = gimli::DebugTypes::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_loc" => {
|
||||
extra_sections.debug_loc = gimli::DebugLoc::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_loclists" => {
|
||||
} else if reader.name() == ".debug_loc" {
|
||||
extra_sections.debug_loc =
|
||||
gimli::DebugLoc::new(reader.data(), gimli::LittleEndian);
|
||||
} else if reader.name() == ".debug_loclists" {
|
||||
extra_sections.debug_loclists =
|
||||
gimli::DebugLocLists::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_ranges" => {
|
||||
} else if reader.name() == ".debug_ranges" {
|
||||
extra_sections.debug_ranges =
|
||||
gimli::DebugRanges::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) if reader.name() == ".debug_rnglists" => {
|
||||
} else if reader.name() == ".debug_rnglists" {
|
||||
extra_sections.debug_rnglists =
|
||||
gimli::DebugRngLists::new(reader.data(), gimli::LittleEndian);
|
||||
}
|
||||
Payload::CustomSection(reader) => {
|
||||
}else{
|
||||
module
|
||||
.custom_sections
|
||||
.insert(reader.name().to_owned(), reader.data().to_owned());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Payload::Version { .. } => {}
|
||||
Payload::ElementSection(reader) => {
|
||||
for element in reader {
|
||||
|
|
|
@ -47,8 +47,8 @@ pub struct MemorySegment {
|
|||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct TableData {
|
||||
pub ty: Type,
|
||||
pub initial: u32,
|
||||
pub max: Option<u32>,
|
||||
pub initial: u64,
|
||||
pub max: Option<u64>,
|
||||
pub func_elements: Option<Vec<Func>>,
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ impl<'a> Module<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Module<'a> {
|
||||
pub(crate) fn frontend_add_table(&mut self, ty: Type, initial: u32, max: Option<u32>) -> Table {
|
||||
pub(crate) fn frontend_add_table(&mut self, ty: Type, initial: u64, max: Option<u64>) -> Table {
|
||||
let func_elements = Some(vec![]);
|
||||
self.tables.push(TableData {
|
||||
ty,
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
// Re-export wasmparser for easier use of the right version by our embedders.
|
||||
pub use wasmparser;
|
||||
// Likewise for wasm-encoder.
|
||||
pub use wasm_encoder;
|
||||
|
||||
mod backend;
|
||||
pub mod cfg;
|
||||
|
|
Loading…
Reference in a new issue