Skip to content

Commit

Permalink
Update wasmi_core v0.1 -> v0.2 (#392)
Browse files Browse the repository at this point in the history
* wasmi_core: add docs to F32 and F64

* wasmi_core: bump version 0.1 -> 0.2
  • Loading branch information
Robbepop authored Jul 24, 2022
1 parent 103a3d5 commit 2832cbf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["wasm", "webassembly", "bytecode", "interpreter"]
exclude = [ "/res/*", "/tests/*", "/fuzz/*", "/benches/*" ]

[dependencies]
wasmi_core = { version = "0.1", path = "core", default-features = false }
wasmi_core = { version = "0.2", path = "core", default-features = false }
validation = { package = "wasmi-validation", version = "0.4.2", path = "validation", default-features = false }
parity-wasm = { version = "0.45.0", default-features = false }

Expand Down
6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "wasmi_core"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT/Apache-2.0"
readme = "../README.md"
repository = "https://github.com/paritytech/wasmi"
documentation = "https://paritytech.github.io/wasmi/"
description = "WebAssembly interpreter"
documentation = "https://docs.rs/wasmi_core"
description = "Core abstractions and primitives for the wasmi WebAssembly interpreter"
keywords = ["wasm", "webassembly", "bytecode", "interpreter"]

[dependencies]
Expand Down
40 changes: 26 additions & 14 deletions core/src/nan_preserving_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use core::{
use num_traits::float::FloatCore;

macro_rules! impl_binop {
($for:ident, $is:ident, $op:ident, $func_name:ident) => {
($for:ty, $is:ty, $op:ident, $func_name:ident) => {
impl<T: Into<$for>> $op<T> for $for {
type Output = Self;

#[inline]
fn $func_name(self, other: T) -> Self {
$for(
$op::$func_name($is::from_bits(self.0), $is::from_bits(other.into().0))
Self(
$op::$func_name(<$is>::from_bits(self.0), <$is>::from_bits(other.into().0))
.to_bits(),
)
}
Expand All @@ -21,15 +21,20 @@ macro_rules! impl_binop {
}

macro_rules! float {
($for:ident, $rep:ident, $is:ident) => {
(
$( #[$docs:meta] )*
struct $for:ident($rep:ty as $is:ty);
) => {
float!(
$for,
$rep,
$is,
1 << (::core::mem::size_of::<$is>() * 8 - 1)
$(#[$docs])*
struct $for($rep as $is, #bits = 1 << (::core::mem::size_of::<$is>() * 8 - 1));
);
};
($for:ident, $rep:ident, $is:ident, $sign_bit:expr) => {
(
$( #[$docs:meta] )*
struct $for:ident($rep:ty as $is:ty, #bits = $sign_bit:expr);
) => {
$(#[$docs])*
#[derive(Copy, Clone)]
pub struct $for($rep);

Expand Down Expand Up @@ -117,27 +122,34 @@ macro_rules! float {
impl<T: Into<$for> + Copy> PartialEq<T> for $for {
#[inline]
fn eq(&self, other: &T) -> bool {
$is::from(*self) == $is::from((*other).into())
<$is>::from(*self) == <$is>::from((*other).into())
}
}

impl<T: Into<$for> + Copy> PartialOrd<T> for $for {
#[inline]
fn partial_cmp(&self, other: &T) -> Option<Ordering> {
$is::from(*self).partial_cmp(&$is::from((*other).into()))
<$is>::from(*self).partial_cmp(&<$is>::from((*other).into()))
}
}

impl ::core::fmt::Debug for $for {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
$is::from(*self).fmt(f)
<$is>::from(*self).fmt(f)
}
}
};
}

float!(F32, u32, f32);
float!(F64, u64, f64);
float! {
/// A NaN preserving `f32` type.
struct F32(u32 as f32);
}

float! {
/// A NaN preserving `f64` type.
struct F64(u64 as f64);
}

impl From<u32> for F32 {
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion wasmi_v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["wasm", "webassembly", "bytecode", "interpreter"]

[dependencies]
wasmparser = { version = "0.83", package = "wasmparser-nostd", default-features = false }
wasmi_core = { version = "0.1", path = "../core", default-features = false }
wasmi_core = { version = "0.2", path = "../core", default-features = false }
spin = { version = "0.9", default-features = false, features = ["mutex", "spin_mutex"] }

[dev-dependencies]
Expand Down

0 comments on commit 2832cbf

Please sign in to comment.