Add InitLocals instruction for bulk local initialization#3122
Add InitLocals instruction for bulk local initialization#3122antoniosarosi merged 2 commits intocanaryfrom
Conversation
Replace N consecutive LoadConst(null) instructions at the start of each function with a single InitLocals(N) that bulk-initializes local variable stack slots. Reduces bytecode size, dispatch overhead, and improves readability.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughIntroduce a new Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Merging this PR will not alter performance
|
Binary size checks passed✅ 7 passed
Generated by |
Integrates 4 canary PRs: - #3126: MIR analysis soundness (StatementRef, unified walkers) - #3124: Type variants for type expressions (parse takes Type) - #3122: InitLocals(n) instruction - #3107: Full tracing system (bex_events, Collector) Conflict resolutions: - llm.baml: keep orchestration loop with panic, update parse() to use get_return_type - baml_builtins: keep both Enum and Type TypePattern variants, add get_return_type alongside orchestration builtins - baml_compiler_emit: keep HIDDEN_LLM_BUILTINS removal - baml_compiler_tir: add both Enum and Type arms in substitute functions - bex_vm_types: merge both ClientBuild* and CollectorRef re-exports - llm_render tests: use new 4-arg call_function signature, fix PromptAst FQN
Summary
InitLocals(n)bytecode instruction that pushesnnull values onto the stack in one shot, replacing N consecutiveLoadConst(null)instructions emitted at the start of every function for local variable pre-allocation.Vec::resizefor the VM handler instead of per-element push, avoiding N dispatch cycles through the main match loop.baml.llm.call_llm_functionprologue).Test plan
baml_compiler_emittests passbaml_testspass (33 codegen snapshots auto-updated)bex_vmtests passcargo fmt --checkcleancargo clippyclean on affected cratesSummary by CodeRabbit