Bytecode & Tools

← Back to Language Guide

This is the task-oriented companion to the reference docs Compiler and Bytecode VM. It covers everyday workflows: compiling, running, inspecting bytecode, and tracing a function from source to Call opcode.


Compile vs interpret

etai program.eta              # parse, compile, run in one step
etac program.eta -o out.etac  # compile only
etai out.etac                 # run pre-compiled bytecode

.etac files are a self-contained serialised form of a module: bytecode, constants, debug spans, and the symbol table.

WorkflowWhen to use
etai source.etaIteration, scripts, REPL development
etac -O … && etai …Production / benchmark runs
Ship .etacDistribute binaries without source

Optimisation

etac -O runs the standard pass set:

See Optimisations for the full pass list and heuristics.


Inspecting bytecode

etac --disasm program.eta

Emits a per-function listing of opcodes with PCs, source spans, and constants. Use this to verify TCO, look for missing inlining, or correlate a profiler hot spot with its source.

Tip

A useful pre-flight check for tight loops: search the disassembly for Call in your loop body — every recursive iteration should be TailCall. See Tail Calls.


Inspecting macro expansions

etac --dump-expand program.eta

Prints the source after macro expansion, before bytecode emission — useful for hygiene problems and ellipsis debugging. See Macros.


Reading a .etac file

SectionContents
HeaderMagic, version, target triple
Symbol tableModule exports and import resolutions
Constant poolAll literal values
FunctionsPer-function bytecode + upvalue layout
Debug spans(file-id, start-line, start-col, end-line, end-col) per opcode

etai validates the header on load and refuses mismatched versions.


Common opcodes

OpcodePurpose
LoadConstPush a constant from the pool
Load / StoreLocal slot read / write
LoadUp / StoreUpUpvalue read / write
Call / TailCallFunction call (the latter reuses the frame)
ReturnPop frame and return
Jump, JumpIfFalseUnconditional / conditional branches
SetupCatch, ThrowException handler frame; raise
Unify, BindVarLogic-engine primitives

The complete opcode set is in Bytecode VM.


Build-time vs run-time errors

PhaseExamples
CompileParse error, macro expansion error, undefined export, arity mismatch on define
LinkMissing module on the search path
Runtimeruntime.type-error, runtime.invalid-arity, user raise

Compile and link errors are reported with full source spans; runtime errors carry a span and a stack trace as the exception payload — see Error Handling.


Profiling tips