Skip to main content

Module ecall

Module ecall 

Source
Expand description

Ecall dispatch.

The Vm impls javm_exec::EcallHandler. The interpreter / JIT invokes handle for every PVM ecall (opcode 3, no immediate) and ecalli imm (opcode 10, u32 immediate). The handler decodes the operation from the immediate and routes to the appropriate sub-dispatcher.

§ecalli opcode encoding (Stage 3 baseline)

The imm value of an ecalli instruction is partitioned by range:

  0          REPLY (kernel-shorthand for "return to caller")
               — driven by run_instance / Interpreter::Halt translation.
  1..=15     MGMT operations (this module).
  16..=63    Kernel-known host calls (this module; sub-stages 3.8 ↑).
  64..       Chain-user host calls (out of scope; reserved).

MGMT operand encoding (register-based, simple flat addressing — single-step root-cnode slot indices):

  Common: φ[7] = src_slot_idx (u8 in low byte)
          φ[8] = dst_slot_idx (u8 in low byte)
  MGMT_COPY        (op=1)   src→dst
  MGMT_MOVE        (op=2)   src→dst
  MGMT_DROP        (op=3)   src
  MGMT_CNODE_SWAP  (op=4)   a=φ[7], b=φ[8]
  MGMT_CNODE_MINT  (op=5)   dst=φ[7], size_log=φ[8] (u8)

Host call operand encoding (Stage 3.8+):

  HOST_YIELD       (op=16)  φ[7] = marker_slot_idx (u8)

After the move to the javm_cap::Cap cache model, ecalls operate on CapHashOrRef targets in the running root cnode and cross-reference into the caller-supplied CacheDirectory for kind dispatch. Vm::drive_and_translate installs a short-lived CachedEcallHandler for interpreter runs, so cache-touching host calls can read/write cap content without storing the cache borrow in the long-lived Vm.

Modules§

host_op
Kernel-known host call opcode space (in the ecalli immediate), 16..=63. Stage 3.8 lands HOST_YIELD; subsequent sub-stages fill the rest.
mgmt_op
MGMT opcode space (in the ecalli immediate).