#[repr(C)]pub struct Context {Show 14 fields
pub regs: [u32; 32],
pub pc: u32,
pub next_pc: u32,
pub mem: ForkableMemory,
pub trace_buf: MmapOffset,
pub ecall_handler: extern "C" fn(NonNull<Context>),
pub ebreak_handler: extern "C" fn(NonNull<Context>),
pub undefined_handler: extern "C" fn(NonNull<Context>, u32),
pub trace_handler: extern "C" fn(NonNull<Context>),
pub trampoline: extern "C" fn(NonNull<Context>) -> JitFn,
pub addition: NonNull<dyn Addition>,
pub compiler: Box<dyn Compiler>,
pub compile_cfg: CompileConfig,
pub exit_code: Option<u32>,
/* private fields */
}Expand description
The Context for the zkVMc runtime.
Fields§
§regs: [u32; 32]Registers.
pc: u32Program Counter.
next_pc: u32Next Program Counter.
mem: ForkableMemoryLinear memory between VM and JIT code.
trace_buf: MmapOffsetTrace buffer for tracing the instructions.
ecall_handler: extern "C" fn(NonNull<Context>)Handler function for the ecall instruction.
ebreak_handler: extern "C" fn(NonNull<Context>)Handler function for the ebreak instruction.
undefined_handler: extern "C" fn(NonNull<Context>, u32)Handler function for an undefined instruction.
trace_handler: extern "C" fn(NonNull<Context>)Handler function for the execution traces.
trampoline: extern "C" fn(NonNull<Context>) -> JitFnFunction called by compiled code or VM to lookup or translate the next compiled code block.
addition: NonNull<dyn Addition>Additional context.
compiler: Box<dyn Compiler>Compile the code block at pc and return the compiled function.
compile_cfg: CompileConfig§exit_code: Option<u32>Exit code of the program.
Implementations§
Source§impl Context
impl Context
pub fn new( compiler: Option<Box<dyn Compiler>>, entry: u32, image: FxHashMap<u32, &[u8]>, addition: NonNull<dyn Addition>, cfg: Option<CompileConfig>, ecall_handler: Option<extern "C" fn(NonNull<Context>)>, ebreak_handler: Option<extern "C" fn(NonNull<Context>)>, undefined_handler: Option<extern "C" fn(NonNull<Context>, u32)>, interrupt_handler: Option<extern "C" fn(NonNull<Context>)>, ) -> Context
pub fn update_pc(&mut self)
pub fn write_bytes(&mut self, addr: u32, bytes: &[u8])
pub fn write_word(&mut self, addr: u32, word: u32)
pub fn write_words(&mut self, addr: u32, words: &[u32])
pub fn read_bytes(&self, addr: u32, len: usize) -> &[u8] ⓘ
pub fn read_word(&self, addr: u32) -> u32
pub fn read_words(&self, addr: u32, len: usize) -> &[u32]
pub fn as_addition<T>(&self) -> &T
pub fn as_addition_mut<T>(&mut self) -> &mut T
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl !Unpin for Context
impl !UnwindSafe for Context
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