Commit 221c79e
authored
refactor(vm): extract baml_vm_types crate to decouple compiler from runtime (#2959)
Create new baml_vm_types crate containing:
- Bytecode and Instruction definitions (617+ instructions)
- Program<T> struct generic over native function bindings
- Value, Object, Function, Class, Enum types
- Type-safe pool indexing (ObjectPool, GlobalPool, Index<K>)
- Jump table data structures for O(1) match dispatch
Key architectural changes:
- baml_compiler_emit now depends only on baml_vm_types, not baml_vm
- Compiler emits Program<()> with unbound native function stubs
- VM binds native functions at construction: Program<()> →
Program<NativeFunction>
- New attach_builtins() resolves native function names to
implementations
Benefits:
- Compiled programs are now serializable (no function pointers)
- Enables shipping pre-compiled bytecode in inlined_baml
- Reduces code-gen: runtime loads bytecode instead of regenerating
- Cleaner separation between compilation and execution
BREAKING: Vm::from_program() now returns Result<Vm, VmError> since
native function binding can fail if a builtin is not found.1 parent e98ffe2 commit 221c79e
41 files changed
Lines changed: 4802 additions & 4235 deletions
File tree
- baml_language
- architecture
- crates
- baml_compiler_emit
- src
- tests
- baml_tests
- snapshots/type_builder_test
- src
- baml_tools_onionskin
- src
- baml_vm_types
- src
- baml_vm
- benches
- src
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
Loading
0 commit comments