pub struct PageBytes {
pub hash: CapHash,
pub bytes: Vec<u8>,
}Expand description
One page’s bytes plus its precomputed content hash.
Sharing across DataCap CoW clones is via PageRef (= Arc),
which carries its own refcount — PageBytes itself is not
refcounted.
Clone and rkyv Deserialize are hand-written to preserve the
PAGE_SIZE-alignment invariant of bytes: the recompiler resolves a
page’s physical address from its slab pointer and direct-maps it into a
ring-3 page table (pt_map_leaf requires a page-aligned PA). The derived
Clone / Deserialize would Vec-allocate bytes at alignment 1, so a
cloned or wire-decoded page would land mid-page and the recompiler would map
the wrong physical frame. Both re-allocate through
super::data::alloc_page_aligned_zeroed. (Mirrors the page-alignment
discipline the legacy DataContent::Inline kept in its manual Clone.)
Fields§
§hash: CapHash§bytes: Vec<u8>Implementations§
Source§impl PageBytes
impl PageBytes
Sourcepub fn from_content(content: &[u8]) -> Self
pub fn from_content(content: &[u8]) -> Self
Build a PageBytes from up to PAGE_SIZE content bytes: a
PAGE_SIZE-aligned slab (zero-padded tail) plus the precomputed
content hash (super::data::page_content_hash). The slab alignment is
load-bearing — the recompiler maps the page’s slab directly into a
ring-3 page table.
Sourcepub fn from_page_copy_unhashed(src: &[u8]) -> Self
pub fn from_page_copy_unhashed(src: &[u8]) -> Self
Build a PageBytes from up to PAGE_SIZE source bytes without
computing the content hash: a PAGE_SIZE-aligned slab (zero-padded
tail) carrying a [0u8; 32] sentinel hash.
Used by the x86 recompiler’s ring-0 copy-on-write page-fault handler,
which inserts the fresh page straight into a super::data::DataCap
overlay. Overlay pages are never hashed before
super::data::DataCap::flush (which rebuilds each page via
Self::from_content, recomputing the real hash and re-asserting the
substitution invariant), so keeping SHA-256 out of the #PF path keeps
the per-page CoW gas charge identical between the interpreter and the
recompiler. The slab is still PAGE_SIZE-aligned — load-bearing for
the direct ring-3 PT map.
Trait Implementations§
Source§impl Archive for PageBytes
impl Archive for PageBytes
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedPageBytes
type Archived = ArchivedPageBytes
Source§type Resolver = PageBytesResolver
type Resolver = PageBytesResolver
Source§impl<D: Fallible + ?Sized> Deserialize<PageBytes, D> for ArchivedPageBytes
impl<D: Fallible + ?Sized> Deserialize<PageBytes, D> for ArchivedPageBytes
Source§impl Encode for PageBytes
impl Encode for PageBytes
Source§fn is_ssz_fixed_len() -> bool
fn is_ssz_fixed_len() -> bool
true iff this type is fixed-length (no variable-length fields).Source§fn ssz_fixed_len() -> usize
fn ssz_fixed_len() -> usize
BYTES_PER_LENGTH_OFFSET] (i.e. the size of the offset slot).Source§fn ssz_bytes_len(&self) -> usize
fn ssz_bytes_len(&self) -> usize
self when serialized.Source§fn ssz_append(&self, buf: &mut Vec<u8>)
fn ssz_append(&self, buf: &mut Vec<u8>)
self to buf.§fn is_basic_type() -> bool
fn is_basic_type() -> bool
true for “basic” SSZ types (uintN, bool), which pack adjacent
elements into shared 32-byte chunks for merkleization. Composite
types (containers, lists, structs) return false (the default).§fn as_ssz_bytes(&self) -> Vec<u8> ⓘ
fn as_ssz_bytes(&self) -> Vec<u8> ⓘ
Vec<u8> allocated through the global allocator.Auto Trait Implementations§
impl Freeze for PageBytes
impl RefUnwindSafe for PageBytes
impl Send for PageBytes
impl Sync for PageBytes
impl Unpin for PageBytes
impl UnsafeUnpin for PageBytes
impl UnwindSafe for PageBytes
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read more