Phase 118 refactoring: Box modularization for exit value collection. # Changes - Created `exit_args_collector.rs` with ExitArgsCollectorBox - Extracted jump_args processing logic from instruction_rewriter.rs - Implemented SSOT for offset calculation (0 vs 1 legacy layout) - Added comprehensive unit tests (6 tests, all passing) # Design - **Responsibility**: Collects exit PHI inputs + carrier inputs from jump_args - **SSOT**: Centralized offset calculation logic - **Fail-Fast**: Validates jump_args length against exit_bindings - **Phase 118 P2 Contract**: Uses boundary.exit_bindings as SSOT # Key Features - Filters ConditionOnly carriers (no exit PHI needed) - Handles both direct mapping (offset=0) and legacy layout (offset=1) - Strict mode: Fail-Fast on validation errors - Non-strict mode: Warns and continues with best effort # Test Results - Unit tests: 6/6 PASS - Phase 118 smoke tests: PASS (VM + LLVM) - Phase 117 regression: PASS # Reduced Code Complexity - instruction_rewriter.rs: ~90 lines → ~25 lines (box call) - Offset logic: Centralized in ExitArgsCollectorBox 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
JoinIR Merge Coordinator(箱の地図)
責務: JoinIR 生成物をホスト MIR に統合するフェーズ(block/ValueId remap → rewrite → PHI/ExitLine 再接続)。
主な箱と入口:
instruction_rewriter.rs— JoinIR→MIR 命令を書き換えつつブロックを組み立てるメイン導線phi_block_remapper.rs— PHI の block-id だけを再マップする専用箱(ValueId は remapper 済みを前提)loop_header_phi_builder.rs/exit_phi_builder.rs— ヘッダ/出口 PHI の組み立てinline_boundary_injector.rs— Host↔JoinIR の ValueId 接続(Boundary 注入)value_collector.rs/block_allocator.rs— 再マップ前の収集と ID 割り当てtail_call_classifier.rs— tail call 判定(loop_step の末尾呼び出し検出)
Fail-Fast の基本:
- block/ValueId 衝突や PHI 契約違反は握りつぶさず
Errで止める - remap は「ValueId remap」→「block-id remap」の順で一貫させる(PHI 二度 remap は禁止)
拡張時のチェックリスト:
- 新しい JoinInst → MIR 変換を追加する場合、
instruction_rewriterに閉じて追加し、PHI/ExitLine 契約が壊れないか確認。 - PHI の入力ブロックを触るときは
phi_block_remapper経由に寄せて二重 remap を防ぐ。 - 増やした box/契約はここ(README)に一言追記して入口を明示。