/// Writes from heap to stable memory.
///
/// Supports bigger stable memory indexed by 64 bit pointers.
Writes from heap to stable memory.
Supports bigger stable memory indexed by 64 bit pointers.
Writes from heap to stable memory . Supports bigger stable memory indexed by 64 bit pointers .
pub(super) fn stable64_write(
        &mut self,
        offset: u64,
        src: u64,
        size: u64,
        heap: &[u8],
    ) -> HypervisorResult<()> {
        let (src, offset, size) = (src as usize, offset as usize, size as usize);
        let (stable_memory_size_in_bytes, overflow) = self
            .stable64_size()?
            .overflowing_mul(WASM_PAGE_SIZE_IN_BYTES as u64);
        if overflow {
            return Err(HypervisorError::Trapped(StableMemoryOutOfBounds));
        }
        let (stable_memory_end, overflow) = offset.overflowing_add(size);
        if overflow || stable_memory_end > stable_memory_size_in_bytes as usize {
            return Err(HypervisorError::Trapped(StableMemoryOutOfBounds));
        }
        let (heap_end, overflow) = src.overflowing_add(size);
        if overflow || heap_end > heap.len() {
            return Err(HypervisorError::Trapped(HeapOutOfBounds));
        }
        self.stable_memory_buffer
            .write(&heap[src..heap_end], offset);
        Ok(())
    }
pub ( super ) fn stable64_write ( & mut self , offset : u64 , src : u64 , size : u64 , heap : & [ u8 ] , ) -> HypervisorResult < ( ) > { let ( src , offset , size ) = ( src as usize , offset as usize , size as usize ) ; let ( stable_memory_size_in_bytes , overflow ) = self . stable64_size ( ) ? . overflowing_mul ( WASM_PAGE_SIZE_IN_BYTES as u64 ) ; if overflow { return Err ( HypervisorError :: Trapped ( StableMemoryOutOfBounds ) ) ; } let ( stable_memory_end , overflow ) = offset . overflowing_add ( size ) ; if overflow || stable_memory_end > stable_memory_size_in_bytes as usize { return Err ( HypervisorError :: Trapped ( StableMemoryOutOfBounds ) ) ; } let ( heap_end , overflow ) = src . overflowing_add ( size ) ; if overflow || heap_end > heap . len ( ) { return Err ( HypervisorError :: Trapped ( HeapOutOfBounds ) ) ; } self . stable_memory_buffer . write ( & heap [ src .. heap_end ] , offset ) ; Ok ( ( ) ) }
Writes from heap to stable memory.
Writes from heap to stable memory .
&mut self
offset
u64
src
u64
size
u64
heap
&[u8]