pub struct Vm<K: KernelAssist> {
pub stack: CallStack,
pub kernel_assist: K,
pub image_cache: ImageCache,
}Expand description
The v3 VM driver. Parameterized over a KernelAssist impl so the
integration crate can be tested with the in-process default while
jar-kernel-v3 swaps in a σ-aware implementation.
Fields§
§stack: CallStack§kernel_assist: K§image_cache: ImageCacheImplementations§
Source§impl<K: KernelAssist> Vm<K>
impl<K: KernelAssist> Vm<K>
pub fn new(kernel_assist: K) -> Self
pub fn with_max_depth(kernel_assist: K, max_depth: usize) -> Self
Sourcepub fn invoke_cached(
&mut self,
cache: &mut CacheDirectory,
instance_hash: CapHash,
endpoint_idx: u8,
args: [u64; 4],
gas_budget: u64,
) -> Result<CallResult, VmError>
pub fn invoke_cached( &mut self, cache: &mut CacheDirectory, instance_hash: CapHash, endpoint_idx: u8, args: [u64; 4], gas_budget: u64, ) -> Result<CallResult, VmError>
CacheDirectory-driven entry point: look up a published Cap::Instance
in cache by hash, pull its referenced Cap::Image from the
same cache, predecode bytecode (cached by image_hash), seed
regs + memory + gas, push a working InstanceEntry, drive the
interpreter to a termination.
The cache stays caller-owned and is borrowed for the duration of the call (host calls walk back through it to resolve nested cap targets).
Sourcepub fn call_resume(
&mut self,
cache: &mut CacheDirectory,
scratchpad: Option<CapHashOrRef>,
) -> Result<CallResult, VmError>
pub fn call_resume( &mut self, cache: &mut CacheDirectory, scratchpad: Option<CapHashOrRef>, ) -> Result<CallResult, VmError>
Resume the top ReferenceEntry: pop it, re-enter the
interpreter on the InstanceEntry it points at (which already
has its saved regs/mem/gas from the yield site), and translate
the next termination.
Optionally reflects scratchpad into the resumed Instance’s
slot[0] before re-entering — the spec’s CALL_RESUME(payload)
pattern.
Errors:
VmError::Invariantif the top isn’t aReferenceEntry.VmError::CallStackEmptyif the resolved target Instance is missing.
Sourcepub fn drop_paused(&mut self, _target_slot: SlotPath) -> Result<(), VmError>
pub fn drop_paused(&mut self, _target_slot: SlotPath) -> Result<(), VmError>
Stub for DROP_PAUSED. Lands with the σ-resident Paused state machine (Stage 4).