pub struct Vm { /* private fields */ }interp only.Expand description
A virtual machine for interpreting Pulley bytecode.
Implementations§
Source§impl Vm
 
impl Vm
Sourcepub fn with_stack(stack_size: usize) -> Self
 
pub fn with_stack(stack_size: usize) -> Self
Create a new virtual machine with the given stack.
Sourcepub fn state(&self) -> &MachineState
 
pub fn state(&self) -> &MachineState
Get a shared reference to this VM’s machine state.
Sourcepub fn state_mut(&mut self) -> &mut MachineState
 
pub fn state_mut(&mut self) -> &mut MachineState
Get an exclusive reference to this VM’s machine state.
Sourcepub unsafe fn call<'a, T>(
    &'a mut self,
    func: NonNull<u8>,
    args: &[Val],
    rets: T,
) -> DoneReason<impl Iterator<Item = Val> + use<'a, T>>where
    T: IntoIterator<Item = RegType> + 'a,
 
pub unsafe fn call<'a, T>(
    &'a mut self,
    func: NonNull<u8>,
    args: &[Val],
    rets: T,
) -> DoneReason<impl Iterator<Item = Val> + use<'a, T>>where
    T: IntoIterator<Item = RegType> + 'a,
Call a bytecode function.
The given func must point to the beginning of a valid Pulley bytecode
function.
The given args must match the number and type of arguments that
function expects.
The given rets must match the function’s actual return types.
Returns either the resulting values, or the PC at which a trap was raised.
Sourcepub unsafe fn call_start<'a>(&'a mut self, args: &[Val]) -> *mut u8
 
pub unsafe fn call_start<'a>(&'a mut self, args: &[Val]) -> *mut u8
Performs the initial part of Vm::call in setting up the args
provided in registers according to Pulley’s ABI.
§Return
Returns the old lr register value. The current lr value is replaced
with a sentinel that triggers a return to the host when returned-to.
§Unsafety
All the same unsafety as call and additionally, you must
invoke call_run and then call_end after calling call_start.
If you don’t want to wrangle these invocations, use call instead
of call_{start,run,end}.
Sourcepub unsafe fn call_end<'a>(
    &'a mut self,
    old_ret: *mut u8,
    rets: impl IntoIterator<Item = RegType> + 'a,
) -> impl Iterator<Item = Val> + 'a
 
pub unsafe fn call_end<'a>( &'a mut self, old_ret: *mut u8, rets: impl IntoIterator<Item = RegType> + 'a, ) -> impl Iterator<Item = Val> + 'a
Sourcepub fn executing_pc(&self) -> &ExecutingPc
 Available on crate feature profile only.
pub fn executing_pc(&self) -> &ExecutingPc
profile only.Gets a handle to the currently executing program counter for this interpreter which can be read from other threads.