Skip to main content

JitFunction

Struct JitFunction 

Source
pub struct JitFunction {
    pub public_values_stream: Vec<u8>,
    pub hints: Vec<(u64, Vec<u8>)>,
    pub memory: MmapMut,
    pub pc: u64,
    pub registers: [u64; 32],
    pub clk: u64,
    pub global_clk: u64,
    pub exit_code: u32,
    pub debug_sender: Option<SyncSender<Option<State>>>,
    /* private fields */
}
Expand description

A type representing a JIT compiled function.

The underlying function should be of the form [fn(*mut JitContext)].

Fields§

§public_values_stream: Vec<u8>

A stream of public values from the program (global to entire program).

§hints: Vec<(u64, Vec<u8>)>

During execution, the hints are read by the program, and we store them here. This is effectively a mapping from start address to the value of the hint.

§memory: MmapMut

The JIT function may stop “in the middle” of an program, we want to be able to resume it, so this is the information needed to do so.

§pc: u64§registers: [u64; 32]§clk: u64§global_clk: u64§exit_code: u32§debug_sender: Option<SyncSender<Option<State>>>

Implementations§

Source§

impl JitFunction

Source

pub fn with_initial_memory_image(&mut self, memory: Arc<HashMap<u64, u64>>)

Write the initial memory image to the JIT memory.

§Panics

Panics if the PC is not the starting PC.

Source

pub fn push_input(&mut self, input: Vec<u8>)

Push an input to the input buffer.

§Panics

Panics if the PC is not the starting PC.

Source

pub fn set_input_buffer(&mut self, input: VecDeque<Vec<u8>>)

Set the entire input buffer.

§Panics

Panics if the PC is not the starting PC.

Source

pub unsafe fn call(&mut self) -> Option<TraceChunkRaw>

Call the function, returning the trace buffer, starting at the starting PC of the program.

If the PC is 0, then the program has completed and we return None.

§SAFETY

Relies on the builder to emit valid assembly and that the pointer is valid for the duration of the function call.

Source

pub fn reset(&mut self)

Reset the JIT function to the initial state.

This will clear the registers, the program counter, the clock, and the memory, restoring the initial memory image.

Trait Implementations§

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