Skip to content
Merged
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
35 changes: 18 additions & 17 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ test-programs = { path = "crates/test-programs" }
wasmtime-runtime = { path = "crates/runtime" }
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
tracing-subscriber = "0.3.1"
wast = "41.0.0"
wast = "42.0.0"
criterion = "0.3.4"
num_cpus = "1.13.0"
winapi = { version = "0.3.9", features = ['memoryapi'] }
memchr = "2.4"
async-trait = "0.1"
wat = "1.0.42"
wat = "1.0.43"
once_cell = "1.9.0"
rayon = "1.5.0"

Expand Down
2 changes: 1 addition & 1 deletion cranelift/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"]
edition = "2021"

[dependencies]
wasmparser = { version = "0.85.0", default-features = false }
wasmparser = { version = "0.86.0", default-features = false }
cranelift-codegen = { path = "../codegen", version = "0.86.0", default-features = false }
cranelift-entity = { path = "../entity", version = "0.86.0" }
cranelift-frontend = { path = "../frontend", version = "0.86.0", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions cranelift/wasm/src/func_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn parse_local_decls<FE: FuncEnvironment + ?Sized>(
builder.set_srcloc(cur_srcloc(reader));
let pos = reader.original_position();
let count = reader.read_var_u32()?;
let ty = reader.read_type()?;
let ty = reader.read_val_type()?;
validator.define_locals(pos, count, ty)?;
declare_locals(builder, count, ty, &mut next_local, environ)?;
}
Expand All @@ -187,12 +187,12 @@ fn parse_local_decls<FE: FuncEnvironment + ?Sized>(
fn declare_locals<FE: FuncEnvironment + ?Sized>(
builder: &mut FunctionBuilder,
count: u32,
wasm_type: wasmparser::Type,
wasm_type: wasmparser::ValType,
next_local: &mut usize,
environ: &mut FE,
) -> WasmResult<()> {
// All locals are initialized to 0.
use wasmparser::Type::*;
use wasmparser::ValType::*;
let zeroval = match wasm_type {
I32 => builder.ins().iconst(ir::types::I32, 0),
I64 => builder.ins().iconst(ir::types::I64, 0),
Expand Down
4 changes: 2 additions & 2 deletions cranelift/wasm/src/sections_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use wasmparser::{
ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader,
GlobalSectionReader, GlobalType, ImportSectionReader, MemorySectionReader, MemoryType,
NameSectionReader, Naming, Operator, TableSectionReader, TableType, TagSectionReader, TagType,
TypeDef, TypeRef, TypeSectionReader,
Type, TypeRef, TypeSectionReader,
};

fn memory(ty: MemoryType) -> Memory {
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn parse_type_section<'a>(

for entry in types {
match entry? {
TypeDef::Func(wasm_func_ty) => {
Type::Func(wasm_func_ty) => {
environ.declare_type_func(wasm_func_ty.clone().try_into()?)?;
module_translation_state
.wasm_types
Expand Down
18 changes: 9 additions & 9 deletions cranelift/wasm/src/state/module_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::vec::Vec;

/// Map of signatures to a function's parameter and return types.
pub(crate) type WasmTypes =
PrimaryMap<SignatureIndex, (Box<[wasmparser::Type]>, Box<[wasmparser::Type]>)>;
PrimaryMap<SignatureIndex, (Box<[wasmparser::ValType]>, Box<[wasmparser::ValType]>)>;

/// Contains information decoded from the Wasm module that must be referenced
/// during each Wasm function's translation.
Expand All @@ -23,13 +23,13 @@ pub struct ModuleTranslationState {
pub(crate) wasm_types: WasmTypes,
}

fn cranelift_to_wasmparser_type(ty: Type) -> WasmResult<wasmparser::Type> {
fn cranelift_to_wasmparser_type(ty: Type) -> WasmResult<wasmparser::ValType> {
Ok(match ty {
types::I32 => wasmparser::Type::I32,
types::I64 => wasmparser::Type::I64,
types::F32 => wasmparser::Type::F32,
types::F64 => wasmparser::Type::F64,
types::R32 | types::R64 => wasmparser::Type::ExternRef,
types::I32 => wasmparser::ValType::I32,
types::I64 => wasmparser::ValType::I64,
types::F32 => wasmparser::ValType::F32,
types::F64 => wasmparser::ValType::F64,
types::R32 | types::R64 => wasmparser::ValType::ExternRef,
_ => {
return Err(WasmError::Unsupported(format!(
"Cannot convert Cranelift type to Wasm signature: {:?}",
Expand All @@ -54,11 +54,11 @@ impl ModuleTranslationState {
pub fn from_func_sigs(sigs: &[(&[Type], &[Type])]) -> WasmResult<Self> {
let mut wasm_types = PrimaryMap::with_capacity(sigs.len());
for &(ref args, ref results) in sigs {
let args: Vec<wasmparser::Type> = args
let args: Vec<wasmparser::ValType> = args
.iter()
.map(|&ty| cranelift_to_wasmparser_type(ty))
.collect::<Result<_, _>>()?;
let results: Vec<wasmparser::Type> = results
let results: Vec<wasmparser::ValType> = results
.iter()
.map(|&ty| cranelift_to_wasmparser_type(ty))
.collect::<Result<_, _>>()?;
Expand Down
70 changes: 35 additions & 35 deletions cranelift/wasm/src/translation_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ pub enum TableElementType {

/// Helper function translating wasmparser types to Cranelift types when possible.
pub fn type_to_type<PE: TargetEnvironment + ?Sized>(
ty: wasmparser::Type,
ty: wasmparser::ValType,
environ: &PE,
) -> WasmResult<ir::Type> {
match ty {
wasmparser::Type::I32 => Ok(ir::types::I32),
wasmparser::Type::I64 => Ok(ir::types::I64),
wasmparser::Type::F32 => Ok(ir::types::F32),
wasmparser::Type::F64 => Ok(ir::types::F64),
wasmparser::Type::V128 => Ok(ir::types::I8X16),
wasmparser::Type::ExternRef | wasmparser::Type::FuncRef => {
wasmparser::ValType::I32 => Ok(ir::types::I32),
wasmparser::ValType::I64 => Ok(ir::types::I64),
wasmparser::ValType::F32 => Ok(ir::types::F32),
wasmparser::ValType::F64 => Ok(ir::types::F64),
wasmparser::ValType::V128 => Ok(ir::types::I8X16),
wasmparser::ValType::ExternRef | wasmparser::ValType::FuncRef => {
Ok(environ.reference_type(ty.try_into()?))
}
}
Expand All @@ -39,17 +39,17 @@ pub fn type_to_type<PE: TargetEnvironment + ?Sized>(
/// Helper function translating wasmparser possible table types to Cranelift types when possible,
/// or None for Func tables.
pub fn tabletype_to_type<PE: TargetEnvironment + ?Sized>(
ty: wasmparser::Type,
ty: wasmparser::ValType,
environ: &PE,
) -> WasmResult<Option<ir::Type>> {
match ty {
wasmparser::Type::I32 => Ok(Some(ir::types::I32)),
wasmparser::Type::I64 => Ok(Some(ir::types::I64)),
wasmparser::Type::F32 => Ok(Some(ir::types::F32)),
wasmparser::Type::F64 => Ok(Some(ir::types::F64)),
wasmparser::Type::V128 => Ok(Some(ir::types::I8X16)),
wasmparser::Type::ExternRef => Ok(Some(environ.reference_type(ty.try_into()?))),
wasmparser::Type::FuncRef => Ok(None),
wasmparser::ValType::I32 => Ok(Some(ir::types::I32)),
wasmparser::ValType::I64 => Ok(Some(ir::types::I64)),
wasmparser::ValType::F32 => Ok(Some(ir::types::F32)),
wasmparser::ValType::F64 => Ok(Some(ir::types::F64)),
wasmparser::ValType::V128 => Ok(Some(ir::types::I8X16)),
wasmparser::ValType::ExternRef => Ok(Some(environ.reference_type(ty.try_into()?))),
wasmparser::ValType::FuncRef => Ok(None),
}
}

Expand All @@ -58,31 +58,31 @@ pub fn blocktype_params_results<'a, T>(
validator: &'a FuncValidator<T>,
ty: wasmparser::BlockType,
) -> WasmResult<(
impl ExactSizeIterator<Item = wasmparser::Type> + Clone + 'a,
impl ExactSizeIterator<Item = wasmparser::Type> + Clone + 'a,
impl ExactSizeIterator<Item = wasmparser::ValType> + Clone + 'a,
impl ExactSizeIterator<Item = wasmparser::ValType> + Clone + 'a,
)>
where
T: WasmModuleResources,
{
return Ok(match ty {
wasmparser::BlockType::Empty => {
let params: &'static [wasmparser::Type] = &[];
let results: &'static [wasmparser::Type] = &[];
let params: &'static [wasmparser::ValType] = &[];
let results: &'static [wasmparser::ValType] = &[];
(
itertools::Either::Left(params.iter().copied()),
itertools::Either::Left(results.iter().copied()),
)
}
wasmparser::BlockType::Type(ty) => {
let params: &'static [wasmparser::Type] = &[];
let results: &'static [wasmparser::Type] = match ty {
wasmparser::Type::I32 => &[wasmparser::Type::I32],
wasmparser::Type::I64 => &[wasmparser::Type::I64],
wasmparser::Type::F32 => &[wasmparser::Type::F32],
wasmparser::Type::F64 => &[wasmparser::Type::F64],
wasmparser::Type::V128 => &[wasmparser::Type::V128],
wasmparser::Type::ExternRef => &[wasmparser::Type::ExternRef],
wasmparser::Type::FuncRef => &[wasmparser::Type::FuncRef],
let params: &'static [wasmparser::ValType] = &[];
let results: &'static [wasmparser::ValType] = match ty {
wasmparser::ValType::I32 => &[wasmparser::ValType::I32],
wasmparser::ValType::I64 => &[wasmparser::ValType::I64],
wasmparser::ValType::F32 => &[wasmparser::ValType::F32],
wasmparser::ValType::F64 => &[wasmparser::ValType::F64],
wasmparser::ValType::V128 => &[wasmparser::ValType::V128],
wasmparser::ValType::ExternRef => &[wasmparser::ValType::ExternRef],
wasmparser::ValType::FuncRef => &[wasmparser::ValType::FuncRef],
};
(
itertools::Either::Left(params.iter().copied()),
Expand All @@ -105,28 +105,28 @@ where
/// Create a `Block` with the given Wasm parameters.
pub fn block_with_params<PE: TargetEnvironment + ?Sized>(
builder: &mut FunctionBuilder,
params: impl IntoIterator<Item = wasmparser::Type>,
params: impl IntoIterator<Item = wasmparser::ValType>,
environ: &PE,
) -> WasmResult<ir::Block> {
let block = builder.create_block();
for ty in params {
match ty {
wasmparser::Type::I32 => {
wasmparser::ValType::I32 => {
builder.append_block_param(block, ir::types::I32);
}
wasmparser::Type::I64 => {
wasmparser::ValType::I64 => {
builder.append_block_param(block, ir::types::I64);
}
wasmparser::Type::F32 => {
wasmparser::ValType::F32 => {
builder.append_block_param(block, ir::types::F32);
}
wasmparser::Type::F64 => {
wasmparser::ValType::F64 => {
builder.append_block_param(block, ir::types::F64);
}
wasmparser::Type::ExternRef | wasmparser::Type::FuncRef => {
wasmparser::ValType::ExternRef | wasmparser::ValType::FuncRef => {
builder.append_block_param(block, environ.reference_type(ty.try_into()?));
}
wasmparser::Type::V128 => {
wasmparser::ValType::V128 => {
builder.append_block_param(block, ir::types::I8X16);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cranelift-codegen = { path = "../../cranelift/codegen", version = "0.86.0" }
cranelift-frontend = { path = "../../cranelift/frontend", version = "0.86.0" }
cranelift-entity = { path = "../../cranelift/entity", version = "0.86.0" }
cranelift-native = { path = "../../cranelift/native", version = "0.86.0" }
wasmparser = "0.85.0"
wasmparser = "0.86.0"
target-lexicon = "0.12"
gimli = { version = "0.26.0", default-features = false, features = ['read', 'std'] }
object = { version = "0.28.0", default-features = false, features = ['write'] }
Expand Down
2 changes: 1 addition & 1 deletion crates/cranelift/src/debug/transform/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use gimli::{self, LineEncoding};
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
use wasmparser::Type as WasmType;
use wasmparser::ValType as WasmType;
use wasmtime_environ::{
DebugInfoData, DefinedFuncIndex, EntityRef, FuncIndex, FunctionMetadata, WasmFileInfo,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/environ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
anyhow = "1.0"
cranelift-entity = { path = "../../cranelift/entity", version = "0.86.0" }
wasmtime-types = { path = "../types", version = "0.39.0" }
wasmparser = "0.85.0"
wasmparser = "0.86.0"
indexmap = { version = "1.0.2", features = ["serde-1"] }
thiserror = "1.0.4"
serde = { version = "1.0.94", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/environ/src/component/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub enum Export {
/// function.
LiftedFunction {
/// The component function type of the function being created.
ty: FuncTypeIndex,
ty: TypeFuncIndex,
/// Which core WebAssembly export is being lifted.
func: CoreExport<FuncIndex>,
/// Any options, if present, associated with this lifting.
Expand Down
Loading