Skip to content

Commit

Permalink
inline more
Browse files Browse the repository at this point in the history
  • Loading branch information
joonazan committed Aug 22, 2024
1 parent fa11e78 commit 6811a52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/instruction_handlers/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ pub trait PtrOp: OpcodeType {
}

impl PtrOp for PointerAdd {
#[inline(always)]
fn perform(in1: U256, in2: U256) -> Option<U256> {
ptr_add_sub::<true>(in1, in2)
}
}

impl PtrOp for PointerSub {
#[inline(always)]
fn perform(in1: U256, in2: U256) -> Option<U256> {
ptr_add_sub::<false>(in1, in2)
}
Expand All @@ -80,6 +82,7 @@ fn ptr_add_sub<const IS_ADD: bool>(mut in1: U256, in2: U256) -> Option<U256> {
}

impl PtrOp for PointerPack {
#[inline(always)]
fn perform(in1: U256, in2: U256) -> Option<U256> {
if in2.low_u128() != 0 {
None
Expand All @@ -90,6 +93,7 @@ impl PtrOp for PointerPack {
}

impl PtrOp for PointerShrink {
#[inline(always)]
fn perform(mut in1: U256, in2: U256) -> Option<U256> {
let pointer: &mut FatPointer = (&mut in1).into();
pointer.length = pointer.length.checked_sub(in2.low_u32())?;
Expand Down
4 changes: 4 additions & 0 deletions src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl Stack {
unsafe { Box::from_raw(alloc_zeroed(Layout::new::<Stack>()).cast::<Stack>()) }
}

#[inline(always)]
pub(crate) fn get(&self, slot: u16) -> U256 {
self.slots[slot as usize]
}
Expand All @@ -46,14 +47,17 @@ impl Stack {
self.pointer_flags = Default::default();
}

#[inline(always)]
pub(crate) fn get_pointer_flag(&self, slot: u16) -> bool {
self.pointer_flags.get(slot)
}

#[inline(always)]
pub(crate) fn set_pointer_flag(&mut self, slot: u16) {
self.pointer_flags.set(slot);
}

#[inline(always)]
pub(crate) fn clear_pointer_flag(&mut self, slot: u16) {
self.pointer_flags.clear(slot);
}
Expand Down

0 comments on commit 6811a52

Please sign in to comment.