Skip to content

Commit 21d4916

Browse files
authored
Update wasmi version with breaking changes (#1817)
* Update wasmi version with breaking changes * Update version
1 parent 61cf6a9 commit 21d4916

File tree

4 files changed

+84
-39
lines changed

4 files changed

+84
-39
lines changed

Cargo.lock

+53-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ siphasher = { version = "1.0.1", default-features = false }
7676
slab = { version = "0.4.8", default-features = false }
7777
smallvec = { version = "1.13.2", default-features = false }
7878
twox-hash = { version = "1.6.3", default-features = false }
79-
wasmi = { version = "0.32.0-beta.10", default-features = false }
79+
wasmi = { version = "0.32.0-beta.14", default-features = false }
8080
x25519-dalek = { version = "2.0.0-rc.3", default-features = false, features = ["alloc", "precomputed-tables", "static_secrets", "zeroize"] }
8181
zeroize = { version = "1.7.0", default-features = false, features = ["alloc"] }
8282

lib/src/executor/vm.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1062,9 +1062,9 @@ impl<'a> From<&'a Signature> for wasmi::FuncType {
10621062
sig.params
10631063
.iter()
10641064
.copied()
1065-
.map(wasmi::core::ValueType::from)
1065+
.map(wasmi::core::ValType::from)
10661066
.collect::<Vec<_>>(),
1067-
sig.ret_ty.map(wasmi::core::ValueType::from),
1067+
sig.ret_ty.map(wasmi::core::ValType::from),
10681068
)
10691069
}
10701070
}
@@ -1189,35 +1189,35 @@ impl WasmValue {
11891189
}
11901190
}
11911191

1192-
impl TryFrom<wasmi::Value> for WasmValue {
1192+
impl TryFrom<wasmi::Val> for WasmValue {
11931193
type Error = UnsupportedTypeError;
11941194

1195-
fn try_from(val: wasmi::Value) -> Result<Self, Self::Error> {
1195+
fn try_from(val: wasmi::Val) -> Result<Self, Self::Error> {
11961196
match val {
1197-
wasmi::Value::I32(v) => Ok(WasmValue::I32(v)),
1198-
wasmi::Value::I64(v) => Ok(WasmValue::I64(v)),
1197+
wasmi::Val::I32(v) => Ok(WasmValue::I32(v)),
1198+
wasmi::Val::I64(v) => Ok(WasmValue::I64(v)),
11991199
_ => Err(UnsupportedTypeError),
12001200
}
12011201
}
12021202
}
12031203

1204-
impl<'a> TryFrom<&'a wasmi::Value> for WasmValue {
1204+
impl<'a> TryFrom<&'a wasmi::Val> for WasmValue {
12051205
type Error = UnsupportedTypeError;
12061206

1207-
fn try_from(val: &'a wasmi::Value) -> Result<Self, Self::Error> {
1207+
fn try_from(val: &'a wasmi::Val) -> Result<Self, Self::Error> {
12081208
match val {
1209-
wasmi::Value::I32(v) => Ok(WasmValue::I32(*v)),
1210-
wasmi::Value::I64(v) => Ok(WasmValue::I64(*v)),
1209+
wasmi::Val::I32(v) => Ok(WasmValue::I32(*v)),
1210+
wasmi::Val::I64(v) => Ok(WasmValue::I64(*v)),
12111211
_ => Err(UnsupportedTypeError),
12121212
}
12131213
}
12141214
}
12151215

1216-
impl From<WasmValue> for wasmi::Value {
1216+
impl From<WasmValue> for wasmi::Val {
12171217
fn from(val: WasmValue) -> Self {
12181218
match val {
1219-
WasmValue::I32(v) => wasmi::Value::I32(v),
1220-
WasmValue::I64(v) => wasmi::Value::I64(v),
1219+
WasmValue::I32(v) => wasmi::Val::I32(v),
1220+
WasmValue::I64(v) => wasmi::Val::I64(v),
12211221
}
12221222
}
12231223
}
@@ -1273,22 +1273,22 @@ impl<'a> TryFrom<&'a wasmtime::Val> for WasmValue {
12731273
}
12741274
}
12751275

1276-
impl From<ValueType> for wasmi::core::ValueType {
1277-
fn from(ty: ValueType) -> wasmi::core::ValueType {
1276+
impl From<ValueType> for wasmi::core::ValType {
1277+
fn from(ty: ValueType) -> wasmi::core::ValType {
12781278
match ty {
1279-
ValueType::I32 => wasmi::core::ValueType::I32,
1280-
ValueType::I64 => wasmi::core::ValueType::I64,
1279+
ValueType::I32 => wasmi::core::ValType::I32,
1280+
ValueType::I64 => wasmi::core::ValType::I64,
12811281
}
12821282
}
12831283
}
12841284

1285-
impl TryFrom<wasmi::core::ValueType> for ValueType {
1285+
impl TryFrom<wasmi::core::ValType> for ValueType {
12861286
type Error = UnsupportedTypeError;
12871287

1288-
fn try_from(val: wasmi::core::ValueType) -> Result<Self, Self::Error> {
1288+
fn try_from(val: wasmi::core::ValType) -> Result<Self, Self::Error> {
12891289
match val {
1290-
wasmi::core::ValueType::I32 => Ok(ValueType::I32),
1291-
wasmi::core::ValueType::I64 => Ok(ValueType::I64),
1290+
wasmi::core::ValType::I32 => Ok(ValueType::I32),
1291+
wasmi::core::ValType::I64 => Ok(ValueType::I64),
12921292
_ => Err(UnsupportedTypeError),
12931293
}
12941294
}

lib/src/executor/vm/interpreter.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl InterpreterPrototype {
217217
.get(&self.store);
218218

219219
match value {
220-
wasmi::Value::I32(v) => Ok(u32::from_ne_bytes(v.to_ne_bytes())),
220+
wasmi::Val::I32(v) => Ok(u32::from_ne_bytes(v.to_ne_bytes())),
221221
_ => Err(GlobalValueErr::Invalid),
222222
}
223223
}
@@ -385,10 +385,10 @@ impl Prepare {
385385
// function signature above.
386386
debug_assert!(list.len() <= 1);
387387
list.first().map(|item| match *item {
388-
wasmi::core::ValueType::I32 => wasmi::Value::I32(0),
389-
wasmi::core::ValueType::I64 => wasmi::Value::I64(0),
390-
wasmi::core::ValueType::F32 => wasmi::Value::F32(0.0f32.into()),
391-
wasmi::core::ValueType::F64 => wasmi::Value::F64(0.0.into()),
388+
wasmi::core::ValType::I32 => wasmi::Val::I32(0),
389+
wasmi::core::ValType::I64 => wasmi::Val::I64(0),
390+
wasmi::core::ValType::F32 => wasmi::Val::F32(0.0f32.into()),
391+
wasmi::core::ValType::F64 => wasmi::Val::F64(0.0.into()),
392392
_ => unreachable!(),
393393
})
394394
};
@@ -402,7 +402,7 @@ impl Prepare {
402402
func_to_call,
403403
params
404404
.iter()
405-
.map(|v| wasmi::Value::from(*v))
405+
.map(|v| wasmi::Val::from(*v))
406406
.collect::<Vec<_>>(),
407407
)),
408408
})
@@ -452,11 +452,11 @@ pub struct Interpreter {
452452
/// Where the return value of the execution will be stored.
453453
/// While this could be regenerated every time `run` is called, it is instead kept in the
454454
/// `Interpreter` struct for convenience.
455-
dummy_output_value: Option<wasmi::Value>,
455+
dummy_output_value: Option<wasmi::Val>,
456456
}
457457

458458
enum Execution {
459-
NotStarted(wasmi::Func, Vec<wasmi::Value>),
459+
NotStarted(wasmi::Func, Vec<wasmi::Val>),
460460
Started(wasmi::ResumableInvocation),
461461
}
462462

@@ -497,7 +497,7 @@ impl Interpreter {
497497
return Err(RunErr::BadValueTy { expected, obtained });
498498
}
499499

500-
let value = value.map(wasmi::Value::from);
500+
let value = value.map(wasmi::Val::from);
501501
let inputs = match value.as_ref() {
502502
Some(v) => &core::array::from_ref(v)[..],
503503
None => &[],

0 commit comments

Comments
 (0)