pub struct JitContext {
pub pc: u64,
pub clk: u64,
pub global_clk: u64,
pub is_unconstrained: u64,
/* private fields */
}Fields§
§pc: u64The current program counter
clk: u64The number of cycles executed.
global_clk: u64The number of cycles executed.
is_unconstrained: u64This context is in unconstrainted mode. 1 if unconstrained, 0 otherwise.
Implementations§
Source§impl JitContext
impl JitContext
Sourcepub unsafe fn trace_mem_access(&self, reads: &[MemValue])
pub unsafe fn trace_mem_access(&self, reads: &[MemValue])
§Safety
- todo
Sourcepub fn enter_unconstrained(&mut self) -> Result<()>
pub fn enter_unconstrained(&mut self) -> Result<()>
Enter the unconstrained context, this will create a COW memory map of the memory file descriptor.
Sourcepub fn exit_unconstrained(&mut self)
pub fn exit_unconstrained(&mut self)
Exit the unconstrained context, this will restore the original memory map.
Sourcepub unsafe fn trace_hint(&mut self, addr: u64, value: Vec<u8>)
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.
Sourcepub const fn memory(&mut self) -> ContextMemory<'_>
pub const fn memory(&mut self) -> ContextMemory<'_>
Obtain a mutable view of the emulated memory.
Sourcepub const unsafe fn input_buffer(&mut self) -> &mut VecDeque<Vec<u8>>
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.
Sourcepub const unsafe fn public_values_stream(&mut self) -> &mut Vec<u8> ⓘ
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.
pub const fn rw(&mut self, reg: RiscRegister, val: u64)
pub const fn rr(&self, reg: RiscRegister) -> u64
pub const fn tracing(&self) -> bool
Trait Implementations§
Source§impl Debug for JitContext
impl Debug for JitContext
Source§impl SyscallContext for JitContext
impl SyscallContext for JitContext
Source§fn bump_memory_clk(&mut self)
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
fn rr(&self, reg: RiscRegister) -> u64
Read a value from a register.
Source§fn mr_slice(&mut self, addr: u64, len: usize) -> impl IntoIterator<Item = &u64>
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>
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>
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 enter_unconstrained(&mut self) -> Result<()>
fn enter_unconstrained(&mut self) -> Result<()>
Enter the unconstrained context.
Source§fn exit_unconstrained(&mut self)
fn exit_unconstrained(&mut self)
Exit the unconstrained context.
Source§fn trace_value(&mut self, value: u64)
fn trace_value(&mut self, value: u64)
Trace a dummy value.
Source§fn mw_hint(&mut self, addr: u64, val: u64)
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)
fn set_exit_code(&mut self, exit_code: u32)
Set the exit code of the program.
Source§fn is_unconstrained(&self) -> bool
fn is_unconstrained(&self) -> bool
Returns if were in unconstrained mode.
Source§fn global_clk(&self) -> u64
fn global_clk(&self) -> u64
Get the global clock (total cycles executed).
Auto Trait Implementations§
impl Freeze for JitContext
impl RefUnwindSafe for JitContext
impl !Send for JitContext
impl !Sync for JitContext
impl Unpin for JitContext
impl UnsafeUnpin for JitContext
impl UnwindSafe for JitContext
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