Skip to content

Conversation

@dylon
Copy link
Collaborator

@dylon dylon commented Dec 27, 2025

Summary

Add bytecode VM for Tier 1 compilation:

  • Stack-based virtual machine
  • Opcode dispatch and execution
  • Environment and space operation handlers
  • Arithmetic and comparison implementations

Part of Stacked PR Series

This is PR #17 in a 28-PR stacked series implementing the bytecode VM and JIT compiler.
Base: pr16/eval-builtins-space
Next: pr18/jit-dependencies


This PR series implements tiered compilation: tree-walker → bytecode VM → JIT native code

@dylon dylon force-pushed the pr16/eval-builtins-space branch from 33af780 to 0acd655 Compare December 27, 2025 04:01
@dylon dylon force-pushed the pr16/eval-builtins-space branch from 0acd655 to fe21892 Compare December 27, 2025 17:31
dylon and others added 2 commits December 27, 2025 13:26
Add a stack-based bytecode VM for faster execution of compiled MeTTa code.

The VM module is organized by functionality:
- types.rs: Core types (VmError, VmConfig, CallFrame, BindingFrame, ChoicePoint)
- pattern.rs: Pattern matching helpers for unification
- stack.rs: Stack manipulation operations (push, pop, dup, swap, rot3, over)
- arithmetic.rs: Arithmetic operations (+, -, *, /, %)
- comparison.rs: Comparison operations (<, <=, >, >=, ==, !=)
- value_ops.rs: Value creation and variable binding operations
- control_flow.rs: Jumps, calls, returns, and call stack management
- nondeterminism.rs: Fork, fail, choice points for backtracking
- expression_ops.rs: Expression manipulation (car, cdr, cons, etc.)
- advanced_calls.rs: Native, external, and cached function calls
- environment_ops.rs: Rule definition and pattern-based dispatch
- space_ops.rs: Space operations for knowledge base access
- state_ops.rs: Mutable state cell operations
- debug_ops.rs: Debugging and tracing operations
- tests.rs: Comprehensive test coverage

The VM executes bytecode compiled from MeTTa expressions with support for:
- Nondeterminism via choice points and backtracking
- Pattern matching with variable binding
- Environment-based rule dispatch
- Memoization cache integration
- Native and external function calls

Note: JIT compilation support is stubbed out and will be added
in a later PR when the JIT compiler infrastructure is complete.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add #[allow(dead_code)] to pattern.rs helper functions
- Add #[allow(dead_code)] to EvalStep enum in eval/mod.rs
- Add #[allow(dead_code)] to eval_let_step in let_forms.rs
- Add #[allow(dead_code)] to list operations in basic.rs
- Add #[allow(clippy::large_enum_variant)] to Alternative enum
- Add #[cfg(test)] to CacheStats import in vm/mod.rs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants