refactor(joinir): make jump_args layout explicit (Phase 256)

This commit is contained in:
2025-12-20 13:04:24 +09:00
parent 1028bd419c
commit 4439d64da3
21 changed files with 715 additions and 195 deletions

View File

@ -5,16 +5,19 @@ Scope: Loop pattern recognition for split/tokenization operations
Related:
- Phase 255 完了loop_invariants 導入、Pattern 6 完成)
- Phase 254 完了Pattern 6 index_of 実装)
- North star設計目標: `docs/development/current/main/design/join-explicit-cfg-construction.md`
## Current Status (SSOT)
- Current first FAIL: `StringUtils.split/2`MIR verification: “Value defined multiple times” + SSA undef
- Pattern6 は PASS 維持
- Current first FAIL: `json_lint_vm`Pattern2 break cond: `this.is_whitespace(...)` needs `current_static_box_name`
- `StringUtils.split/2` は VM `--verify` / smoke まで PASS
- Pattern6index_ofは PASS 維持
- 直近の完了:
- P1.10: DCE が `jump_args` 参照を保持し、`instruction_spans` と同期するよう修正(回帰テスト追加)
- P1.7: SSA undef`%49/%67`根治continuation 関数名の SSOT 不一致)
- P1.6: pipeline contract checks を `run_all_pipeline_checks()` に集約
- 次の作業: P1.11merge 側の ExitLine/PHI/dominance を `--verify` で緑に戻す
- 次の作業: Pattern2 の static box context を break condition lowering に渡す(次フェーズ
- 設計メモChatGPT Pro 相談まとめ): `docs/development/current/main/investigations/phase-256-joinir-contract-questions.md`
---
@ -414,6 +417,44 @@ Option APattern 7 新設)を推奨。
- `instruction_spans``instructions` の同期不変条件を維持SPAN MISMATCH 根治)
- 回帰テストを追加(`test_dce_keeps_jump_args_values`, `test_dce_syncs_instruction_spans`
---
## 進捗P1.11
### P1.11: ExitArgsCollector の expr_result slot 判定を明確化(完了)
症状split の誤動作):
- runtime 側で `start``result` が入れ替わり、ExitLine の配線が崩れる
- 結果として VM 実行で型エラー(例: `ArrayBox <= 5`)に到達
根本原因SSOT:
- ExitArgsCollector が `jump_args[0]` を “expr_result slot” とみなす条件が粗く、
`expr_result` が exit_bindings の LoopState carrier と同一 ValueId例: `result`)のケースでも offset=1 側に寄っていた
修正(方針):
- `expect_expr_result_slot` を明示的に渡し、かつ
`expr_result` が exit_bindings の LoopState carriers に含まれる場合は `expect_expr_result_slot=false` とする
- `exit_args_collector.rs` 側は `expect_expr_result_slot` の意味に合わせて整理し、
「末尾の invariants は無視」の仕様は維持する
受け入れ(確認):
- `./target/release/hakorune --backend vm --verify apps/tests/phase256_p0_split_min.hako` PASS
- `./target/release/hakorune --backend vm apps/tests/phase256_p0_split_min.hako` が期待 RC`3`)で終了
---
## 進捗P1.12
### P1.12: integration smoke scripts の終了コード取得を安定化(完了)
変更(要旨):
- `set -e` のまま “対象コマンドだけ” を `set +e` でラップし、非0終了でも exit code を取得できるようにする
- `HAKORUNE_BIN` の既定値を追加し、手動実行の再現性を上げる
受け入れ(確認):
- `HAKORUNE_BIN=./target/release/hakorune bash tools/smokes/v2/profiles/integration/apps/phase256_p0_split_vm.sh` PASSexit=3
- `HAKORUNE_BIN=./target/release/hakorune bash tools/smokes/v2/profiles/integration/apps/phase254_p0_index_of_vm.sh` PASSexit=1
### リファクタリング方針P1.6候補 / 先送り推奨)
現時点split がまだ FAILでは、箱化のための箱化で複雑さが増えやすいので、以下を推奨する: