Update some wasm-tools crates (#5422)
Notably this pulls in https://github.com/bytecodealliance/wasm-tools/pull/862 which should fix some fuzz bugs on oss-fuzz.
This commit is contained in:
16
Cargo.lock
generated
16
Cargo.lock
generated
@@ -3262,9 +3262,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-mutate"
|
name = "wasm-mutate"
|
||||||
version = "0.2.12"
|
version = "0.2.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3a3f74c801ac9b17a797d7d2ea441277bc1ded7ba521ca5146258d6510cc2f11"
|
checksum = "a0e9666b36c1e7e88bf1e0d114c8a4fe7d4e32d3aa38c1e8e9d71a972b99764a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"egg",
|
"egg",
|
||||||
"log",
|
"log",
|
||||||
@@ -3276,9 +3276,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-smith"
|
name = "wasm-smith"
|
||||||
version = "0.11.9"
|
version = "0.11.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca488f460a34d3af30f1d65f26f108612f2755872f2aba9906c36f1c046ef1cf"
|
checksum = "e6ca3f5a24b691771929ac6adf330972e8ecbfe48dcf8809d7bf83216c124cfd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"flagset",
|
"flagset",
|
||||||
@@ -3328,9 +3328,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmparser"
|
name = "wasmparser"
|
||||||
version = "0.95.0"
|
version = "0.96.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a"
|
checksum = "adde01ade41ab9a5d10ec8ed0bb954238cf8625b5cd5a13093d6de2ad9c2be1a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"url",
|
"url",
|
||||||
@@ -3347,9 +3347,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmprinter"
|
name = "wasmprinter"
|
||||||
version = "0.2.44"
|
version = "0.2.45"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae24500f9cc27a4b2b338e66693ff53c08b17cf920bdc81e402a09fe7a204eea"
|
checksum = "3045e1aa2cac847f4f94a1e25db9f084a947aeff47d9099fb9c5ccd16d335040"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"wasmparser",
|
"wasmparser",
|
||||||
|
|||||||
@@ -156,13 +156,13 @@ winch-codegen = { path = "winch/codegen", version = "=0.3.0" }
|
|||||||
|
|
||||||
target-lexicon = { version = "0.12.3", default-features = false, features = ["std"] }
|
target-lexicon = { version = "0.12.3", default-features = false, features = ["std"] }
|
||||||
anyhow = "1.0.22"
|
anyhow = "1.0.22"
|
||||||
wasmparser = "0.95.0"
|
wasmparser = "0.96.0"
|
||||||
wat = "1.0.52"
|
wat = "1.0.52"
|
||||||
wast = "50.0.0"
|
wast = "50.0.0"
|
||||||
wasmprinter = "0.2.44"
|
wasmprinter = "0.2.45"
|
||||||
wasm-encoder = "0.20.0"
|
wasm-encoder = "0.20.0"
|
||||||
wasm-smith = "0.11.9"
|
wasm-smith = "0.11.10"
|
||||||
wasm-mutate = "0.2.12"
|
wasm-mutate = "0.2.13"
|
||||||
wit-parser = "0.3"
|
wit-parser = "0.3"
|
||||||
windows-sys = "0.42.0"
|
windows-sys = "0.42.0"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ fn parse_local_decls<FE: FuncEnvironment + ?Sized>(
|
|||||||
builder.set_srcloc(cur_srcloc(reader));
|
builder.set_srcloc(cur_srcloc(reader));
|
||||||
let pos = reader.original_position();
|
let pos = reader.original_position();
|
||||||
let count = reader.read_var_u32()?;
|
let count = reader.read_var_u32()?;
|
||||||
let ty = reader.read_val_type()?;
|
let ty = reader.read()?;
|
||||||
validator.define_locals(pos, count, ty)?;
|
validator.define_locals(pos, count, ty)?;
|
||||||
declare_locals(builder, count, ty, &mut next_local, environ)?;
|
declare_locals(builder, count, ty, &mut next_local, environ)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,9 +108,8 @@ pub fn translate_module<'data>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Payload::CustomSection(s) if s.name() == "name" => {
|
Payload::CustomSection(s) if s.name() == "name" => {
|
||||||
let result = NameSectionReader::new(s.data(), s.data_offset())
|
let result =
|
||||||
.map_err(|e| e.into())
|
parse_name_section(NameSectionReader::new(s.data(), s.data_offset()), environ);
|
||||||
.and_then(|s| parse_name_section(s, environ));
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
log::warn!("failed to parse name section {:?}", e);
|
log::warn!("failed to parse name section {:?}", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ use crate::{
|
|||||||
DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, Table,
|
DataIndex, ElemIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, Table,
|
||||||
TableIndex, Tag, TagIndex, TypeIndex, WasmError, WasmResult,
|
TableIndex, Tag, TagIndex, TypeIndex, WasmError, WasmResult,
|
||||||
};
|
};
|
||||||
use core::convert::TryFrom;
|
|
||||||
use core::convert::TryInto;
|
|
||||||
use cranelift_entity::packed_option::ReservedValue;
|
use cranelift_entity::packed_option::ReservedValue;
|
||||||
use cranelift_entity::EntityRef;
|
use cranelift_entity::EntityRef;
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmparser::{
|
use wasmparser::{
|
||||||
self, Data, DataKind, DataSectionReader, Element, ElementItem, ElementItems, ElementKind,
|
self, Data, DataKind, DataSectionReader, Element, ElementItems, ElementKind,
|
||||||
ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader,
|
ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader,
|
||||||
GlobalSectionReader, GlobalType, ImportSectionReader, MemorySectionReader, MemoryType,
|
GlobalSectionReader, GlobalType, ImportSectionReader, MemorySectionReader, MemoryType,
|
||||||
NameSectionReader, Naming, Operator, TableSectionReader, TableType, TagSectionReader, TagType,
|
NameSectionReader, Naming, Operator, TableSectionReader, TableType, TagSectionReader, TagType,
|
||||||
@@ -65,7 +63,7 @@ pub fn parse_type_section<'a>(
|
|||||||
types: TypeSectionReader<'a>,
|
types: TypeSectionReader<'a>,
|
||||||
environ: &mut dyn ModuleEnvironment<'a>,
|
environ: &mut dyn ModuleEnvironment<'a>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
let count = types.get_count();
|
let count = types.count();
|
||||||
environ.reserve_types(count)?;
|
environ.reserve_types(count)?;
|
||||||
|
|
||||||
for entry in types {
|
for entry in types {
|
||||||
@@ -83,7 +81,7 @@ pub fn parse_import_section<'data>(
|
|||||||
imports: ImportSectionReader<'data>,
|
imports: ImportSectionReader<'data>,
|
||||||
environ: &mut dyn ModuleEnvironment<'data>,
|
environ: &mut dyn ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_imports(imports.get_count())?;
|
environ.reserve_imports(imports.count())?;
|
||||||
|
|
||||||
for entry in imports {
|
for entry in imports {
|
||||||
let import = entry?;
|
let import = entry?;
|
||||||
@@ -121,7 +119,7 @@ pub fn parse_function_section(
|
|||||||
functions: FunctionSectionReader,
|
functions: FunctionSectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
let num_functions = functions.get_count();
|
let num_functions = functions.count();
|
||||||
if num_functions == std::u32::MAX {
|
if num_functions == std::u32::MAX {
|
||||||
// We reserve `u32::MAX` for our own use in cranelift-entity.
|
// We reserve `u32::MAX` for our own use in cranelift-entity.
|
||||||
return Err(WasmError::ImplLimitExceeded);
|
return Err(WasmError::ImplLimitExceeded);
|
||||||
@@ -142,7 +140,7 @@ pub fn parse_table_section(
|
|||||||
tables: TableSectionReader,
|
tables: TableSectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_tables(tables.get_count())?;
|
environ.reserve_tables(tables.count())?;
|
||||||
|
|
||||||
for entry in tables {
|
for entry in tables {
|
||||||
let ty = table(entry?)?;
|
let ty = table(entry?)?;
|
||||||
@@ -157,7 +155,7 @@ pub fn parse_memory_section(
|
|||||||
memories: MemorySectionReader,
|
memories: MemorySectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_memories(memories.get_count())?;
|
environ.reserve_memories(memories.count())?;
|
||||||
|
|
||||||
for entry in memories {
|
for entry in memories {
|
||||||
let memory = memory(entry?);
|
let memory = memory(entry?);
|
||||||
@@ -172,7 +170,7 @@ pub fn parse_tag_section(
|
|||||||
tags: TagSectionReader,
|
tags: TagSectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_tags(tags.get_count())?;
|
environ.reserve_tags(tags.count())?;
|
||||||
|
|
||||||
for entry in tags {
|
for entry in tags {
|
||||||
let tag = tag(entry?);
|
let tag = tag(entry?);
|
||||||
@@ -187,7 +185,7 @@ pub fn parse_global_section(
|
|||||||
globals: GlobalSectionReader,
|
globals: GlobalSectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_globals(globals.get_count())?;
|
environ.reserve_globals(globals.count())?;
|
||||||
|
|
||||||
for entry in globals {
|
for entry in globals {
|
||||||
let wasmparser::Global { ty, init_expr } = entry?;
|
let wasmparser::Global { ty, init_expr } = entry?;
|
||||||
@@ -226,7 +224,7 @@ pub fn parse_export_section<'data>(
|
|||||||
exports: ExportSectionReader<'data>,
|
exports: ExportSectionReader<'data>,
|
||||||
environ: &mut dyn ModuleEnvironment<'data>,
|
environ: &mut dyn ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_exports(exports.get_count())?;
|
environ.reserve_exports(exports.count())?;
|
||||||
|
|
||||||
for entry in exports {
|
for entry in exports {
|
||||||
let Export {
|
let Export {
|
||||||
@@ -259,11 +257,16 @@ pub fn parse_start_section(index: u32, environ: &mut dyn ModuleEnvironment) -> W
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_elems(items: &ElementItems) -> WasmResult<Box<[FuncIndex]>> {
|
fn read_elems(items: &ElementItems) -> WasmResult<Box<[FuncIndex]>> {
|
||||||
let items_reader = items.get_items_reader()?;
|
let mut elems = Vec::new();
|
||||||
let mut elems = Vec::with_capacity(usize::try_from(items_reader.get_count()).unwrap());
|
match items {
|
||||||
for item in items_reader {
|
ElementItems::Functions(funcs) => {
|
||||||
let elem = match item? {
|
for func in funcs.clone() {
|
||||||
ElementItem::Expr(init) => match init.get_binary_reader().read_operator()? {
|
elems.push(FuncIndex::from_u32(func?));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ElementItems::Expressions(funcs) => {
|
||||||
|
for func in funcs.clone() {
|
||||||
|
let idx = match func?.get_binary_reader().read_operator()? {
|
||||||
Operator::RefNull { .. } => FuncIndex::reserved_value(),
|
Operator::RefNull { .. } => FuncIndex::reserved_value(),
|
||||||
Operator::RefFunc { function_index } => FuncIndex::from_u32(function_index),
|
Operator::RefFunc { function_index } => FuncIndex::from_u32(function_index),
|
||||||
s => {
|
s => {
|
||||||
@@ -272,10 +275,10 @@ fn read_elems(items: &ElementItems) -> WasmResult<Box<[FuncIndex]>> {
|
|||||||
s
|
s
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
ElementItem::Func(index) => FuncIndex::from_u32(index),
|
|
||||||
};
|
};
|
||||||
elems.push(elem);
|
elems.push(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(elems.into_boxed_slice())
|
Ok(elems.into_boxed_slice())
|
||||||
}
|
}
|
||||||
@@ -285,7 +288,7 @@ pub fn parse_element_section<'data>(
|
|||||||
elements: ElementSectionReader<'data>,
|
elements: ElementSectionReader<'data>,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_table_elements(elements.get_count())?;
|
environ.reserve_table_elements(elements.count())?;
|
||||||
|
|
||||||
for (index, entry) in elements.into_iter().enumerate() {
|
for (index, entry) in elements.into_iter().enumerate() {
|
||||||
let Element {
|
let Element {
|
||||||
@@ -337,7 +340,7 @@ pub fn parse_data_section<'data>(
|
|||||||
data: DataSectionReader<'data>,
|
data: DataSectionReader<'data>,
|
||||||
environ: &mut dyn ModuleEnvironment<'data>,
|
environ: &mut dyn ModuleEnvironment<'data>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_data_initializers(data.get_count())?;
|
environ.reserve_data_initializers(data.count())?;
|
||||||
|
|
||||||
for (index, entry) in data.into_iter().enumerate() {
|
for (index, entry) in data.into_iter().enumerate() {
|
||||||
let Data {
|
let Data {
|
||||||
|
|||||||
@@ -265,7 +265,12 @@ impl wasmtime_environ::Compiler for Compiler {
|
|||||||
context.func.stack_limit = Some(stack_limit);
|
context.func.stack_limit = Some(stack_limit);
|
||||||
let FunctionBodyData { validator, body } = input;
|
let FunctionBodyData { validator, body } = input;
|
||||||
let mut validator = validator.into_validator(validator_allocations);
|
let mut validator = validator.into_validator(validator_allocations);
|
||||||
func_translator.translate_body(&mut validator, body, &mut context.func, &mut func_env)?;
|
func_translator.translate_body(
|
||||||
|
&mut validator,
|
||||||
|
body.clone(),
|
||||||
|
&mut context.func,
|
||||||
|
&mut func_env,
|
||||||
|
)?;
|
||||||
|
|
||||||
let (_, code_buf) = compile_maybe_cached(&mut context, isa, cache_ctx.as_mut())?;
|
let (_, code_buf) = compile_maybe_cached(&mut context, isa, cache_ctx.as_mut())?;
|
||||||
// compile_maybe_cached returns the compiled_code but that borrow has the same lifetime as
|
// compile_maybe_cached returns the compiled_code but that borrow has the same lifetime as
|
||||||
|
|||||||
@@ -618,8 +618,8 @@ impl<'a, 'data> Translator<'a, 'data> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Payload::ComponentStartSection(s) => {
|
Payload::ComponentStartSection { start, range } => {
|
||||||
self.validator.component_start_section(&s)?;
|
self.validator.component_start_section(&start, &range)?;
|
||||||
unimplemented!("component start section");
|
unimplemented!("component start section");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use std::convert::{TryFrom, TryInto};
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wasmparser::{
|
use wasmparser::{
|
||||||
types::Types, CustomSectionReader, DataKind, ElementItem, ElementKind, Encoding, ExternalKind,
|
types::Types, CustomSectionReader, DataKind, ElementItems, ElementKind, Encoding, ExternalKind,
|
||||||
FuncToValidate, FunctionBody, NameSectionReader, Naming, Operator, Parser, Payload, Type,
|
FuncToValidate, FunctionBody, NameSectionReader, Naming, Operator, Parser, Payload, Type,
|
||||||
TypeRef, Validator, ValidatorResources,
|
TypeRef, Validator, ValidatorResources,
|
||||||
};
|
};
|
||||||
@@ -232,7 +232,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
|
|
||||||
Payload::TypeSection(types) => {
|
Payload::TypeSection(types) => {
|
||||||
self.validator.type_section(&types)?;
|
self.validator.type_section(&types)?;
|
||||||
let num = usize::try_from(types.get_count()).unwrap();
|
let num = usize::try_from(types.count()).unwrap();
|
||||||
self.result.module.types.reserve(num);
|
self.result.module.types.reserve(num);
|
||||||
self.types.reserve_wasm_signatures(num);
|
self.types.reserve_wasm_signatures(num);
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
Payload::ImportSection(imports) => {
|
Payload::ImportSection(imports) => {
|
||||||
self.validator.import_section(&imports)?;
|
self.validator.import_section(&imports)?;
|
||||||
|
|
||||||
let cnt = usize::try_from(imports.get_count()).unwrap();
|
let cnt = usize::try_from(imports.count()).unwrap();
|
||||||
self.result.module.initializers.reserve(cnt);
|
self.result.module.initializers.reserve(cnt);
|
||||||
|
|
||||||
for entry in imports {
|
for entry in imports {
|
||||||
@@ -284,7 +284,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
Payload::FunctionSection(functions) => {
|
Payload::FunctionSection(functions) => {
|
||||||
self.validator.function_section(&functions)?;
|
self.validator.function_section(&functions)?;
|
||||||
|
|
||||||
let cnt = usize::try_from(functions.get_count()).unwrap();
|
let cnt = usize::try_from(functions.count()).unwrap();
|
||||||
self.result.module.functions.reserve_exact(cnt);
|
self.result.module.functions.reserve_exact(cnt);
|
||||||
|
|
||||||
for entry in functions {
|
for entry in functions {
|
||||||
@@ -297,7 +297,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
|
|
||||||
Payload::TableSection(tables) => {
|
Payload::TableSection(tables) => {
|
||||||
self.validator.table_section(&tables)?;
|
self.validator.table_section(&tables)?;
|
||||||
let cnt = usize::try_from(tables.get_count()).unwrap();
|
let cnt = usize::try_from(tables.count()).unwrap();
|
||||||
self.result.module.table_plans.reserve_exact(cnt);
|
self.result.module.table_plans.reserve_exact(cnt);
|
||||||
|
|
||||||
for entry in tables {
|
for entry in tables {
|
||||||
@@ -310,7 +310,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
Payload::MemorySection(memories) => {
|
Payload::MemorySection(memories) => {
|
||||||
self.validator.memory_section(&memories)?;
|
self.validator.memory_section(&memories)?;
|
||||||
|
|
||||||
let cnt = usize::try_from(memories.get_count()).unwrap();
|
let cnt = usize::try_from(memories.count()).unwrap();
|
||||||
self.result.module.memory_plans.reserve_exact(cnt);
|
self.result.module.memory_plans.reserve_exact(cnt);
|
||||||
|
|
||||||
for entry in memories {
|
for entry in memories {
|
||||||
@@ -331,7 +331,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
Payload::GlobalSection(globals) => {
|
Payload::GlobalSection(globals) => {
|
||||||
self.validator.global_section(&globals)?;
|
self.validator.global_section(&globals)?;
|
||||||
|
|
||||||
let cnt = usize::try_from(globals.get_count()).unwrap();
|
let cnt = usize::try_from(globals.count()).unwrap();
|
||||||
self.result.module.globals.reserve_exact(cnt);
|
self.result.module.globals.reserve_exact(cnt);
|
||||||
|
|
||||||
for entry in globals {
|
for entry in globals {
|
||||||
@@ -369,7 +369,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
Payload::ExportSection(exports) => {
|
Payload::ExportSection(exports) => {
|
||||||
self.validator.export_section(&exports)?;
|
self.validator.export_section(&exports)?;
|
||||||
|
|
||||||
let cnt = usize::try_from(exports.get_count()).unwrap();
|
let cnt = usize::try_from(exports.count()).unwrap();
|
||||||
self.result.module.exports.reserve(cnt);
|
self.result.module.exports.reserve(cnt);
|
||||||
|
|
||||||
for entry in exports {
|
for entry in exports {
|
||||||
@@ -419,33 +419,36 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
// possible to create anything other than a `ref.null
|
// possible to create anything other than a `ref.null
|
||||||
// extern` for externref segments, so those just get
|
// extern` for externref segments, so those just get
|
||||||
// translated to the reserved value of `FuncIndex`.
|
// translated to the reserved value of `FuncIndex`.
|
||||||
let items_reader = items.get_items_reader()?;
|
let mut elements = Vec::new();
|
||||||
let mut elements =
|
match items {
|
||||||
Vec::with_capacity(usize::try_from(items_reader.get_count()).unwrap());
|
ElementItems::Functions(funcs) => {
|
||||||
for item in items_reader {
|
elements.reserve(usize::try_from(funcs.count()).unwrap());
|
||||||
let func = match item? {
|
for func in funcs {
|
||||||
ElementItem::Func(f) => Some(f),
|
let func = FuncIndex::from_u32(func?);
|
||||||
ElementItem::Expr(init) => {
|
self.flag_func_escaped(func);
|
||||||
match init.get_binary_reader().read_operator()? {
|
elements.push(func);
|
||||||
Operator::RefNull { .. } => None,
|
}
|
||||||
Operator::RefFunc { function_index } => Some(function_index),
|
}
|
||||||
|
ElementItems::Expressions(funcs) => {
|
||||||
|
elements.reserve(usize::try_from(funcs.count()).unwrap());
|
||||||
|
for func in funcs {
|
||||||
|
let func = match func?.get_binary_reader().read_operator()? {
|
||||||
|
Operator::RefNull { .. } => FuncIndex::reserved_value(),
|
||||||
|
Operator::RefFunc { function_index } => {
|
||||||
|
let func = FuncIndex::from_u32(function_index);
|
||||||
|
self.flag_func_escaped(func);
|
||||||
|
func
|
||||||
|
}
|
||||||
s => {
|
s => {
|
||||||
return Err(WasmError::Unsupported(format!(
|
return Err(WasmError::Unsupported(format!(
|
||||||
"unsupported init expr in element section: {:?}",
|
"unsupported init expr in element section: {:?}",
|
||||||
s
|
s
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
elements.push(match func {
|
elements.push(func);
|
||||||
Some(f) => {
|
}
|
||||||
let f = FuncIndex::from_u32(f);
|
|
||||||
self.flag_func_escaped(f);
|
|
||||||
f
|
|
||||||
}
|
}
|
||||||
None => FuncIndex::reserved_value(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
@@ -540,7 +543,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let cnt = usize::try_from(data.get_count()).unwrap();
|
let cnt = usize::try_from(data.count()).unwrap();
|
||||||
initializers.reserve_exact(cnt);
|
initializers.reserve_exact(cnt);
|
||||||
self.result.data.reserve_exact(cnt);
|
self.result.data.reserve_exact(cnt);
|
||||||
|
|
||||||
@@ -620,9 +623,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Payload::CustomSection(s) if s.name() == "name" => {
|
Payload::CustomSection(s) if s.name() == "name" => {
|
||||||
let result = NameSectionReader::new(s.data(), s.data_offset())
|
let result = self.name_section(NameSectionReader::new(s.data(), s.data_offset()));
|
||||||
.map_err(|e| e.into())
|
|
||||||
.and_then(|s| self.name_section(s));
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
log::warn!("failed to parse name section {:?}", e);
|
log::warn!("failed to parse name section {:?}", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ struct WasmFeatures {
|
|||||||
simd: bool,
|
simd: bool,
|
||||||
threads: bool,
|
threads: bool,
|
||||||
tail_call: bool,
|
tail_call: bool,
|
||||||
deterministic_only: bool,
|
|
||||||
multi_memory: bool,
|
multi_memory: bool,
|
||||||
exceptions: bool,
|
exceptions: bool,
|
||||||
memory64: bool,
|
memory64: bool,
|
||||||
@@ -183,7 +182,6 @@ impl Metadata {
|
|||||||
simd,
|
simd,
|
||||||
threads,
|
threads,
|
||||||
tail_call,
|
tail_call,
|
||||||
deterministic_only,
|
|
||||||
multi_memory,
|
multi_memory,
|
||||||
exceptions,
|
exceptions,
|
||||||
memory64,
|
memory64,
|
||||||
@@ -194,6 +192,7 @@ impl Metadata {
|
|||||||
mutable_global: _,
|
mutable_global: _,
|
||||||
saturating_float_to_int: _,
|
saturating_float_to_int: _,
|
||||||
sign_extension: _,
|
sign_extension: _,
|
||||||
|
floats: _,
|
||||||
} = engine.config().features;
|
} = engine.config().features;
|
||||||
|
|
||||||
Metadata {
|
Metadata {
|
||||||
@@ -209,7 +208,6 @@ impl Metadata {
|
|||||||
simd,
|
simd,
|
||||||
threads,
|
threads,
|
||||||
tail_call,
|
tail_call,
|
||||||
deterministic_only,
|
|
||||||
multi_memory,
|
multi_memory,
|
||||||
exceptions,
|
exceptions,
|
||||||
memory64,
|
memory64,
|
||||||
@@ -375,7 +373,6 @@ impl Metadata {
|
|||||||
simd,
|
simd,
|
||||||
threads,
|
threads,
|
||||||
tail_call,
|
tail_call,
|
||||||
deterministic_only,
|
|
||||||
multi_memory,
|
multi_memory,
|
||||||
exceptions,
|
exceptions,
|
||||||
memory64,
|
memory64,
|
||||||
@@ -406,11 +403,6 @@ impl Metadata {
|
|||||||
Self::check_bool(simd, other.simd, "WebAssembly SIMD support")?;
|
Self::check_bool(simd, other.simd, "WebAssembly SIMD support")?;
|
||||||
Self::check_bool(threads, other.threads, "WebAssembly threads support")?;
|
Self::check_bool(threads, other.threads, "WebAssembly threads support")?;
|
||||||
Self::check_bool(tail_call, other.tail_call, "WebAssembly tail-call support")?;
|
Self::check_bool(tail_call, other.tail_call, "WebAssembly tail-call support")?;
|
||||||
Self::check_bool(
|
|
||||||
deterministic_only,
|
|
||||||
other.deterministic_only,
|
|
||||||
"WebAssembly deterministic-only support",
|
|
||||||
)?;
|
|
||||||
Self::check_bool(
|
Self::check_bool(
|
||||||
multi_memory,
|
multi_memory,
|
||||||
other.multi_memory,
|
other.multi_memory,
|
||||||
|
|||||||
@@ -639,6 +639,12 @@ criteria = "safe-to-run"
|
|||||||
version = "0.2.12"
|
version = "0.2.12"
|
||||||
notes = "The Bytecode Alliance is the author of this crate."
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
[[audits.wasm-mutate]]
|
||||||
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
|
criteria = "safe-to-run"
|
||||||
|
version = "0.2.13"
|
||||||
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
[[audits.wasm-smith]]
|
[[audits.wasm-smith]]
|
||||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
@@ -687,6 +693,12 @@ criteria = "safe-to-run"
|
|||||||
version = "0.11.9"
|
version = "0.11.9"
|
||||||
notes = "The Bytecode Alliance is the author of this crate."
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
[[audits.wasm-smith]]
|
||||||
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
|
criteria = "safe-to-run"
|
||||||
|
version = "0.11.10"
|
||||||
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
[[audits.wasmi]]
|
[[audits.wasmi]]
|
||||||
who = "Robin Freyler <robin.freyler@gmail.com>"
|
who = "Robin Freyler <robin.freyler@gmail.com>"
|
||||||
criteria = "safe-to-run"
|
criteria = "safe-to-run"
|
||||||
@@ -783,6 +795,12 @@ criteria = "safe-to-deploy"
|
|||||||
version = "0.95.0"
|
version = "0.95.0"
|
||||||
notes = "The Bytecode Alliance is the author of this crate."
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
[[audits.wasmparser]]
|
||||||
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
|
criteria = "safe-to-deploy"
|
||||||
|
version = "0.96.0"
|
||||||
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
[[audits.wasmparser-nostd]]
|
[[audits.wasmparser-nostd]]
|
||||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
criteria = "safe-to-run"
|
criteria = "safe-to-run"
|
||||||
@@ -842,6 +860,12 @@ criteria = "safe-to-deploy"
|
|||||||
version = "0.2.44"
|
version = "0.2.44"
|
||||||
notes = "The Bytecode Alliance is the author of this crate."
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
|
[[audits.wasmprinter]]
|
||||||
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
|
criteria = "safe-to-deploy"
|
||||||
|
version = "0.2.45"
|
||||||
|
notes = "The Bytecode Alliance is the author of this crate."
|
||||||
|
|
||||||
[[audits.wast]]
|
[[audits.wast]]
|
||||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ impl Frame {
|
|||||||
for _ in 0..local_count {
|
for _ in 0..local_count {
|
||||||
let position = reader.original_position();
|
let position = reader.original_position();
|
||||||
let count = reader.read_var_u32()?;
|
let count = reader.read_var_u32()?;
|
||||||
let ty = reader.read_val_type()?;
|
let ty = reader.read()?;
|
||||||
validator.define_locals(position, count, ty)?;
|
validator.define_locals(position, count, ty)?;
|
||||||
|
|
||||||
let ty: ValType = ty.try_into()?;
|
let ty: ValType = ty.try_into()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user