Skip to main content

JitContext

Struct JitContext 

Source
pub struct JitContext {
    pub pc: u64,
    pub clk: u64,
    pub global_clk: u64,
    pub is_unconstrained: u64,
    /* private fields */
}

Fields§

§pc: u64

The current program counter

§clk: u64

The number of cycles executed.

§global_clk: u64

The number of cycles executed.

§is_unconstrained: u64

This context is in unconstrainted mode. 1 if unconstrained, 0 otherwise.

Implementations§

Source§

impl JitContext

Source

pub unsafe fn trace_mem_access(&self, reads: &[MemValue])

§Safety
  • todo
Source

pub fn enter_unconstrained(&mut self) -> Result<()>

Enter the unconstrained context, this will create a COW memory map of the memory file descriptor.

Source

pub fn exit_unconstrained(&mut self)

Exit the unconstrained context, this will restore the original memory map.

Source

pub unsafe fn trace_hint(&mut self, addr: u64, value: Vec<u8>)

Indicate that the program has read a hint.

This is used to store the hints read by the program.

§Safety
  • The address must be aligned to 8 bytes.
  • The hints pointer must not be mutably aliased.
Source

pub const fn memory(&mut self) -> ContextMemory<'_>

Obtain a mutable view of the emulated memory.

Source

pub const unsafe fn input_buffer(&mut self) -> &mut VecDeque<Vec<u8>>

§Safety
  • The input buffer must be non null and valid to read from.
Source

pub const unsafe fn public_values_stream(&mut self) -> &mut Vec<u8>

§Safety
  • The public values stream must be non null and valid to read from.
Source

pub const fn registers(&self) -> &[u64; 32]

Obtain a view of the registers.

Source

pub const fn rw(&mut self, reg: RiscRegister, val: u64)

Source

pub const fn rr(&self, reg: RiscRegister) -> u64

Source

pub const fn tracing(&self) -> bool

Trait Implementations§

Source§

impl Debug for JitContext

Source§

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

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

impl SyscallContext for JitContext

Source§

fn bump_memory_clk(&mut self)

Used for precompiles that access memory, that need to bump the clk. This increment is local to the precompile, and does not affect the number of cycles the precompile itself takes up.
Source§

fn rr(&self, reg: RiscRegister) -> u64

Read a value from a register.
Source§

fn mr(&mut self, addr: u64) -> u64

Read a value from memory.
Source§

fn mw(&mut self, addr: u64, val: u64)

Write a value to memory.
Source§

fn mr_slice(&mut self, addr: u64, len: usize) -> impl IntoIterator<Item = &u64>

Read a slice of values from memory.
Source§

fn mr_slice_no_trace( &mut self, addr: u64, len: usize, ) -> impl IntoIterator<Item = &u64>

Read a slice of values from memory, without updating the memory clock or tracing the access.
Source§

fn mr_slice_unsafe( &mut self, addr: u64, len: usize, ) -> impl IntoIterator<Item = &u64>

Read a slice of values from memory, without updating the memory clock Note that it still traces the access when tracing is enabled.
Source§

fn mw_slice(&mut self, addr: u64, vals: &[u64])

Write a slice of values to memory.
Source§

fn input_buffer(&mut self) -> &mut VecDeque<Vec<u8>>

Get the input buffer
Source§

fn public_values_stream(&mut self) -> &mut Vec<u8>

Get the public values stream.
Source§

fn enter_unconstrained(&mut self) -> Result<()>

Enter the unconstrained context.
Source§

fn exit_unconstrained(&mut self)

Exit the unconstrained context.
Source§

fn trace_hint(&mut self, addr: u64, value: Vec<u8>)

Trace a hint.
Source§

fn trace_value(&mut self, value: u64)

Trace a dummy value.
Source§

fn mw_hint(&mut self, addr: u64, val: u64)

Write a hint to memory, which is like setting uninitialized memory to a nonzero value The clk will be set to 0, just like for uninitialized memory.
Source§

fn set_exit_code(&mut self, exit_code: u32)

Set the exit code of the program.
Source§

fn is_unconstrained(&self) -> bool

Returns if were in unconstrained mode.
Source§

fn global_clk(&self) -> u64

Get the global clock (total cycles executed).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more