bump wasmparser to 0.44.0 + fix error due to change wasmparser operator names

This commit is contained in:
Patrick Ventuzelo
2019-12-10 11:57:21 +01:00
parent 63b69a8e6c
commit 0e2f7600b2
3 changed files with 69 additions and 77 deletions

View File

@@ -14,7 +14,7 @@ edition = "2018"
smallvec = "1.0.0" smallvec = "1.0.0"
dynasm = "0.5.1" dynasm = "0.5.1"
dynasmrt = "0.5.1" dynasmrt = "0.5.1"
wasmparser = "0.39.1" wasmparser = "0.44.0"
memoffset = "0.5.1" memoffset = "0.5.1"
itertools = "0.8" itertools = "0.8"
capstone = "0.6.0" capstone = "0.6.0"

View File

@@ -821,8 +821,8 @@ where
Operator::Store { ty: I64, memarg } | Operator::Store { ty: F64, memarg } => { Operator::Store { ty: I64, memarg } | Operator::Store { ty: F64, memarg } => {
ctx.store64(memarg.offset)? ctx.store64(memarg.offset)?
} }
Operator::GetGlobal(idx) => ctx.get_global(idx)?, Operator::GlobalGet(idx) => ctx.get_global(idx)?,
Operator::SetGlobal(idx) => ctx.set_global(idx)?, Operator::GlobalSet(idx) => ctx.set_global(idx)?,
Operator::Select => { Operator::Select => {
ctx.select()?; ctx.select()?;
} }

View File

@@ -511,15 +511,15 @@ pub enum Operator<Label> {
/// the stack, otherwise discard `A` and push `B` back onto the stack. /// the stack, otherwise discard `A` and push `B` back onto the stack.
Select, Select,
/// Duplicate the element at depth `depth` to the top of the stack. This can be used to implement /// Duplicate the element at depth `depth` to the top of the stack. This can be used to implement
/// `GetLocal`. /// `LocalGet`.
Pick(u32), Pick(u32),
/// Swap the top element of the stack with the element at depth `depth`. This can be used to implement /// Swap the top element of the stack with the element at depth `depth`. This can be used to implement
/// `SetLocal`. /// `LocalSet`.
// TODO: Is it better to have `Swap`, to have `Pull` (which moves the `nth` element instead of swapping) // TODO: Is it better to have `Swap`, to have `Pull` (which moves the `nth` element instead of swapping)
// or to have both? // or to have both?
Swap(u32), Swap(u32),
GetGlobal(u32), GlobalGet(u32),
SetGlobal(u32), GlobalSet(u32),
Load { Load {
ty: SignlessType, ty: SignlessType,
memarg: MemoryImmediate, memarg: MemoryImmediate,
@@ -821,8 +821,8 @@ where
Type::Float::<Int>(*output_ty), Type::Float::<Int>(*output_ty),
input_ty, input_ty,
), ),
Operator::GetGlobal(index) => write!(f, "global.get {}", index), Operator::GlobalGet(index) => write!(f, "global.get {}", index),
Operator::SetGlobal(index) => write!(f, "global.set {}", index), Operator::GlobalSet(index) => write!(f, "global.set {}", index),
Operator::ITruncFromF { Operator::ITruncFromF {
input_ty, input_ty,
output_ty, output_ty,
@@ -1184,28 +1184,24 @@ where
// `Select` pops 3 elements and pushes 1 // `Select` pops 3 elements and pushes 1
WasmOperator::Select => sig!((T, T, I32) -> (T)), WasmOperator::Select => sig!((T, T, I32) -> (T)),
WasmOperator::GetLocal { local_index } => { WasmOperator::LocalGet { local_index } => {
let ty = self.stack[*local_index as usize]; let ty = self.stack[*local_index as usize];
sig!(() -> (ty)) sig!(() -> (ty))
} }
WasmOperator::SetLocal { local_index } => { WasmOperator::LocalSet { local_index } => {
let ty = self.stack[*local_index as usize]; let ty = self.stack[*local_index as usize];
sig!((ty) -> ()) sig!((ty) -> ())
} }
WasmOperator::TeeLocal { local_index } => { WasmOperator::LocalTee { local_index } => {
let ty = self.stack[*local_index as usize]; let ty = self.stack[*local_index as usize];
sig!((ty) -> (ty)) sig!((ty) -> (ty))
} }
WasmOperator::GetGlobal { global_index } => { WasmOperator::GlobalGet { global_index } => sig!(() -> (self.module.global_type(*global_index).to_microwasm_type())),
sig!(() -> (self.module.global_type(*global_index).to_microwasm_type())) WasmOperator::GlobalSet { global_index } => sig!((self.module.global_type(*global_index).to_microwasm_type()) -> ()),
}
WasmOperator::SetGlobal { global_index } => {
sig!((self.module.global_type(*global_index).to_microwasm_type()) -> ())
}
WasmOperator::F32Load { .. } => sig!((I32) -> (F32)), WasmOperator::F32Load { .. } => sig!((I32) -> (F32)),
WasmOperator::F64Load { .. } => sig!((I32) -> (F64)), WasmOperator::F64Load { .. } => sig!((I32) -> (F64)),
@@ -1294,12 +1290,8 @@ where
| WasmOperator::F64Le | WasmOperator::F64Le
| WasmOperator::F64Ge => sig!((F64, F64) -> (I32)), | WasmOperator::F64Ge => sig!((F64, F64) -> (I32)),
WasmOperator::I32Clz | WasmOperator::I32Ctz | WasmOperator::I32Popcnt => { WasmOperator::I32Clz | WasmOperator::I32Ctz | WasmOperator::I32Popcnt => sig!((I32) -> (I32)),
sig!((I32) -> (I32)) WasmOperator::I64Clz | WasmOperator::I64Ctz | WasmOperator::I64Popcnt => sig!((I64) -> (I64)),
}
WasmOperator::I64Clz | WasmOperator::I64Ctz | WasmOperator::I64Popcnt => {
sig!((I64) -> (I64))
}
WasmOperator::I32Add WasmOperator::I32Add
| WasmOperator::I32Sub | WasmOperator::I32Sub
@@ -1366,16 +1358,16 @@ where
| WasmOperator::F64Copysign => sig!((F64, F64) -> (F64)), | WasmOperator::F64Copysign => sig!((F64, F64) -> (F64)),
WasmOperator::I32WrapI64 => sig!((I64) -> (I32)), WasmOperator::I32WrapI64 => sig!((I64) -> (I32)),
WasmOperator::I32TruncSF32 | WasmOperator::I32TruncUF32 => sig!((F32) -> (I32)), WasmOperator::I32TruncF32S | WasmOperator::I32TruncF32U => sig!((F32) -> (I32)),
WasmOperator::I32TruncSF64 | WasmOperator::I32TruncUF64 => sig!((F64) -> (I32)), WasmOperator::I32TruncF64S | WasmOperator::I32TruncF64U => sig!((F64) -> (I32)),
WasmOperator::I64ExtendSI32 | WasmOperator::I64ExtendUI32 => sig!((I32) -> (I64)), WasmOperator::I64ExtendI32S | WasmOperator::I64ExtendI32U => sig!((I32) -> (I64)),
WasmOperator::I64TruncSF32 | WasmOperator::I64TruncUF32 => sig!((F32) -> (I64)), WasmOperator::I64TruncF32S | WasmOperator::I64TruncF32U => sig!((F32) -> (I64)),
WasmOperator::I64TruncSF64 | WasmOperator::I64TruncUF64 => sig!((F64) -> (I64)), WasmOperator::I64TruncF64S | WasmOperator::I64TruncF64U => sig!((F64) -> (I64)),
WasmOperator::F32ConvertSI32 | WasmOperator::F32ConvertUI32 => sig!((I32) -> (F32)), WasmOperator::F32ConvertI32S | WasmOperator::F32ConvertI32U => sig!((I32) -> (F32)),
WasmOperator::F32ConvertSI64 | WasmOperator::F32ConvertUI64 => sig!((I64) -> (F32)), WasmOperator::F32ConvertI64S | WasmOperator::F32ConvertI64U => sig!((I64) -> (F32)),
WasmOperator::F32DemoteF64 => sig!((F64) -> (F32)), WasmOperator::F32DemoteF64 => sig!((F64) -> (F32)),
WasmOperator::F64ConvertSI32 | WasmOperator::F64ConvertUI32 => sig!((I32) -> (F64)), WasmOperator::F64ConvertI32S | WasmOperator::F64ConvertI32U => sig!((I32) -> (F64)),
WasmOperator::F64ConvertSI64 | WasmOperator::F64ConvertUI64 => sig!((I64) -> (F64)), WasmOperator::F64ConvertI64S | WasmOperator::F64ConvertI64U => sig!((I64) -> (F64)),
WasmOperator::F64PromoteF32 => sig!((F32) -> (F64)), WasmOperator::F64PromoteF32 => sig!((F32) -> (F64)),
WasmOperator::I32ReinterpretF32 => sig!((F32) -> (I32)), WasmOperator::I32ReinterpretF32 => sig!((F32) -> (I32)),
WasmOperator::I64ReinterpretF64 => sig!((F64) -> (I64)), WasmOperator::I64ReinterpretF64 => sig!((F64) -> (I64)),
@@ -1893,42 +1885,42 @@ where
WasmOperator::Drop => smallvec![Operator::Drop(0..=0)], WasmOperator::Drop => smallvec![Operator::Drop(0..=0)],
WasmOperator::Select => smallvec![Operator::Select], WasmOperator::Select => smallvec![Operator::Select],
WasmOperator::GetLocal { local_index } => { WasmOperator::LocalGet { local_index } => {
// `- 1` because we apply the stack difference _before_ this point // `- 1` because we apply the stack difference _before_ this point
let depth = self.local_depth(local_index).checked_sub(1)?; let depth = self.local_depth(local_index).checked_sub(1)?;
let depth = match depth.try_into() { let depth = match depth.try_into() {
Ok(o) => o, Ok(o) => o,
Err(_) => { Err(_) => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "GetLocal - Local out of range", message: "LocalGet - Local out of range",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
}; };
smallvec![Operator::Pick(depth)] smallvec![Operator::Pick(depth)]
} }
WasmOperator::SetLocal { local_index } => { WasmOperator::LocalSet { local_index } => {
// `+ 1` because we apply the stack difference _before_ this point // `+ 1` because we apply the stack difference _before_ this point
let depth = self.local_depth(local_index).checked_add(1)?; let depth = self.local_depth(local_index).checked_add(1)?;
let depth = match depth.try_into() { let depth = match depth.try_into() {
Ok(o) => o, Ok(o) => o,
Err(_) => { Err(_) => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "SetLocal - Local out of range", message: "LocalSet - Local out of range",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
}; };
smallvec![Operator::Swap(depth), Operator::Drop(0..=0)] smallvec![Operator::Swap(depth), Operator::Drop(0..=0)]
} }
WasmOperator::TeeLocal { local_index } => { WasmOperator::LocalTee { local_index } => {
// `+ 1` because we `pick` before `swap` // `+ 1` because we `pick` before `swap`
let depth = self.local_depth(local_index).checked_add(1)?; let depth = self.local_depth(local_index).checked_add(1)?;
let depth = match depth.try_into() { let depth = match depth.try_into() {
Ok(o) => o, Ok(o) => o,
Err(_) => { Err(_) => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "SetLocal - Local out of range", message: "LocalTee - Local out of range",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
@@ -1939,11 +1931,11 @@ where
Operator::Drop(0..=0), Operator::Drop(0..=0),
] ]
} }
WasmOperator::GetGlobal { global_index } => { WasmOperator::GlobalGet { global_index } => {
smallvec![Operator::GetGlobal(global_index)] smallvec![Operator::GlobalGet(global_index)]
} }
WasmOperator::SetGlobal { global_index } => { WasmOperator::GlobalSet { global_index } => {
smallvec![Operator::SetGlobal(global_index)] smallvec![Operator::GlobalSet(global_index)]
} }
WasmOperator::I32Load { memarg } => smallvec![Operator::Load { WasmOperator::I32Load { memarg } => smallvec![Operator::Load {
@@ -2165,73 +2157,73 @@ where
WasmOperator::F64Max => smallvec![Operator::Max(Size::_64)], WasmOperator::F64Max => smallvec![Operator::Max(Size::_64)],
WasmOperator::F64Copysign => smallvec![Operator::Copysign(Size::_64)], WasmOperator::F64Copysign => smallvec![Operator::Copysign(Size::_64)],
WasmOperator::I32WrapI64 => smallvec![Operator::I32WrapFromI64], WasmOperator::I32WrapI64 => smallvec![Operator::I32WrapFromI64],
WasmOperator::I32TruncSF32 => smallvec![Operator::ITruncFromF { WasmOperator::I32TruncF32S => smallvec![Operator::ITruncFromF {
input_ty: Size::_32, input_ty: Size::_32,
output_ty: sint::I32 output_ty: sint::I32
}], }],
WasmOperator::I32TruncUF32 => smallvec![Operator::ITruncFromF { WasmOperator::I32TruncF32U => smallvec![Operator::ITruncFromF {
input_ty: Size::_32, input_ty: Size::_32,
output_ty: sint::U32 output_ty: sint::U32
}], }],
WasmOperator::I32TruncSF64 => smallvec![Operator::ITruncFromF { WasmOperator::I32TruncF64S => smallvec![Operator::ITruncFromF {
input_ty: Size::_64, input_ty: Size::_64,
output_ty: sint::I32 output_ty: sint::I32
}], }],
WasmOperator::I32TruncUF64 => smallvec![Operator::ITruncFromF { WasmOperator::I32TruncF64U => smallvec![Operator::ITruncFromF {
input_ty: Size::_64, input_ty: Size::_64,
output_ty: sint::U32 output_ty: sint::U32
}], }],
WasmOperator::I64ExtendSI32 => smallvec![Operator::Extend { WasmOperator::I64ExtendI32S => smallvec![Operator::Extend {
sign: Signedness::Signed sign: Signedness::Signed
}], }],
WasmOperator::I64ExtendUI32 => smallvec![Operator::Extend { WasmOperator::I64ExtendI32U => smallvec![Operator::Extend {
sign: Signedness::Unsigned sign: Signedness::Unsigned
}], }],
WasmOperator::I64TruncSF32 => smallvec![Operator::ITruncFromF { WasmOperator::I64TruncF32S => smallvec![Operator::ITruncFromF {
input_ty: Size::_32, input_ty: Size::_32,
output_ty: sint::I64, output_ty: sint::I64,
}], }],
WasmOperator::I64TruncUF32 => smallvec![Operator::ITruncFromF { WasmOperator::I64TruncF32U => smallvec![Operator::ITruncFromF {
input_ty: Size::_32, input_ty: Size::_32,
output_ty: sint::U64, output_ty: sint::U64,
}], }],
WasmOperator::I64TruncSF64 => smallvec![Operator::ITruncFromF { WasmOperator::I64TruncF64S => smallvec![Operator::ITruncFromF {
input_ty: Size::_64, input_ty: Size::_64,
output_ty: sint::I64, output_ty: sint::I64,
}], }],
WasmOperator::I64TruncUF64 => smallvec![Operator::ITruncFromF { WasmOperator::I64TruncF64U => smallvec![Operator::ITruncFromF {
input_ty: Size::_64, input_ty: Size::_64,
output_ty: sint::U64, output_ty: sint::U64,
}], }],
WasmOperator::F32ConvertSI32 => smallvec![Operator::FConvertFromI { WasmOperator::F32ConvertI32S => smallvec![Operator::FConvertFromI {
input_ty: sint::I32, input_ty: sint::I32,
output_ty: Size::_32 output_ty: Size::_32
}], }],
WasmOperator::F32ConvertUI32 => smallvec![Operator::FConvertFromI { WasmOperator::F32ConvertI32U => smallvec![Operator::FConvertFromI {
input_ty: sint::U32, input_ty: sint::U32,
output_ty: Size::_32 output_ty: Size::_32
}], }],
WasmOperator::F32ConvertSI64 => smallvec![Operator::FConvertFromI { WasmOperator::F32ConvertI64S => smallvec![Operator::FConvertFromI {
input_ty: sint::I64, input_ty: sint::I64,
output_ty: Size::_32 output_ty: Size::_32
}], }],
WasmOperator::F32ConvertUI64 => smallvec![Operator::FConvertFromI { WasmOperator::F32ConvertI64U => smallvec![Operator::FConvertFromI {
input_ty: sint::U64, input_ty: sint::U64,
output_ty: Size::_32 output_ty: Size::_32
}], }],
WasmOperator::F64ConvertSI32 => smallvec![Operator::FConvertFromI { WasmOperator::F64ConvertI32S => smallvec![Operator::FConvertFromI {
input_ty: sint::I32, input_ty: sint::I32,
output_ty: Size::_64 output_ty: Size::_64
}], }],
WasmOperator::F64ConvertUI32 => smallvec![Operator::FConvertFromI { WasmOperator::F64ConvertI32U => smallvec![Operator::FConvertFromI {
input_ty: sint::U32, input_ty: sint::U32,
output_ty: Size::_64 output_ty: Size::_64
}], }],
WasmOperator::F64ConvertSI64 => smallvec![Operator::FConvertFromI { WasmOperator::F64ConvertI64S => smallvec![Operator::FConvertFromI {
input_ty: sint::I64, input_ty: sint::I64,
output_ty: Size::_64 output_ty: Size::_64
}], }],
WasmOperator::F64ConvertUI64 => smallvec![Operator::FConvertFromI { WasmOperator::F64ConvertI64U => smallvec![Operator::FConvertFromI {
input_ty: sint::U64, input_ty: sint::U64,
output_ty: Size::_64 output_ty: Size::_64
}], }],
@@ -2274,51 +2266,51 @@ where
// 0xFC operators // 0xFC operators
// Non-trapping Float-to-int Conversions // Non-trapping Float-to-int Conversions
WasmOperator::I32TruncSSatF32 => { WasmOperator::I32TruncSatF32S => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I32TruncSSatF32 unimplemented", message: "I32TruncSatF32S unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I32TruncUSatF32 => { WasmOperator::I32TruncSatF32U => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I32TruncUSatF32 unimplemented", message: "I32TruncSatF32U unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I32TruncSSatF64 => { WasmOperator::I32TruncSatF64S => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I32TruncSSatF64 unimplemented", message: "I32TruncSatF64S unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I32TruncUSatF64 => { WasmOperator::I32TruncSatF64U => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I32TruncUSatF64 unimplemented", message: "I32TruncSatF64U unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I64TruncSSatF32 => { WasmOperator::I64TruncSatF32S => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I64TruncSSatF32 unimplemented", message: "I64TruncSatF32S unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I64TruncUSatF32 => { WasmOperator::I64TruncSatF32U => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I64TruncUSatF32 unimplemented", message: "I64TruncSatF32U unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I64TruncSSatF64 => { WasmOperator::I64TruncSatF64S => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I64TruncSSatF64 unimplemented", message: "I64TruncSatF64S unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }
WasmOperator::I64TruncUSatF64 => { WasmOperator::I64TruncSatF64U => {
return Some(Err(BinaryReaderError { return Some(Err(BinaryReaderError {
message: "I64TruncUSatF64 unimplemented", message: "I64TruncSatF64U unimplemented",
offset: -1isize as usize, offset: -1isize as usize,
})) }))
} }