Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bump wasmi to 0.3.0 #278

Merged
merged 1 commit into from
Jul 4, 2018
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
29 changes: 17 additions & 12 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 polkadot/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Types and utilities for creating and working with parachains"

[dependencies]
substrate-codec = { path = "../../substrate/codec", default-features = false }
wasmi = { version = "0.1", optional = true }
wasmi = { version = "0.3", optional = true }
error-chain = { version = "0.12", optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion substrate/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ substrate-runtime-version = { path = "../runtime/version" }
ed25519 = { path = "../ed25519" }
serde = "1.0"
serde_derive = "1.0"
wasmi = "0.1.0"
wasmi = "0.3"
byteorder = "1.1"
rustc-hex = "1.0.0"
triehash = "0.1.0"
Expand Down
5 changes: 3 additions & 2 deletions substrate/executor/src/wasm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Rust implementation of Substrate contracts.

use wasmi::{ValueType, RuntimeValue, HostError};
use wasmi::nan_preserving_float::{F32, F64};
use std::fmt;

#[derive(Debug)]
Expand All @@ -34,8 +35,8 @@ impl ConvertibleToWasm for i32 { type NativeType = i32; const VALUE_TYPE: ValueT
impl ConvertibleToWasm for u32 { type NativeType = u32; const VALUE_TYPE: ValueType = ValueType::I32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I32(self as i32) } }
impl ConvertibleToWasm for i64 { type NativeType = i64; const VALUE_TYPE: ValueType = ValueType::I64; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I64(self) } }
impl ConvertibleToWasm for u64 { type NativeType = u64; const VALUE_TYPE: ValueType = ValueType::I64; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I64(self as i64) } }
impl ConvertibleToWasm for f32 { type NativeType = f32; const VALUE_TYPE: ValueType = ValueType::F32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::F32(self) } }
impl ConvertibleToWasm for f64 { type NativeType = f64; const VALUE_TYPE: ValueType = ValueType::F64; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::F64(self) } }
impl ConvertibleToWasm for F32 { type NativeType = F32; const VALUE_TYPE: ValueType = ValueType::F32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::F32(self) } }
impl ConvertibleToWasm for F64 { type NativeType = F64; const VALUE_TYPE: ValueType = ValueType::F64; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::F64(self) } }
impl ConvertibleToWasm for isize { type NativeType = i32; const VALUE_TYPE: ValueType = ValueType::I32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I32(self as i32) } }
impl ConvertibleToWasm for usize { type NativeType = u32; const VALUE_TYPE: ValueType = ValueType::I32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I32(self as u32 as i32) } }
impl<T> ConvertibleToWasm for *const T { type NativeType = u32; const VALUE_TYPE: ValueType = ValueType::I32; fn to_runtime_value(self) -> RuntimeValue { RuntimeValue::I32(self as isize as i32) } }
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ uint = { git = "https://github.com/rphmeier/primitives.git", branch = "compile-f
twox-hash = { version = "1.1.0", optional = true }
byteorder = { version = "1.1", default_features = false }
blake2-rfc = { version = "0.2.18", optional = true }
wasmi = { version = "0.1", optional = true }
wasmi = { version = "0.3", optional = true }

[dev-dependencies]
substrate-serializer = { path = "../serializer" }
Expand Down
5 changes: 3 additions & 2 deletions substrate/primitives/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ impl From<::wasmi::RuntimeValue> for TypedValue {
impl From<TypedValue> for ::wasmi::RuntimeValue {
fn from(val: TypedValue) -> ::wasmi::RuntimeValue {
use ::wasmi::RuntimeValue;
use ::wasmi::nan_preserving_float::{F32, F64};
match val {
TypedValue::I32(v) => RuntimeValue::I32(v),
TypedValue::I64(v) => RuntimeValue::I64(v),
TypedValue::F32(v_bits) => RuntimeValue::F32(f32::from_bits(v_bits as u32)),
TypedValue::F64(v_bits) => RuntimeValue::F64(f64::from_bits(v_bits as u64)),
TypedValue::F32(v_bits) => RuntimeValue::F32(F32::from_bits(v_bits as u32)),
TypedValue::F64(v_bits) => RuntimeValue::F64(F64::from_bits(v_bits as u64)),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/runtime-sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build = "build.rs"
rustc_version = "0.2"

[dependencies]
wasmi = { version = "0.1", optional = true }
wasmi = { version = "0.3", optional = true }
substrate-primitives = { path = "../primitives", default_features = false }
substrate-runtime-std = { path = "../runtime-std", default_features = false }
substrate-runtime-io = { path = "../runtime-io", default_features = false }
Expand Down
6 changes: 3 additions & 3 deletions substrate/runtime-sandbox/with_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ extern crate wasmi;
use rstd::collections::btree_map::BTreeMap;
use rstd::fmt;


use self::wasmi::{
Externals, FuncInstance, FuncRef, GlobalDescriptor, GlobalRef, ImportResolver,
MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef,
Expand Down Expand Up @@ -104,11 +103,12 @@ fn from_runtime_value(v: RuntimeValue) -> TypedValue {
}

fn to_runtime_value(v: TypedValue) -> RuntimeValue {
use self::wasmi::nan_preserving_float::{F32, F64};
match v {
TypedValue::I32(v) => RuntimeValue::I32(v as i32),
TypedValue::I64(v) => RuntimeValue::I64(v as i64),
TypedValue::F32(v_bits) => RuntimeValue::F32(f32::from_bits(v_bits as u32)),
TypedValue::F64(v_bits) => RuntimeValue::F64(f64::from_bits(v_bits as u64)),
TypedValue::F32(v_bits) => RuntimeValue::F32(F32::from_bits(v_bits as u32)),
TypedValue::F64(v_bits) => RuntimeValue::F64(F64::from_bits(v_bits as u64)),
}
}

Expand Down