Skip to main content

PvmProgram

Struct PvmProgram 

Source
pub struct PvmProgram {
    pub code: Vec<u8>,
    pub bitmask: Vec<u8>,
    pub jump_table: Vec<u32>,
    pub mem_cycles: u8,
}
Expand description

PVM program for execution.

  • code is the raw byte-encoded PVM bytecode (JAM Gray Paper Appendix A.5).
  • bitmask is the unpacked form (one byte per code position); bitmask[i] == 1 iff a PVM instruction starts at code[i]. Packed bitmasks (1 bit per byte) live only in the serialized blob format upstream; by the time the program reaches this layer the upstream parser has unpacked them.
  • jump_table[i] is the target byte offset within code for a branch / jump whose immediate decodes to i.
  • mem_cycles is the L/S latency tier (see compute_mem_cycles).

Fields§

§code: Vec<u8>§bitmask: Vec<u8>§jump_table: Vec<u32>§mem_cycles: u8

Implementations§

Source§

impl PvmProgram

Source

pub fn new( code: Vec<u8>, bitmask: Vec<u8>, jump_table: Vec<u32>, mem_cycles: u8, ) -> Result<Self, ProgramError>

Construct with validation: bitmask.len() must equal code.len().

Source

pub fn is_insn_start(&self, pc: u32) -> bool

true iff a PVM instruction starts at byte offset pc in code. False if pc is out of range.

Source

pub fn code_len(&self) -> usize

Number of bytecode bytes.

Trait Implementations§

Source§

impl Clone for PvmProgram

Source§

fn clone(&self) -> PvmProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PvmProgram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PvmProgram

Source§

fn eq(&self, other: &PvmProgram) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for PvmProgram

Source§

impl StructuralPartialEq for PvmProgram

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.