docs(phase269): document P1 completion - SSA fix and type annotation
- Update 10-Now.md: Phase 269 P1 complete (SSA + type SSOT) - Update 30-Backlog.md: Add P1.2 investigation task - Update phases/phase-269/README.md: Document P1.0 and P1.1 details Phase 269 P1 achievements: - Pattern8 SSA correctness with PHI nodes - call_method return type SSOT propagation - Module signature as single source of truth Known issue: this.method() in loops (pre-existing, tracked as P1.2) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,63 +1,68 @@
|
||||
# Phase 269: Pattern8 への Frag 適用(test-only + 最小 fixture)
|
||||
# Phase 269: Pattern8 への Frag 適用(P0=test-only → P1=実装)
|
||||
|
||||
Status: 🚧 進行中(P0)
|
||||
Status: 🚧 進行中(P1)
|
||||
Date: 2025-12-21
|
||||
|
||||
## 目的
|
||||
|
||||
**EdgeCFG Fragment を Pattern8 に適用し、NormalizedShadow への適用パターンを確立**
|
||||
**Pattern8(BoolPredicateScan)を EdgeCFG Fragment(Frag + emit_frag)で実装し、pattern番号の列挙を “exit配線” に収束させる。**
|
||||
|
||||
- **P0**: Pattern8 の Frag 版 lowerer を test-only で作成(既存実装と並走)
|
||||
- **P1 以降**: 既存 Pattern8 を段階的に置換(将来フェーズ)
|
||||
- **P0**: test-only stub + 最小 fixture/smoke で “入口” を固定(DONE)
|
||||
- **P1**: 実装(MIR CFG層で Frag を組み、emit_frag で terminator を SSOT 化)(IN PROGRESS)
|
||||
|
||||
## 実装範囲(重要:スコープ境界)
|
||||
|
||||
### ✅ 触る(P0 スコープ)
|
||||
- `pattern8_scan_bool_predicate.rs` に Frag 版 lowerer を追加(test-only)
|
||||
- EdgeCFG Fragment API(compose::loop_(), emit_frag())を使用
|
||||
- 最小 fixture(`phase269_p0_pattern8_frag_min.hako`)を作成
|
||||
- 最小 smoke test(VM のみ)を作成
|
||||
### ✅ 触る(P1 スコープ)
|
||||
- `src/mir/builder/control_flow/joinir/patterns/pattern8_scan_bool_predicate.rs`
|
||||
- `src/mir/builder/emission/loop_predicate_scan.rs`(薄い入口:Frag 構築 + emit_frag)
|
||||
- fixture/smoke(`apps/tests/phase269_p0_pattern8_frag_min.hako`, `tools/smokes/v2/profiles/integration/apps/phase269_p0_pattern8_frag_vm.sh`)
|
||||
|
||||
### ❌ 触らない(P0 スコープ外)
|
||||
- 既存 Pattern8 本体(`cf_loop_pattern8_bool_predicate_impl()`)は維持
|
||||
- Pattern6/7 は触らない
|
||||
- JoinIR merge 層は触らない
|
||||
- LLVM backend は P1 以降
|
||||
### ❌ 触らない(P1 スコープ外)
|
||||
- cf_loop(JoinIR-only hard-freeze)
|
||||
- merge/EdgeCFG plumbing(Phase 260-268 の SSOT は維持)
|
||||
- Pattern6/7/9(Phase 269 は Pattern8 に集中)
|
||||
|
||||
## 実装戦略(Phase 268 パターン踏襲)
|
||||
|
||||
### アーキテクチャ図
|
||||
```
|
||||
pattern8_scan_bool_predicate.rs (Pattern8 層)
|
||||
↓ 新規追加(test-only)
|
||||
lower_pattern8_frag() (Frag 版 lowerer)
|
||||
↓ 内部で使用
|
||||
Frag 構築 + compose::loop_() + emit_frag() (EdgeCFG Fragment API)
|
||||
↓ P1: emission 入口に委譲
|
||||
emission/loop_predicate_scan.rs::emit_bool_predicate_scan_edgecfg()
|
||||
↓ 内部で使用(break/continue 無しなので手配線)
|
||||
Frag(branches+wires)+ emit_frag()
|
||||
↓ 最終的に呼び出し
|
||||
set_branch_with_edge_args() / set_jump_with_edge_args() (Phase 260 SSOT)
|
||||
```
|
||||
|
||||
### P0 実装順序
|
||||
## P1 実装のポイント(重要)
|
||||
|
||||
1. **Phase 269 README 作成**(このファイル)
|
||||
- 設計境界と適用順を SSOT 化
|
||||
- "どの層を触る/触らない" を明記
|
||||
### 1) Return を exits に置かない
|
||||
- `emit_frag()` が emit するのは `branches` と `wires` のみ(`exits` は “上位に伝搬する未配線”)
|
||||
- したがって early-exit の `return false` は `wires` に `ExitKind::Return` として入れる(`target=None` を許可)
|
||||
|
||||
2. **Pattern8 Frag 版 lowerer 作成**(test-only)
|
||||
- `#[cfg(test)] pub(crate) fn lower_pattern8_frag()` として実装
|
||||
- JoinModule から MIR terminator を生成
|
||||
- unit test で MIR terminator 生成を確認
|
||||
### 2) `return true` は loop 後 AST に任せる
|
||||
- Frag 経路は “loop の制御” と “early-exit” のみ担当し、関数全体の return は既存 AST lowering に任せる
|
||||
- P1 の最小は「失敗で return false / それ以外は after に落ちる」
|
||||
|
||||
3. **最小 fixture + smoke test**(VM のみ)
|
||||
- `apps/tests/phase269_p0_pattern8_frag_min.hako`
|
||||
- `tools/smokes/v2/profiles/integration/apps/phase269_p0_pattern8_frag_vm.sh`
|
||||
- PASS を確認(既存 quick 45/46 を悪化させない)
|
||||
### 3) SSA: ループ変数 `i` の PHI が必須
|
||||
- header の条件評価は毎周回評価されるが、SSA 的には `i` の “現在値” を header に合流させる必要がある
|
||||
- 最小の形(header に挿入、先頭に置く):
|
||||
- `i_current = phi [i_init, preheader_bb], [i_next, step_bb]`
|
||||
- header/body/step は `i_current` を参照
|
||||
- step で `i_next = i_current + 1` を作り、backedge の入力にする
|
||||
|
||||
4. **docs 更新**
|
||||
- `10-Now.md` に Phase 269 P0 追記
|
||||
- `30-Backlog.md` に Phase 269 項目追加
|
||||
## テスト手順(固定)
|
||||
|
||||
## Pattern8 の構造理解
|
||||
1. `cargo build --release`
|
||||
2. `cargo test -p nyash-rust --lib --release`
|
||||
3. `HAKORUNE_BIN=./target/release/hakorune bash tools/smokes/v2/profiles/integration/apps/phase259_p0_is_integer_vm.sh`
|
||||
4. `HAKORUNE_BIN=./target/release/hakorune bash tools/smokes/v2/profiles/integration/apps/phase269_p0_pattern8_frag_vm.sh`
|
||||
5. `./tools/smokes/v2/run.sh --profile quick`(45/46 を維持)
|
||||
|
||||
## P0(historical)
|
||||
|
||||
P0 の test-only 記録は履歴として残す(入口の固定に寄与)。
|
||||
|
||||
### 検出基準(Phase 259 P0 固定形式)
|
||||
1. Loop condition: `i < s.length()`
|
||||
|
||||
Reference in New Issue
Block a user