fix(normalization): Phase 143 execution fix - Param region SSOT
Problem: normalized_helpers allocated env params as ValueId(1,2...) in PHI Reserved region (0-99) instead of Param region (100-999) per JoinValueSpace contract. Root cause: All 4 normalized shadow modules started from next_value_id=1, violating the Param region contract. Solution: - Add NormalizedHelperBox::alloc_env_params_param_region() that allocates params starting from PARAM_MIN (100) - Update 4 normalized shadow files to use new API: - loop_true_if_break_continue.rs - loop_true_break_once.rs - if_as_last_join_k.rs - post_if_post_k.rs - Fix instruction_rewriter.rs type mismatch (func.signature.params → func.params) Verification: - Unit tests: 69/69 PASS - VM smoke: exit code 7 ✅ - LLVM EXE smoke: exit code 7 ✅ (timeout resolved!) ValueId Space Contract (Phase 201): | Region | Range | Purpose | |--------------|----------|------------------------------| | PHI Reserved | 0-99 | Loop header PHI dst | | Param | 100-999 | env params (flag, counter) | | Local | 1000+ | Const, BinOp, condition | 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -3,12 +3,61 @@
|
||||
## Next (planned)
|
||||
|
||||
- Phase 141 P2+: Call/MethodCall 対応(effects + typing を分離して段階投入)
|
||||
- Phase 143-loopvocab R0+: StepTree の語彙拡張(loop 内 if/break/continue を「新パターン追加」ではなく「語彙追加」で吸収)
|
||||
- R0: Contract SSOT 抽出(pattern shape と exit action の分離)
|
||||
- P1: continue 支援を追加
|
||||
- P2: else/対称branch 対応
|
||||
- Phase 143-loopvocab P2+: Loop-If-Exit パターン拡張(else/対称branch対応)
|
||||
- P2: else/対称branch 対応(continue/break の混合パターン)
|
||||
- P3+: 条件スコープ拡張(impure expressions 対応)
|
||||
- 詳細: `docs/development/current/main/30-Backlog.md`
|
||||
|
||||
## 2025-12-19:Phase 143 実行系契約修正 ✅
|
||||
|
||||
**問題**: normalized_helpers が env params を `ValueId(1,2...)` で割り当てていた(PHI Reserved 領域 0-99)。
|
||||
|
||||
**根本原因**: JoinValueSpace 契約では Param 領域は 100-999。4つの normalized shadow モジュールが全て間違った領域に params を割り当てていた。
|
||||
|
||||
**修正**:
|
||||
- `NormalizedHelperBox::alloc_env_params_param_region()` 新規追加(100+ 開始)
|
||||
- 4 ファイルの normalized shadow 生成を更新:
|
||||
- `loop_true_if_break_continue.rs`
|
||||
- `loop_true_break_once.rs`
|
||||
- `if_as_last_join_k.rs`
|
||||
- `post_if_post_k.rs`
|
||||
- `instruction_rewriter.rs` 型ミスマッチ修正(`func.signature.params` → `func.params`)
|
||||
|
||||
**検証**:
|
||||
- VM exit=7 ✅(phase143_loop_true_if_break_vm.sh PASS)
|
||||
- LLVM EXE exit=7 ✅(phase143_loop_true_if_break_llvm_exe.sh PASS、timeout 解消)
|
||||
- Unit tests: 69/69 PASS
|
||||
|
||||
**ValueId Space Contract (Phase 201)**:
|
||||
| Region | Range | Purpose |
|
||||
|--------|-------|---------|
|
||||
| PHI Reserved | 0-99 | Loop header PHI dst |
|
||||
| **Param** | **100-999** | **env params (flag, counter, etc.)** |
|
||||
| Local | 1000+ | Const, BinOp, condition results |
|
||||
|
||||
## 2025-12-19:Phase 143.5 + P1 完了 ✅
|
||||
|
||||
**Phase 143.5: NormalizedHelperBox 箱化(リファクタリング)**
|
||||
- 目的: 120+ 行のヘルパー関数重複を消去(4 ファイル共通化)
|
||||
- 実装: `src/mir/control_tree/normalized_shadow/common/normalized_helpers.rs` (151行+6テスト)
|
||||
- 効果: 136行追加 - 149行削除 = **-13行**(保守性大幅向上)
|
||||
- 統計: 67/67 tests PASS(新規テスト 6個含む)
|
||||
- 検証: cargo check 0 errors, cargo test 100% green
|
||||
|
||||
**Phase 143 P1: Continue Support(条件付きループ継続)**
|
||||
- 目的: `loop(true) { if(cond_pure) continue }` パターン追加
|
||||
- 実装: Loop-If-Exit contract enum 駆動(break/continue 弁別)
|
||||
- 変更:
|
||||
- `extract_pattern_shape()`: Err-based pattern matching to LoopIfExitShape
|
||||
- `extract_exit_action()`: Break/Continue を enum variant として識別
|
||||
- `loop_cond_check`: match shape.then で Jump target を動的決定
|
||||
- Fixtures & Tests:
|
||||
- `apps/tests/phase143_loop_true_if_continue_min.hako`
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase143_loop_true_if_continue_vm.sh`
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase143_loop_true_if_continue_llvm_exe.sh`
|
||||
- 検証: 契約ベース(shape.validate_for_p1() で P1 制約チェック)
|
||||
- 注記: Phase 131 Pattern matching Issue 既知(ルーティング層の pre-existing failure)
|
||||
|
||||
## 2025-12-19:Phase 143-loopvocab P0 完了 ✅
|
||||
|
||||
**Phase 143-loopvocab P0: Conditional Break Vocabulary Extension**
|
||||
@ -24,7 +73,7 @@
|
||||
- 6-function JoinModule(main → loop_step → loop_cond_check → Jump/Call → k_exit → Ret)
|
||||
- Jump: if true → k_exit, if false → fall through to Call(loop_step)
|
||||
- Fixtures:
|
||||
- `apps/tests/phase143_loop_true_if_break_min.hako`(expected exit code 1)
|
||||
- `apps/tests/phase143_loop_true_if_break_min.hako`(expected exit code 7)
|
||||
- Smoke tests:
|
||||
- VM: `tools/smokes/v2/profiles/integration/apps/phase143_loop_true_if_break_vm.sh` ✅ PASS
|
||||
- LLVM EXE: `tools/smokes/v2/profiles/integration/apps/phase143_loop_true_if_break_llvm_exe.sh` ✅ PASS
|
||||
|
||||
@ -191,3 +191,58 @@ let available_inputs = AvailableInputsCollectorBox::collect(
|
||||
### Diagnostics
|
||||
|
||||
- `OutOfScopeReason::IntrinsicNotWhitelisted` を追加し、`MethodCall` の out-of-scope 理由を精密化する。
|
||||
|
||||
---
|
||||
|
||||
## ValueId Space Contract (Phase 143 fix)
|
||||
|
||||
### 問題
|
||||
|
||||
Normalized shadow modules allocate env params using `alloc_value_id()` starting from 1, but JoinValueSpace contract requires Param region (100-999).
|
||||
|
||||
**Wrong** (before fix):
|
||||
```rust
|
||||
let mut next_value_id: u32 = 1;
|
||||
let params = NormalizedHelperBox::alloc_env_params(&fields, &mut next_value_id);
|
||||
// → [ValueId(1), ValueId(2), ...] — PHI Reserved region!
|
||||
```
|
||||
|
||||
**Correct** (after fix):
|
||||
```rust
|
||||
let (params, mut next_local) = NormalizedHelperBox::alloc_env_params_param_region(&fields);
|
||||
// → [ValueId(100), ValueId(101), ...] — Param region ✅
|
||||
```
|
||||
|
||||
### Contract (Phase 201 SSOT)
|
||||
|
||||
```
|
||||
0 100 1000 u32::MAX
|
||||
├──────────┼──────────┼──────────────────────────┤
|
||||
│ PHI │ Param │ Local │
|
||||
│ Reserved│ Region │ Region │
|
||||
└──────────┴──────────┴──────────────────────────┘
|
||||
```
|
||||
|
||||
| Region | Range | Purpose |
|
||||
|--------|-------|---------|
|
||||
| PHI Reserved | 0-99 | Loop header PHI dst |
|
||||
| **Param** | **100-999** | **env params (flag, counter, etc.)** |
|
||||
| Local | 1000+ | Const, BinOp, condition results |
|
||||
|
||||
### SSOT
|
||||
|
||||
- Constants: `src/mir/join_ir/lowering/join_value_space.rs`
|
||||
- `PARAM_MIN = 100`
|
||||
- `LOCAL_MIN = 1000`
|
||||
- API: `NormalizedHelperBox::alloc_env_params_param_region()`
|
||||
- Location: `src/mir/control_tree/normalized_shadow/common/normalized_helpers.rs`
|
||||
- Returns: `(Vec<ValueId>, u32)` — (params in 100+ range, next_local starting at 1000)
|
||||
|
||||
### Affected Files
|
||||
|
||||
- `loop_true_if_break_continue.rs`
|
||||
- `loop_true_break_once.rs`
|
||||
- `if_as_last_join_k.rs`
|
||||
- `post_if_post_k.rs`
|
||||
|
||||
All normalized shadow modules must use `alloc_env_params_param_region()` instead of `alloc_env_params()` to ensure env params are in the correct region.
|
||||
|
||||
Reference in New Issue
Block a user