Update wasm-tools crates (#5945)
This notably updates `wasmparser` for updates to the relaxed-simd proposal and an implementation of the function-references proposal. Additionally there are some minor bug fixes being picked up for WIT and the component model.
This commit is contained in:
@@ -2648,10 +2648,8 @@ impl Compiler<'_, '_> {
|
||||
| (ValType::F64, ValType::F32)
|
||||
|
||||
// not used in the component model
|
||||
| (ValType::ExternRef, _)
|
||||
| (_, ValType::ExternRef)
|
||||
| (ValType::FuncRef, _)
|
||||
| (_, ValType::FuncRef)
|
||||
| (ValType::Ref(_), _)
|
||||
| (_, ValType::Ref(_))
|
||||
| (ValType::V128, _)
|
||||
| (_, ValType::V128) => {
|
||||
panic!("cannot get {dst_ty:?} from {src_ty:?} local");
|
||||
@@ -2705,10 +2703,8 @@ impl Compiler<'_, '_> {
|
||||
| (ValType::F32, ValType::F64)
|
||||
|
||||
// not used in the component model
|
||||
| (ValType::ExternRef, _)
|
||||
| (_, ValType::ExternRef)
|
||||
| (ValType::FuncRef, _)
|
||||
| (_, ValType::FuncRef)
|
||||
| (ValType::Ref(_), _)
|
||||
| (_, ValType::Ref(_))
|
||||
| (ValType::V128, _)
|
||||
| (_, ValType::V128) => {
|
||||
panic!("cannot get {dst_ty:?} from {src_ty:?} local");
|
||||
|
||||
@@ -301,7 +301,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
||||
self.result.module.table_plans.reserve_exact(cnt);
|
||||
|
||||
for entry in tables {
|
||||
let table = entry?.try_into()?;
|
||||
let table = entry?.ty.try_into()?;
|
||||
let plan = TablePlan::for_table(table, &self.tunables);
|
||||
self.result.module.table_plans.push(plan);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
|
||||
Operator::V128Const { value } => {
|
||||
GlobalInit::V128Const(u128::from_le_bytes(*value.bytes()))
|
||||
}
|
||||
Operator::RefNull { ty: _ } => GlobalInit::RefNullConst,
|
||||
Operator::RefNull { hty: _ } => GlobalInit::RefNullConst,
|
||||
Operator::RefFunc { function_index } => {
|
||||
let index = FuncIndex::from_u32(function_index);
|
||||
self.flag_func_escaped(index);
|
||||
|
||||
@@ -122,7 +122,7 @@ impl Stacks {
|
||||
types.function(vec![], vec![]);
|
||||
|
||||
let call_func_type = types.len();
|
||||
types.function(vec![wasm_encoder::ValType::FuncRef], vec![]);
|
||||
types.function(vec![wasm_encoder::ValType::FUNCREF], vec![]);
|
||||
|
||||
section(&mut module, types);
|
||||
|
||||
@@ -190,7 +190,7 @@ impl Stacks {
|
||||
|
||||
let mut elems = wasm_encoder::ElementSection::new();
|
||||
elems.declared(
|
||||
wasm_encoder::ValType::FuncRef,
|
||||
wasm_encoder::RefType::FUNCREF,
|
||||
wasm_encoder::Elements::Functions(
|
||||
&(0..num_imported_funcs + u32::try_from(self.funcs.len()).unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
|
||||
@@ -4,8 +4,8 @@ use arbitrary::{Arbitrary, Result, Unstructured};
|
||||
use std::ops::RangeInclusive;
|
||||
use wasm_encoder::{
|
||||
CodeSection, ConstExpr, EntityType, ExportKind, ExportSection, Function, FunctionSection,
|
||||
GlobalSection, ImportSection, Instruction, Module, TableSection, TableType, TypeSection,
|
||||
ValType,
|
||||
GlobalSection, ImportSection, Instruction, Module, RefType, TableSection, TableType,
|
||||
TypeSection, ValType,
|
||||
};
|
||||
|
||||
/// A description of a Wasm module that makes a series of `externref` table
|
||||
@@ -50,27 +50,27 @@ impl TableOps {
|
||||
// dynamically adjusts the stack pointer for each call that uses
|
||||
// return pointers rather than statically allocating space in the
|
||||
// stack frame.
|
||||
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
|
||||
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
|
||||
);
|
||||
|
||||
// 1: "run"
|
||||
let mut params: Vec<ValType> = Vec::with_capacity(self.num_params as usize);
|
||||
for _i in 0..self.num_params {
|
||||
params.push(ValType::ExternRef);
|
||||
params.push(ValType::EXTERNREF);
|
||||
}
|
||||
let results = vec![];
|
||||
types.function(params, results);
|
||||
|
||||
// 2: `take_refs`
|
||||
types.function(
|
||||
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
|
||||
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
|
||||
vec![],
|
||||
);
|
||||
|
||||
// 3: `make_refs`
|
||||
types.function(
|
||||
vec![],
|
||||
vec![ValType::ExternRef, ValType::ExternRef, ValType::ExternRef],
|
||||
vec![ValType::EXTERNREF, ValType::EXTERNREF, ValType::EXTERNREF],
|
||||
);
|
||||
|
||||
// Import the GC function.
|
||||
@@ -82,7 +82,7 @@ impl TableOps {
|
||||
// Define our table.
|
||||
let mut tables = TableSection::new();
|
||||
tables.table(TableType {
|
||||
element_type: ValType::ExternRef,
|
||||
element_type: RefType::EXTERNREF,
|
||||
minimum: self.table_size as u32,
|
||||
maximum: None,
|
||||
});
|
||||
@@ -92,10 +92,10 @@ impl TableOps {
|
||||
for _ in 0..self.num_globals {
|
||||
globals.global(
|
||||
wasm_encoder::GlobalType {
|
||||
val_type: wasm_encoder::ValType::ExternRef,
|
||||
val_type: wasm_encoder::ValType::EXTERNREF,
|
||||
mutable: true,
|
||||
},
|
||||
&ConstExpr::ref_null(wasm_encoder::ValType::ExternRef),
|
||||
&ConstExpr::ref_null(wasm_encoder::HeapType::Extern),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ impl TableOps {
|
||||
|
||||
// Give ourselves one scratch local that we can use in various `TableOp`
|
||||
// implementations.
|
||||
let mut func = Function::new(vec![(1, ValType::ExternRef)]);
|
||||
let mut func = Function::new(vec![(1, ValType::EXTERNREF)]);
|
||||
|
||||
func.instruction(&Instruction::Loop(wasm_encoder::BlockType::Empty));
|
||||
for op in &self.ops {
|
||||
@@ -261,7 +261,7 @@ impl TableOp {
|
||||
func.instruction(&Instruction::Drop);
|
||||
}
|
||||
Self::Null => {
|
||||
func.instruction(&Instruction::RefNull(wasm_encoder::ValType::ExternRef));
|
||||
func.instruction(&Instruction::RefNull(wasm_encoder::HeapType::Extern));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,36 @@ impl TryFrom<wasmparser::ValType> for WasmType {
|
||||
F32 => Ok(WasmType::F32),
|
||||
F64 => Ok(WasmType::F64),
|
||||
V128 => Ok(WasmType::V128),
|
||||
FuncRef => Ok(WasmType::FuncRef),
|
||||
ExternRef => Ok(WasmType::ExternRef),
|
||||
Ref(r) => r.try_into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<wasmparser::RefType> for WasmType {
|
||||
type Error = WasmError;
|
||||
fn try_from(ty: wasmparser::RefType) -> Result<Self, Self::Error> {
|
||||
match ty {
|
||||
wasmparser::RefType::FUNCREF => Ok(WasmType::FuncRef),
|
||||
wasmparser::RefType::EXTERNREF => Ok(WasmType::ExternRef),
|
||||
_ => Err(WasmError::Unsupported(
|
||||
"function references proposal".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<wasmparser::HeapType> for WasmType {
|
||||
type Error = WasmError;
|
||||
fn try_from(ty: wasmparser::HeapType) -> Result<Self, Self::Error> {
|
||||
match ty {
|
||||
wasmparser::HeapType::Func => Ok(WasmType::FuncRef),
|
||||
wasmparser::HeapType::Extern => Ok(WasmType::ExternRef),
|
||||
// NB: when the function-references proposal is implemented this
|
||||
// entire `impl` should probably go away to remove the need for not
|
||||
// only this `unsupported` but everything.
|
||||
_ => Err(WasmError::Unsupported(
|
||||
"function references proposal".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,8 +83,8 @@ impl From<WasmType> for wasmparser::ValType {
|
||||
WasmType::F32 => wasmparser::ValType::F32,
|
||||
WasmType::F64 => wasmparser::ValType::F64,
|
||||
WasmType::V128 => wasmparser::ValType::V128,
|
||||
WasmType::FuncRef => wasmparser::ValType::FuncRef,
|
||||
WasmType::ExternRef => wasmparser::ValType::ExternRef,
|
||||
WasmType::FuncRef => wasmparser::ValType::FUNCREF,
|
||||
WasmType::ExternRef => wasmparser::ValType::EXTERNREF,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,7 @@ impl Metadata {
|
||||
relaxed_simd,
|
||||
extended_const,
|
||||
memory_control,
|
||||
function_references,
|
||||
|
||||
// Always on; we don't currently have knobs for these.
|
||||
mutable_global: _,
|
||||
@@ -197,6 +198,7 @@ impl Metadata {
|
||||
|
||||
assert!(!memory_control);
|
||||
assert!(!tail_call);
|
||||
assert!(!function_references);
|
||||
|
||||
Metadata {
|
||||
target: engine.compiler().triple().to_string(),
|
||||
|
||||
Reference in New Issue
Block a user