Skip to content

Commit

Permalink
make ConstRef based on u32 instead of intx::U24 (#727)
Browse files Browse the repository at this point in the history
* make ConstRef based on u32

This allows us to remove intx dependency.

* add some inline annotations

* use inline instead

* get rid of experimental inline annotations

* experiment with more inlines

* experimental removal of inline

* cleanup code

* remove inline for view method

* remove inline (experimental)

* add #[repr(transparent)]

* add another inline attempt

* remove bad inline

* remove #[repr(transparent)] again
  • Loading branch information
Robbepop authored May 29, 2023
1 parent 4fb164c commit 799995d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
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

0 comments on commit 799995d

Please sign in to comment.