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

chore: make memory-limit private #796

Merged
merged 2 commits into from Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 19 additions & 18 deletions crates/interpreter/src/interpreter/shared_memory.rs
Expand Up @@ -22,24 +22,7 @@ pub struct SharedMemory {
current_len: usize,
/// Memory limit. See [`crate::CfgEnv`].
#[cfg(feature = "memory_limit")]
pub memory_limit: u64,
}

impl fmt::Debug for SharedMemory {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SharedMemory")
.field(
"current_slice",
&crate::primitives::hex::encode(self.context_memory()),
)
.finish()
}
}

impl Default for SharedMemory {
fn default() -> Self {
Self::new()
}
memory_limit: u64,
}

impl SharedMemory {
Expand Down Expand Up @@ -250,6 +233,24 @@ impl SharedMemory {
}
}

impl fmt::Debug for SharedMemory {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SharedMemory")
.field("current_len", &self.current_len)
.field(
"context_memory",
&crate::primitives::hex::encode(self.context_memory()),
)
.finish_non_exhaustive()
}
}

impl Default for SharedMemory {
fn default() -> Self {
Self::new()
}
}

/// Rounds up `x` to the closest multiple of 32. If `x % 32 == 0` then `x` is returned.
#[inline]
pub fn next_multiple_of_32(x: usize) -> Option<usize> {
Expand Down