Expand description
Experimental staged bytecode VM for the Rust runtime (issue #195).
Milestone 4 compiles literals, lexical locals, arithmetic,
comparisons, if, do, let, loop/recur, fn closures
(including variadic), exceptions, and the registry-direct global
forms (def, defn single- and multi-arity, var, set!,
declare, defstruct, field, instance?) into a typed
instruction program and executes it on a stack machine (issue #223).
See notes/rust-bytecode-vm.md for the design.
The main hara-wasm crate enables bytecode-vm in its default feature
set. VM entry points remain feature-gated for compiler-free and minimal
builds, while live snapshots and one-boundary stepping are separately
opt-in through bytecode-observation. The VM never falls back to the
tree-walking evaluator: unsupported forms are typed compile errors.
Re-exports§
pub use artifact::decode_program;pub use artifact::encode_program;pub use bundle::compile_bytecode_bundle;pub use bundle::compile_embedded_cli_bundle;pub use bundle::compile_embedded_foundation_bootstrap_bundle;pub use bundle::compile_embedded_standard_library_bundle;pub use bundle::compile_package_bytecode_bundle;pub use bundle::decode_bytecode_bundle;pub use bundle::embedded_cli_sources;pub use bundle::embedded_foundation_bootstrap_sources;pub use bundle::encode_bytecode_bundle;pub use bundle::eval_bytecode_bundle;pub use bundle::eval_eager_bytecode_bundle_with_registries;pub use bundle::BytecodeBundleModule;pub use bundle::ModuleSource;pub use compiler::compile_form_with_config_allow_unbound_globals;pub use compiler::compile_halc_module;pub use compiler::compile_source;pub use compiler::compile_source_with;pub use compiler::compile_source_with_allow_unbound_globals;pub use compiler::compile_source_with_config;pub use compiler::compile_source_with_config_allow_unbound_globals;pub use compiler::compile_spanned_form_with_config_allow_unbound_globals;pub use compiler::compile_spanned_forms_with_config_allow_unbound_globals;pub use compiler::source_namespace_config;pub use compiler::source_uses_dynamic_evaluation;pub use disassemble::disassemble;pub use error::CompileError;pub use error::CompileErrorKind;pub use error::ValidationError;pub use error::VmError;pub use fiber::VmFiber;pub use fiber::VmFiberState;pub use machine::instrumentation::BytecodeMetrics;pub use machine::instrumentation::CounterProbe;pub use machine::instrumentation::EventRing;pub use machine::instrumentation::InstructionEvent;pub use machine::instrumentation::NoProbe;pub use machine::instrumentation::Opcode;pub use machine::instrumentation::OpcodeCount;pub use machine::instrumentation::SampledProbe;pub use machine::instrumentation::TerminalEvent;pub use machine::instrumentation::TerminalKind;pub use machine::instrumentation::TransitionEvent;pub use machine::instrumentation::TransitionKind;pub use machine::instrumentation::VmEvent;pub use machine::instrumentation::VmProbe;pub use machine::instrumentation::BYTECODE_EVENTS_SCHEMA;pub use machine::instrumentation::BYTECODE_METRICS_SCHEMA;pub use machine::execute_program;pub use machine::execute_program_with_globals;pub use machine::Machine;pub use machine::VmOutcome;pub use opcode::Instruction;pub use prepared::prepare_call;pub use prepared::PreparedCall;pub use program::FunctionId;pub use program::FunctionPrototype;pub use program::Program;pub use validate::validate;
Modules§
- artifact
- Alpha persistent encoding for validated VM programs.
- bundle
- Deterministic indexed container for the embedded Foundation bootstrap.
- compiler
- Compiler:
Formtrees (with parser spans) to a validatedProgram. - disassemble
- Deterministic human-readable disassembler. Used in tests and in benchmark diagnostics.
- error
- Error types for the experimental bytecode VM.
- fiber
- frame
- One execution frame: the local slot array plus its operand-stack base.
- machine
- The synchronous stack machine.
- opcode
- Typed instruction set for the experimental bytecode VM.
- prepared
- Prepare-once callable dispatch through a stable namespace Var.
- program
- Program representation for the experimental bytecode VM.
- source_
map - Per-instruction source positions for diagnostics and the disassembler.
- validate
- Program validation: one abstract-interpretation pass over the code vector before any execution. After validation the machine indexes without re-checking, and malformed programs never reach a panic.
Functions§
- eval_
source - Compiles, validates, and executes a closed source string in one step. Errors from either stage flatten to their display form (which carries source positions). No fallback to the tree-walking evaluator.