Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Instruction Set

The AVM instruction set is organized into composable layers. Each layer adds capabilities on top of the previous one.

Layer hierarchy

Each layer is additive — a program that only uses Layer 0 instructions is still a valid Layer 4 program.

graph BT
    L0[Layer 0: Objects + Introspect] --> L1[Layer 1: + Transactions]
    L1 --> L2[Layer 2: + Pure Functions]
    L2 --> L3[Layer 3: + Distribution]
    L3 --> L4[Layer 4: + Constraints]

Layer 0 — Objects and Introspection

InstructionReturnsDescription
create_obj(name, ctrl?)ObjectIdCreate object from behavior name
destroy_obj(id)BoolMark object for destruction
call(id, input)Maybe OutputSynchronous message call
receive()Maybe InputReceive next message
get_self()ObjectIdCurrent object’s ID
get_input()InputCurrent input message
get_state()List ValObject’s internal state
set_state(vals)()Replace internal state
get_sender()Maybe ObjectIdCaller’s ID
get_current_machine()MachineIdPhysical machine

Layer 1 — Transactions

InstructionReturnsDescription
begin_tx(ctrl?)TxIdStart a transaction
commit_tx(id)BoolValidate and apply atomically
abort_tx(id)()Discard all pending changes

Layer 2 — Pure Functions

InstructionReturnsDescription
call_pure(name, args)Maybe ValCall a named pure function

Layer 3 — Distribution

InstructionReturnsDescription
get_machine(id)Maybe MachineIdObject’s physical location
teleport(machine)BoolMove execution
move_object(id, machine)BoolMove object data
fetch(id)BoolBring replica locally
get_controller(id)Maybe ControllerIdObject’s controller
transfer_object(id, ctrl)BoolTransfer ownership
freeze(id)Maybe BoolSynchronize replicas

Layer 4 — Constraints (stub)

Finite-domain constraint variables and nondeterministic choice. Not yet implemented in the interpreter.

Safety

In the Agda specification, instructions are classified as Safe or Unsafe. Unsafe instructions (reflection, reifyTxState, registerPure) bypass encapsulation. The Rust implementation tracks this at the type level through the instruction enum structure.