Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wasmi version with breaking changes #1817

Merged
merged 2 commits into from
May 7, 2024
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
61 changes: 53 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ siphasher = { version = "1.0.1", default-features = false }
slab = { version = "0.4.8", default-features = false }
smallvec = { version = "1.13.2", default-features = false }
twox-hash = { version = "1.6.3", default-features = false }
wasmi = { version = "0.32.0-beta.10", default-features = false }
wasmi = { version = "0.32.0-beta.14", default-features = false }
x25519-dalek = { version = "2.0.0-rc.3", default-features = false, features = ["alloc", "precomputed-tables", "static_secrets", "zeroize"] }
zeroize = { version = "1.7.0", default-features = false, features = ["alloc"] }

Expand Down
42 changes: 21 additions & 21 deletions lib/src/executor/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,9 +1062,9 @@ impl<'a> From<&'a Signature> for wasmi::FuncType {
sig.params
.iter()
.copied()
.map(wasmi::core::ValueType::from)
.map(wasmi::core::ValType::from)
.collect::<Vec<_>>(),
sig.ret_ty.map(wasmi::core::ValueType::from),
sig.ret_ty.map(wasmi::core::ValType::from),
)
}
}
Expand Down Expand Up @@ -1189,35 +1189,35 @@ impl WasmValue {
}
}

impl TryFrom<wasmi::Value> for WasmValue {
impl TryFrom<wasmi::Val> for WasmValue {
type Error = UnsupportedTypeError;

fn try_from(val: wasmi::Value) -> Result<Self, Self::Error> {
fn try_from(val: wasmi::Val) -> Result<Self, Self::Error> {
match val {
wasmi::Value::I32(v) => Ok(WasmValue::I32(v)),
wasmi::Value::I64(v) => Ok(WasmValue::I64(v)),
wasmi::Val::I32(v) => Ok(WasmValue::I32(v)),
wasmi::Val::I64(v) => Ok(WasmValue::I64(v)),
_ => Err(UnsupportedTypeError),
}
}
}

impl<'a> TryFrom<&'a wasmi::Value> for WasmValue {
impl<'a> TryFrom<&'a wasmi::Val> for WasmValue {
type Error = UnsupportedTypeError;

fn try_from(val: &'a wasmi::Value) -> Result<Self, Self::Error> {
fn try_from(val: &'a wasmi::Val) -> Result<Self, Self::Error> {
match val {
wasmi::Value::I32(v) => Ok(WasmValue::I32(*v)),
wasmi::Value::I64(v) => Ok(WasmValue::I64(*v)),
wasmi::Val::I32(v) => Ok(WasmValue::I32(*v)),
wasmi::Val::I64(v) => Ok(WasmValue::I64(*v)),
_ => Err(UnsupportedTypeError),
}
}
}

impl From<WasmValue> for wasmi::Value {
impl From<WasmValue> for wasmi::Val {
fn from(val: WasmValue) -> Self {
match val {
WasmValue::I32(v) => wasmi::Value::I32(v),
WasmValue::I64(v) => wasmi::Value::I64(v),
WasmValue::I32(v) => wasmi::Val::I32(v),
WasmValue::I64(v) => wasmi::Val::I64(v),
}
}
}
Expand Down Expand Up @@ -1273,22 +1273,22 @@ impl<'a> TryFrom<&'a wasmtime::Val> for WasmValue {
}
}

impl From<ValueType> for wasmi::core::ValueType {
fn from(ty: ValueType) -> wasmi::core::ValueType {
impl From<ValueType> for wasmi::core::ValType {
fn from(ty: ValueType) -> wasmi::core::ValType {
match ty {
ValueType::I32 => wasmi::core::ValueType::I32,
ValueType::I64 => wasmi::core::ValueType::I64,
ValueType::I32 => wasmi::core::ValType::I32,
ValueType::I64 => wasmi::core::ValType::I64,
}
}
}

impl TryFrom<wasmi::core::ValueType> for ValueType {
impl TryFrom<wasmi::core::ValType> for ValueType {
type Error = UnsupportedTypeError;

fn try_from(val: wasmi::core::ValueType) -> Result<Self, Self::Error> {
fn try_from(val: wasmi::core::ValType) -> Result<Self, Self::Error> {
match val {
wasmi::core::ValueType::I32 => Ok(ValueType::I32),
wasmi::core::ValueType::I64 => Ok(ValueType::I64),
wasmi::core::ValType::I32 => Ok(ValueType::I32),
wasmi::core::ValType::I64 => Ok(ValueType::I64),
_ => Err(UnsupportedTypeError),
}
}
Expand Down
18 changes: 9 additions & 9 deletions lib/src/executor/vm/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl InterpreterPrototype {
.get(&self.store);

match value {
wasmi::Value::I32(v) => Ok(u32::from_ne_bytes(v.to_ne_bytes())),
wasmi::Val::I32(v) => Ok(u32::from_ne_bytes(v.to_ne_bytes())),
_ => Err(GlobalValueErr::Invalid),
}
}
Expand Down Expand Up @@ -385,10 +385,10 @@ impl Prepare {
// function signature above.
debug_assert!(list.len() <= 1);
list.first().map(|item| match *item {
wasmi::core::ValueType::I32 => wasmi::Value::I32(0),
wasmi::core::ValueType::I64 => wasmi::Value::I64(0),
wasmi::core::ValueType::F32 => wasmi::Value::F32(0.0f32.into()),
wasmi::core::ValueType::F64 => wasmi::Value::F64(0.0.into()),
wasmi::core::ValType::I32 => wasmi::Val::I32(0),
wasmi::core::ValType::I64 => wasmi::Val::I64(0),
wasmi::core::ValType::F32 => wasmi::Val::F32(0.0f32.into()),
wasmi::core::ValType::F64 => wasmi::Val::F64(0.0.into()),
_ => unreachable!(),
})
};
Expand All @@ -402,7 +402,7 @@ impl Prepare {
func_to_call,
params
.iter()
.map(|v| wasmi::Value::from(*v))
.map(|v| wasmi::Val::from(*v))
.collect::<Vec<_>>(),
)),
})
Expand Down Expand Up @@ -452,11 +452,11 @@ pub struct Interpreter {
/// Where the return value of the execution will be stored.
/// While this could be regenerated every time `run` is called, it is instead kept in the
/// `Interpreter` struct for convenience.
dummy_output_value: Option<wasmi::Value>,
dummy_output_value: Option<wasmi::Val>,
}

enum Execution {
NotStarted(wasmi::Func, Vec<wasmi::Value>),
NotStarted(wasmi::Func, Vec<wasmi::Val>),
Started(wasmi::ResumableInvocation),
}

Expand Down Expand Up @@ -497,7 +497,7 @@ impl Interpreter {
return Err(RunErr::BadValueTy { expected, obtained });
}

let value = value.map(wasmi::Value::from);
let value = value.map(wasmi::Val::from);
let inputs = match value.as_ref() {
Some(v) => &core::array::from_ref(v)[..],
None => &[],
Expand Down
Loading