Skip to main content

verify

Function verify 

Source
pub fn verify(chunk: &Chunk) -> Result<(), VerifyError>
Expand description

Verify structural invariants of chunk. See VerifyError for what is checked. This does not perform full dataflow/register-liveness verification (unlike, say, the JVM verifier) — v0 trades that off against implementation complexity, and instead the VM bounds-checks register indices at runtime (cheap: it’s an array index against a fixed small register file, not worth statically proving away yet).

The one register fact that is settled statically is VerifyError::ArityExceedsRegisters. It belongs here rather than in the VM because it is a property of the function table, not of an execution: such a function cannot be entered at all, so letting it reach the interpreter only moves the same rejection later and per call.

Opcode::CallNative targets are deliberately not range-checked here: native functions live in a byteflow_vm::NativeTable supplied by the embedder at Vm construction time, entirely outside this crate’s (and this Chunk’s) knowledge. An out-of-range CallNative is instead caught at runtime as Fault::BadNative.