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

make ConstRef based on u32 instead of intx::U24 #727

Merged
merged 13 commits into from
May 29, 2023
1 change: 0 additions & 1 deletion crates/wasmi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ spin = { version = "0.9", default-features = false, features = [
"rwlock",
] }
smallvec = { version = "1.10.0", features = ["union"] }
intx = "0.1.0"

[dev-dependencies]
wat = "1"
Expand Down
7 changes: 3 additions & 4 deletions crates/wasmi/src/engine/const_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ use alloc::{
collections::{btree_map, BTreeMap},
vec::Vec,
};
use intx::U24;
use wasmi_core::UntypedValue;

#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct ConstRef(U24);
pub struct ConstRef(u32);

impl TryFrom<usize> for ConstRef {
type Error = TranslationError;

fn try_from(index: usize) -> Result<Self, Self::Error> {
match U24::try_from(index as u64) {
match u32::try_from(index) {
Ok(index) => Ok(Self(index)),
Err(_) => Err(TranslationError::new(
TranslationErrorInner::ConstRefOutOfBounds,
Expand All @@ -25,7 +24,7 @@ impl TryFrom<usize> for ConstRef {
impl ConstRef {
/// Returns the index of the [`ConstRef`] as `usize` value.
pub fn to_usize(self) -> usize {
u32::from(self.0) as usize
self.0 as usize
}
}

Expand Down