Skip to main content

JitHook

Trait JitHook 

Source
pub trait JitHook: Send {
    // Required method
    fn try_call(
        &mut self,
        fn_id: u32,
        args: &[Value],
    ) -> Result<Option<Value>, VmError>;
}
Expand description

Hook into the VM dispatch loop for Op::Call.

See the module docs for the contract.

Required Methods§

Source

fn try_call( &mut self, fn_id: u32, args: &[Value], ) -> Result<Option<Value>, VmError>

The dispatch loop has just verified refinements and missed the memo cache for fn_id. The arguments are at the top of the value stack — args is a borrowed view; do not mutate.

Return:

  • Ok(Some(v)) — hook handled the call; the dispatcher will pop args.len() values from the stack, push v, emit the synthetic exit_ok trace event, and continue.
  • Ok(None) — hook declines; the dispatcher proceeds with normal frame setup as if the hook weren’t installed.
  • Err(e) — JITed code raised an error. The dispatcher surfaces it as the call’s error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§