Skip to content

Commit

Permalink
style: split validate_memory_access to avoid warnings in the releas…
Browse files Browse the repository at this point in the history
…e profile (#353)
  • Loading branch information
dlubarov authored Mar 8, 2024
1 parent 21ff9e4 commit c22dc58
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ use std::rc::Rc;
use std::sync::Arc;
pub use syscall::*;

use p3_baby_bear::BabyBear;
use p3_field::AbstractField;

use self::state::ExecutionState;

#[derive(Copy, Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -167,8 +164,11 @@ impl Runtime {
}

#[inline]
#[cfg(debug_assertions)]
fn validate_memory_access(&self, addr: u32, position: AccessPosition) {
#[cfg(debug_assertions)]
use p3_baby_bear::BabyBear;
use p3_field::AbstractField;

if position == AccessPosition::Memory {
assert_eq!(addr % 4, 0, "addr is not aligned");
let _ = BabyBear::from_canonical_u32(addr);
Expand All @@ -178,6 +178,9 @@ impl Runtime {
}
}

#[cfg(not(debug_assertions))]
fn validate_memory_access(&self, _addr: u32, _position: AccessPosition) {}

pub fn mr(&mut self, addr: u32, shard: u32, clk: u32) -> MemoryReadRecord {
// Get the memory entry.
let memory_entry = self.state.memory.entry(addr);
Expand Down

0 comments on commit c22dc58

Please sign in to comment.