Skip to content

Commit

Permalink
Merge pull request #2340 from demergent-labs/dependabot/cargo/wasmi-0…
Browse files Browse the repository at this point in the history
….40.0

deps: bump wasmi from 0.31.2 to 0.40.0
  • Loading branch information
lastmjs authored Jan 1, 2025
2 parents 697a8a9 + 00f1fa0 commit 8ed08b6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 43 deletions.
91 changes: 68 additions & 23 deletions Cargo.lock

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

Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ serde_json = "1.0.134"
ic-wasi-polyfill = "0.6.4"
wasmedge_quickjs = { git = "https://github.com/demergent-labs/wasmedge-quickjs", rev = "573c6c07316de64e4bb9a9561b079f265fd9bcc4" }
# wasmedge_quickjs = { path = "/home/wasmedge-quickjs" }
wasmi = "0.31.2"
wasmi = "0.40.0"
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ impl JsFn for NativeFunction {
let func_param_types = func_ty.params();

// TODO check all of these conversions, they are bad
let params: Vec<wasmi::Value> = func_param_types
let params: Vec<wasmi::Val> = func_param_types
.iter()
.enumerate()
.map(|(index, param_value_type)| match param_value_type {
wasmi::core::ValueType::I32 => {
wasmi::core::ValType::I32 => {
let param_i32 = if let JsValue::Int(int) =
argv.get(index).unwrap()
{
Expand All @@ -89,9 +89,9 @@ impl JsFn for NativeFunction {
panic!("conversion from JsValue to i32 failed")
};

wasmi::Value::I32(*param_i32)
wasmi::Val::I32(*param_i32)
}
wasmi::core::ValueType::I64 => {
wasmi::core::ValType::I64 => {
let param_i64 = if let JsValue::Int(int) =
argv.get(index).unwrap()
{
Expand All @@ -100,9 +100,9 @@ impl JsFn for NativeFunction {
panic!("conversion from JsValue to i32 failed")
};

wasmi::Value::I64(*param_i64 as i64)
wasmi::Val::I64(*param_i64 as i64)
}
wasmi::core::ValueType::F32 => {
wasmi::core::ValType::F32 => {
let param_f64 = if let JsValue::Float(float) =
argv.get(index).unwrap()
{
Expand All @@ -111,9 +111,9 @@ impl JsFn for NativeFunction {
panic!("conversion from JsValue to i32 failed")
};

wasmi::Value::F32((*param_f64 as u32).into())
wasmi::Val::F32((*param_f64 as u32).into())
}
wasmi::core::ValueType::F64 => {
wasmi::core::ValType::F64 => {
let param_f64 = if let JsValue::Float(float) =
argv.get(index).unwrap()
{
Expand All @@ -122,10 +122,10 @@ impl JsFn for NativeFunction {
panic!("conversion from JsValue to i32 failed")
};

wasmi::Value::F64((*param_f64 as u64).into())
wasmi::Val::F64((*param_f64 as u64).into())
}
wasmi::core::ValueType::FuncRef => todo!(),
wasmi::core::ValueType::ExternRef => todo!(),
wasmi::core::ValType::FuncRef => todo!(),
wasmi::core::ValType::ExternRef => todo!(),
})
.collect();

Expand All @@ -134,9 +134,9 @@ impl JsFn for NativeFunction {
// TODO the first result
let func_result_types = func_ty.results();

let mut buf: Vec<wasmi::Value> =
let mut buf: Vec<wasmi::Val> =
vec![
wasmi::Value::default(wasmi::core::ValueType::I32);
wasmi::Val::default(wasmi::core::ValType::I32);
func_result_types.len()
];

Expand All @@ -147,25 +147,25 @@ impl JsFn for NativeFunction {

// TODO check all of these conversions, they are bad
match func_result_types.get(0).unwrap() {
wasmi::core::ValueType::I32 => {
wasmi::core::ValType::I32 => {
JsValue::Int(buf.get(0).unwrap().i32().unwrap())
}
wasmi::core::ValueType::I64 => {
wasmi::core::ValType::I64 => {
JsValue::Int(buf.get(0).unwrap().i64().unwrap() as i32)
// TODO should this not be a bigint?
}
wasmi::core::ValueType::F32 => {
wasmi::core::ValType::F32 => {
let u32: u32 = buf.get(0).unwrap().f32().unwrap().into();

JsValue::Float(u32 as f64)
}
wasmi::core::ValueType::F64 => {
wasmi::core::ValType::F64 => {
let u64: u64 = buf.get(0).unwrap().f64().unwrap().into();

JsValue::Float(u64 as f64)
}
wasmi::core::ValueType::FuncRef => todo!(),
wasmi::core::ValueType::ExternRef => todo!(),
wasmi::core::ValType::FuncRef => todo!(),
wasmi::core::ValType::ExternRef => todo!(),
}
})
},
Expand Down

0 comments on commit 8ed08b6

Please sign in to comment.