Skip to main content

JitFunction

Struct JitFunction 

Source
pub struct JitFunction<M> {
    pub public_values_stream: Vec<u8>,
    pub memory: M,
    pub hints: Vec<(u64, Vec<u8>)>,
    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).

§memory: M

Memory structure,

§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.

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

Implementations§

Source§

impl<M: JitMemory> JitFunction<M>

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, trace_buf_ptr: *mut u8)

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§

impl<M: JitResetableMemory> JitFunction<M>

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§

Source§

impl<M: Send> Send for JitFunction<M>

Auto Trait Implementations§

§

impl<M> Freeze for JitFunction<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for JitFunction<M>
where M: RefUnwindSafe,

§

impl<M> !Sync for JitFunction<M>

§

impl<M> Unpin for JitFunction<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for JitFunction<M>
where M: UnsafeUnpin,

§

impl<M> UnwindSafe for JitFunction<M>
where M: UnwindSafe,

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