Commit Graph

1128 Commits

Author SHA1 Message Date
c397016ac7 docs(phase29ab): record P8 ok fixtures and queue closeout 2025-12-28 16:00:45 +09:00
5edda8a0c2 docs(phase29ab): record P7 pattern6 negative fixtures 2025-12-28 15:41:58 +09:00
7ae96fcc4c docs(phase29ab): record P6 pattern6 contract freeze 2025-12-28 15:38:49 +09:00
b52788b3f6 phase29ab(p6): freeze pattern6 scan-with-init near-miss with fixture+smoke 2025-12-28 15:38:19 +09:00
bea2a8d9bb phase29ab(p5): freeze pattern7 split-scan near-miss with fixture+smoke 2025-12-28 14:32:19 +09:00
7a790a27cb docs(phase29ab): record P4 derived-slot realworld seg 2025-12-28 14:09:15 +09:00
bb8ee83988 docs+config: document and catalog resolve env vars 2025-12-28 14:02:32 +09:00
2ee8718476 docs: note NYASH_STR_CP toggle for strings 2025-12-28 13:57:31 +09:00
fe3eb9f1f7 config: centralize NYASH_STR_CP and add cp smoke 2025-12-28 13:44:53 +09:00
10e6a15552 refactor: unify string helpers and pattern2 derived slot 2025-12-28 13:22:02 +09:00
280a5a8187 docs+api: finalize phase29ab P3 contract and update examples 2025-12-28 10:57:48 +09:00
6ba9d995d2 docs(phase29ab): record P2 seg trim fixture+smoke 2025-12-28 09:04:18 +09:00
506339def0 docs(phase29ab): record P1 pattern2 fixture+smoke 2025-12-28 07:19:23 +09:00
61a3384bd2 docs(phase29aa): mark P8 complete 2025-12-28 06:32:46 +09:00
6d17a0f988 docs(phase29aa): mark P7 complete and queue P8 2025-12-28 06:00:34 +09:00
d3cf73f2ae phase29aa(p7): deterministic ReleaseStrong values ordering 2025-12-28 05:59:22 +09:00
ec1a84c465 docs(phase29aa): mark P6 complete and queue P7 2025-12-28 05:21:28 +09:00
120167bb6e phase29aa(p6): intersect multi-pred return join state 2025-12-28 05:20:45 +09:00
c8c99174af docs(phase29aa): queue P6 intersection join 2025-12-28 04:44:18 +09:00
02c01758b3 phase29aa(p5): multi-pred return join when states match 2025-12-28 04:43:19 +09:00
bf7b203586 phase29aa(p4): propagate rc state along jump chain to return 2025-12-28 01:56:36 +09:00
d70d9e3b89 docs(phase29aa): mark P3 complete and queue P4 2025-12-28 01:43:03 +09:00
94ad562aa5 Phase 29aa P3: Jump→Return single-pred rc propagation 2025-12-28 01:16:52 +09:00
ed68e48ed1 docs: update references after module splits 2025-12-27 21:43:47 +09:00
7be0b0c28e phase29aa: RcPlan + guard no cleanup on jump/branch 2025-12-27 16:09:26 +09:00
b6e80943a3 phase29aa(p1): rc insertion plan/apply refactor 2025-12-27 16:02:32 +09:00
d32b72653c docs(phase29aa): mark P1 pending until code lands 2025-12-27 15:49:42 +09:00
91adbd0547 docs(now): mark phase29z P2 closeout 2025-12-27 15:41:46 +09:00
b895f67e07 docs(phase29aa): add P0 CFG-aware design and link from 29z 2025-12-27 15:38:18 +09:00
a916066631 phase29z(p2): return cleanup and null propagation doc alignment 2025-12-27 15:26:42 +09:00
084277ee18 docs(phase29z): P2 closeout markers and next steps 2025-12-27 15:21:40 +09:00
5a3d45ce53 phase29z(p1): handle explicit drop in rc insertion 2025-12-27 15:16:46 +09:00
977f105e4e phase29z(p0): minimal RC insertion overwrite release 2025-12-27 15:03:05 +09:00
2223c1309b docs(phase29z): Add RC insertion minimal instructions 2025-12-27 14:18:33 +09:00
292fb83dcb docs(phase29y): Finalize P0 SSOT 2025-12-27 14:17:18 +09:00
9c6b725e3e docs(phase29y): Add P0 docs-finalize instructions 2025-12-27 14:04:56 +09:00
60e3510b26 docs(phase287): Complete P9 closeout 2025-12-27 14:02:53 +09:00
25bd15a64c docs(phase287): Add P9 closeout instructions 2025-12-27 13:57:33 +09:00
74c6df1acb docs(phase287): Mark P7 complete, add P8 instructions 2025-12-27 13:39:04 +09:00
df4d0b1776 docs(phase287): Mark P6 complete, add P7 instructions 2025-12-27 13:26:33 +09:00
f225e27007 refactor(joinir): Phase 287 P6 - Remove scan stage (2-stage pipeline) 2025-12-27 13:25:15 +09:00
8d4472ddd3 docs(phase287): Mark P5 complete, add P6 instructions 2025-12-27 13:20:16 +09:00
ad5b6085c1 docs(phase287): Mark P4 complete, add P5 instructions 2025-12-27 12:50:17 +09:00
2f7061e2e5 docs(phase287): Mark P3 complete, add P4 instructions 2025-12-27 12:17:47 +09:00
fe895e8838 refactor(joinir): Phase 287 P2 - Modularize contract_checks (facade pattern)
- contract_checks.rs (846行) を facade 化
- 6モジュールへ分割(1 module = 1 contract):
  - terminator_targets.rs (208行) - Branch/Jump検証
  - exit_bindings.rs (35行) - exit_bindings ↔ exit_phis
  - carrier_inputs.rs (145行) - carrier_inputs完全性
  - boundary_creation.rs (160行) - B1/C2不変条件
  - entry_params.rs (317行) - Entry param一貫性
  - mod.rs (30行) - Facade
- Total: 846 → 895行(+49行モジュール境界オーバーヘッド)
- 意味論不変: エラータグ/ヒント文すべて保存
- Fail-Fast遵守: silent fallback追加なし
- 検証: Build 0 errors / Pattern6 RC=9 / quick 154/154 PASS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 11:05:40 +09:00
433e1d45c0 refactor(joinir): Phase 287 P0.1 - Move verification to debug_assertions
- Move verify_no_phi_dst_overwrite() to debug_assertions.rs
- Move verify_phi_inputs_defined() to debug_assertions.rs
- Move verify_joinir_contracts() to debug_assertions.rs
- Remove duplicate get_instruction_dst() from mod.rs
- mod.rs: 1,555 → ~1,380 lines (-176 lines)
- Semantic invariance: 154/154 smoke tests PASS, Pattern6 RC:9

Phase 287 P0: Big Files Refactoring (意味論不変)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 10:10:59 +09:00
a04b48416e fix(joinir): Phase 287 P2 - Pattern6 nested loop latch overwrite fix
Fix infinite loop in Pattern6 (nested loop minimal) caused by main→loop_step
overwriting k_inner_exit→loop_step latch values.

Root cause: JoinIR main entry block was incorrectly treated as BackEdge,
causing it to overwrite the correct latch incoming values set by the true
back edge (k_inner_exit → loop_step).

Solution:
- Restrict latch recording to TailCallKind::BackEdge only
- Treat only MAIN's entry block as entry-like (not loop_step's entry block)
- Add debug_assert! to detect double latch set in future

Refactoring:
- Extract latch recording to latch_incoming_recorder module (SSOT)
- Add boundary.loop_header_func_name for explicit header identification
- Strengthen tail_call_classifier with is_source_entry_like parameter

Tests: apps/tests/phase1883_nested_minimal.hako → RC:9 (was infinite loop)
Smoke: 154/154 PASS, no regressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 09:39:29 +09:00
bbfc3c1d94 refactor(joinir): Phase 287 P2 - Strengthen BackEdge/latch conditions (WIP)
**Problem**: Phase 188.3 Pattern6 (nested loop) encounters infinite loop
- inner_step → inner_step (self-recursion) incorrectly classified as BackEdge
- → redirects to outer header (loop_step) instead of inner_step entry
- is_recursive_call causes inner recursion to overwrite outer latch values
- → PHI receives wrong values → i doesn't increment → infinite loop

**Fix 1: BackEdge classification strictness** (tail_call_classifier.rs)
- Add `is_target_loop_entry` parameter to classify_tail_call()
- BackEdge ONLY when target==loop_step (entry_func), not inner_step
- Prevents inner_step → inner_step from redirecting to outer header

**Fix 2: latch_incoming guard** (instruction_rewriter.rs)
- Change condition from `is_recursive_call || is_target_loop_entry`
  to `is_target_loop_entry` only
- Prevents inner_step self-recursion from overwriting outer loop's latch
- set_latch_incoming() now called with correct values (verified by debug)

**Status**: 🚧 WIP - Infinite loop still occurs
- set_latch_incoming('i', BasicBlockId(8), ValueId(21))  Called correctly
- But final PHI: `phi [%4, bb8]` instead of `phi [%21, bb8]` 
- Root cause likely in PHI generation (merge/mod.rs), not latch_incoming
- Next: Investigate why latch_incoming values aren't used in PHI

**Files**:
- src/mir/builder/control_flow/joinir/merge/tail_call_classifier.rs
- src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 08:32:14 +09:00
c6ffc06660 feat(joinir): Phase 188.3-P3.1,3.2 - AST extraction & validation helpers
Phase 3-1 完了: extract_inner_loop_ast() 実装
- 外側 loop body から内側 loop を抽出
- 正確に 1 つの inner loop を検証
- 0 個 or 2+ 個の場合は明示エラー (Fail-Fast)

Phase 3-2 完了: validate_strict_mode() プレースホルダー
- 現在は大半の検証を is_pattern6_lowerable() で実施
- 将来の strict mode チェック用の足場

ドキュメント追加:
- P1-INSTRUCTIONS.md: Phase 3-3 実装指示書 (4関数モデル詳細)
- README.md: max_loop_depth 定義の明確化
- 10-Now.md: Phase 188.3 方針の整合性維持

次タスク: Phase 3-3 (Continuation 生成) - P1-INSTRUCTIONS.md 参照

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 06:22:59 +09:00
a2c5fd90fe feat(joinir): Phase 188.3 - Pattern6 (NestedLoopMinimal) 選択ロジック実装
## Phase 188.3 進捗: Phase 2 完了 (6/13 tasks)

### 実装完了 

**Phase 1: Fixture作成**
- apps/tests/phase1883_nested_minimal.hako 追加
  - Add/Compare のみ(乗算なし)
  - 期待 exit code: 9 (3×3 nested loops)
- 既存 lowering で fallback 動作確認

**Phase 2: 選択ロジック (SSOT)**
- LoopPatternContext に step_tree_max_loop_depth フィールド追加
- choose_pattern_kind() に Pattern6 選択ロジック実装:
  1. Cheap check (has_inner_loop)
  2. StepTree 構築 (max_loop_depth 取得)
  3. AST validation (is_pattern6_lowerable)
- pattern6_nested_minimal.rs モジュール作成 (stub)
- LOOP_PATTERNS に Pattern6 entry 追加
- **検証**: Pattern6 が正しく選択される 

### 設計原則 (確認済み)

1. **Fail-Fast**: Pattern6 選択後は Ok(None) で逃げない
2. **outer 変数 write-back 検出 → validation false** (Phase 188.4+)
3. **最小実装**: inner local だけ、Pattern1 モデル二重化
4. **cfg! 依存なし**: production で動作

### 検証結果

```
[choose_pattern_kind] has_inner_loop=true
[choose_pattern_kind] max_loop_depth=2
[choose_pattern_kind] is_pattern6_lowerable=true
 Pattern6 SELECTED!
```

Stub からの期待エラー:
```
[ERROR]  [Pattern6] Nested loop lowering not yet implemented
```

### 次: Phase 3 (Lowering 実装 - 推定4時間)

残りタスク:
- Phase 3-1: AST 抽出ヘルパー
- Phase 3-2: Validation ヘルパー
- Phase 3-3: Continuation 生成 (outer_step, inner_step, k_inner_exit)
- Phase 3-4: fixture が exit=9 を返すことを検証

### 変更ファイル

**新規**:
- apps/tests/phase1883_nested_minimal.hako
- src/mir/builder/control_flow/joinir/patterns/pattern6_nested_minimal.rs
- docs/development/current/main/phases/phase-188.{1,2,3}/README.md

**変更**:
- src/mir/builder/control_flow/joinir/routing.rs (Pattern6 選択)
- src/mir/builder/control_flow/joinir/patterns/router.rs (Context 拡張)
- src/mir/builder/control_flow/joinir/patterns/mod.rs (module 宣言)

🎯 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 05:45:12 +09:00