pub struct CoverageMemoryView<'a> { /* private fields */ }Expand description
Zero-copy WASM memory view for coverage (Muda elimination)
Provides direct access to coverage counters stored in WASM linear memory. Counters are stored as little-endian u64 values.
Implementations§
Source§impl<'a> CoverageMemoryView<'a>
impl<'a> CoverageMemoryView<'a>
Sourcepub fn new(memory: &'a [u8], counter_base: usize, block_count: usize) -> Self
pub fn new(memory: &'a [u8], counter_base: usize, block_count: usize) -> Self
Create a new memory view
§Arguments
memory- Reference to WASM linear memorycounter_base- Byte offset where counters startblock_count- Number of blocks/counters
Sourcepub fn read_counter(&self, block: BlockId) -> u64
pub fn read_counter(&self, block: BlockId) -> u64
Read counter without copy (Genchi Genbutsu)
Directly reads the u64 counter value for the given block.
Sourcepub fn read_all_counters(&self) -> Vec<u64>
pub fn read_all_counters(&self) -> Vec<u64>
SIMD batch read all counters
Reads all counters at once. In a full implementation, this would use Trueno’s SIMD operations for acceleration.
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Get the number of blocks being tracked
Sourcepub fn counter_base(&self) -> usize
pub fn counter_base(&self) -> usize
Get the counter base offset
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
Get the total memory size
Sourcepub fn is_covered(&self, block: BlockId) -> bool
pub fn is_covered(&self, block: BlockId) -> bool
Check if a block is covered (counter > 0)
Sourcepub fn covered_count(&self) -> usize
pub fn covered_count(&self) -> usize
Count the number of covered blocks
Sourcepub fn coverage_percent(&self) -> f64
pub fn coverage_percent(&self) -> f64
Calculate coverage percentage
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for CoverageMemoryView<'a>
impl<'a> RefUnwindSafe for CoverageMemoryView<'a>
impl<'a> Send for CoverageMemoryView<'a>
impl<'a> Sync for CoverageMemoryView<'a>
impl<'a> Unpin for CoverageMemoryView<'a>
impl<'a> UnsafeUnpin for CoverageMemoryView<'a>
impl<'a> UnwindSafe for CoverageMemoryView<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more