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:
Alex Crichton
2023-03-06 17:47:34 -06:00
committed by GitHub
parent 58430b1dd7
commit 3c9fc3ec8c
19 changed files with 203 additions and 101 deletions

View File

@@ -1151,8 +1151,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::F32Le | Operator::F64Le => {
translate_fcmp(FloatCC::LessThanOrEqual, builder, state)
}
Operator::RefNull { ty } => {
state.push1(environ.translate_ref_null(builder.cursor(), (*ty).try_into()?)?)
Operator::RefNull { hty } => {
state.push1(environ.translate_ref_null(builder.cursor(), (*hty).try_into()?)?)
}
Operator::RefIsNull => {
let value = state.pop1();
@@ -2157,14 +2157,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
));
}
Operator::I8x16RelaxedSwizzle
| Operator::I32x4RelaxedTruncSatF32x4S
| Operator::I32x4RelaxedTruncSatF32x4U
| Operator::I32x4RelaxedTruncSatF64x2SZero
| Operator::I32x4RelaxedTruncSatF64x2UZero
| Operator::F32x4RelaxedFma
| Operator::F32x4RelaxedFnma
| Operator::F64x2RelaxedFma
| Operator::F64x2RelaxedFnma
| Operator::I32x4RelaxedTruncF32x4S
| Operator::I32x4RelaxedTruncF32x4U
| Operator::I32x4RelaxedTruncF64x2SZero
| Operator::I32x4RelaxedTruncF64x2UZero
| Operator::F32x4RelaxedMadd
| Operator::F32x4RelaxedNmadd
| Operator::F64x2RelaxedMadd
| Operator::F64x2RelaxedNmadd
| Operator::I8x16RelaxedLaneselect
| Operator::I16x8RelaxedLaneselect
| Operator::I32x4RelaxedLaneselect
@@ -2174,11 +2174,21 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::F64x2RelaxedMin
| Operator::F64x2RelaxedMax
| Operator::I16x8RelaxedQ15mulrS
| Operator::I16x8DotI8x16I7x16S
| Operator::I32x4DotI8x16I7x16AddS
| Operator::F32x4RelaxedDotBf16x8AddF32x4 => {
| Operator::I16x8RelaxedDotI8x16I7x16S
| Operator::I32x4RelaxedDotI8x16I7x16AddS => {
return Err(wasm_unsupported!("proposed relaxed-simd operator {:?}", op));
}
Operator::CallRef { .. }
| Operator::ReturnCallRef { .. }
| Operator::BrOnNull { .. }
| Operator::BrOnNonNull { .. }
| Operator::RefAsNonNull => {
return Err(wasm_unsupported!(
"proposed function-references operator {:?}",
op
));
}
};
Ok(())
}

View File

@@ -202,9 +202,13 @@ fn declare_locals<FE: FuncEnvironment + ?Sized>(
let constant_handle = builder.func.dfg.constants.insert([0; 16].to_vec().into());
builder.ins().vconst(ir::types::I8X16, constant_handle)
}
ExternRef | FuncRef => {
environ.translate_ref_null(builder.cursor(), wasm_type.try_into()?)?
}
Ref(wasmparser::RefType {
nullable: true,
heap_type,
}) => environ.translate_ref_null(builder.cursor(), heap_type.try_into()?)?,
Ref(wasmparser::RefType {
nullable: false, ..
}) => unreachable!(),
};
let ty = builder.func.dfg.value_type(zeroval);

View File

@@ -143,7 +143,7 @@ pub fn parse_table_section(
environ.reserve_tables(tables.count())?;
for entry in tables {
let ty = table(entry?)?;
let ty = table(entry?.ty)?;
environ.declare_table(ty)?;
}
@@ -198,7 +198,7 @@ pub fn parse_global_section(
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 } => {
GlobalInit::RefFunc(FuncIndex::from_u32(function_index))
}

View File

@@ -37,8 +37,9 @@ where
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],
wasmparser::ValType::EXTERNREF => &[wasmparser::ValType::EXTERNREF],
wasmparser::ValType::FUNCREF => &[wasmparser::ValType::FUNCREF],
wasmparser::ValType::Ref(_) => unimplemented!("function references proposal"),
};
(
itertools::Either::Left(params.iter().copied()),
@@ -79,7 +80,7 @@ pub fn block_with_params<PE: TargetEnvironment + ?Sized>(
wasmparser::ValType::F64 => {
builder.append_block_param(block, ir::types::F64);
}
wasmparser::ValType::ExternRef | wasmparser::ValType::FuncRef => {
wasmparser::ValType::Ref(ty) => {
builder.append_block_param(block, environ.reference_type(ty.try_into()?));
}
wasmparser::ValType::V128 => {