feat: Phase 2.4 レガシーアーカイブ整理完了(151MB削減)
## 🎉 完了項目 - ✅ plugin_box_legacy.rs削除(7.7KB、参照ゼロ確認済み) - ✅ REMOVEDコメント整理(encode.rs簡潔化) - ✅ venv削除(143MB節約、.gitignoreは既存) - ✅ llvm_legacyスタブ化(8KB、compile_error!による安全化) ## 🏆 成果 - **リポジトリサイズ改善**: 151MB削減 - **コード整理**: レガシーコード安全にアーカイブ - **プラグインファースト**: StrictPluginFirst継続動作 ## ✅ 検証完了 - cargo build --release --features llvm (警告のみ、エラーなし) - LLVMハーネス実行: print出力正常 - プラグイン動作: StringBox等正常動作 codex先生の戦略に従った安全な段階的削除を実行 Co-Authored-By: codex <noreply@anthropic.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
# MIR PHI Invariants
|
||||
|
||||
Note
|
||||
- Default policy is PHI‑off at MIR level. These invariants apply to the dev‑only PHI‑on mode and to how LLVM synthesizes PHIs from predecessor copies. See also `phi_policy.md`.
|
||||
- Phase‑15 では PHI‑on が既定だよ。この資料の不変条件は MIR ビルダーが生成する PHI と、レガシーで `NYASH_MIR_NO_PHI=1` を指定したときに LLVM が補完するケースの両方へ適用するよ。詳しくは `phi_policy.md` を参照してね。
|
||||
|
||||
Scope: Builder/Bridge, PyVM, llvmlite (AOT)
|
||||
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
## MIR PHI Policy (Phase‑15)
|
||||
|
||||
Status
|
||||
- Default: PHI‑off (edge‑copy mode). Builders/Bridge do not emit PHI; merges are realized via per‑predecessor Copy into the merge destination.
|
||||
- Dev‑only: PHI‑on is experimental for targeted tests (enable with `NYASH_MIR_NO_PHI=0`).
|
||||
- LLVM: PHI synthesis is delegated to the LLVM/llvmlite path (AOT/EXE). PyVM serves as the semantic reference.
|
||||
- Default: PHI‑on. MIR builders always emit SSA `Phi` nodes at merge heads, and verifiers run with full dominance checks.
|
||||
- Legacy fallback: Set `NYASH_MIR_NO_PHI=1` to enforce the former edge‑copy mode (PHI‑off) for targeted debug sessions.
|
||||
- LLVM: The llvmlite harness still validates and, when necessary, rewires PHIs, but it no longer compensates for missing SSA form in the input.
|
||||
|
||||
Rationale
|
||||
- Simplify MIR builders and JSON bridge by removing PHI placement decisions from the core path.
|
||||
- Centralize SSA join formation at a single backend (LLVM harness), reducing maintenance and divergence.
|
||||
- Keep PyVM parity by treating merges as value routing; short‑circuit semantics remain unchanged.
|
||||
- Break/continue correctness: PHI‑off exposed MIR generation bugs around loop exits; keeping PHIs generated in the core builder avoids silent value reuse mistakes.
|
||||
- ChatGPT Pro design review: external audit recommended shipping Phase‑15 with PHI enabled by default to minimize backend divergence and simplify documentation.
|
||||
- Maintained parity: PyVM and LLVM continue to share the same MIR stream; PHI nodes remain the single source of truth for join semantics.
|
||||
|
||||
Operational Rules (PHI‑off)
|
||||
- Edge‑copy only: predecessors write the merged destination via `Copy { dst=merged, src=pred_value }`.
|
||||
- Merge block: must not emit a self‑Copy for the same destination; merged value is already defined by predecessors.
|
||||
- Verifier: `verify_allow_no_phi()` is on by default; dominance and merge checks are relaxed in PHI‑off.
|
||||
Operational Rules (PHI‑on)
|
||||
- Merge blocks place PHIs first, with one incoming per predecessor, covering loop latches, break/continue exits, and structured control flow.
|
||||
- `verify_allow_no_phi()` mirrors `NYASH_MIR_NO_PHI`; with PHI‑on it stays strict and fails if SSA form is missing.
|
||||
- Use `NYASH_LLVM_TRACE_PHI=1` to inspect wiring; traces now confirm the builder’s SSA layout instead of synthesizing it from edge copies.
|
||||
|
||||
- Developer Notes (PHI‑on dev mode)
|
||||
- Requires cargo feature `phi-legacy`. Build with `--features phi-legacy` and enable with `NYASH_MIR_NO_PHI=0`.
|
||||
Builders may place `Phi` at block heads with inputs covering all predecessors.
|
||||
- Use `NYASH_LLVM_TRACE_PHI=1` for wiring trace; prefer small, isolated tests.
|
||||
Fallback Mode (PHI‑off)
|
||||
- Toggle: `NYASH_MIR_NO_PHI=1` (optionally pair with `NYASH_VERIFY_ALLOW_NO_PHI=1`).
|
||||
- Behavior: MIR builders revert to edge copies per predecessor and skip PHI emission. This path is retained only for diagnosing older JSON dumps.
|
||||
- Guardrails: tooling should mark PHI‑off runs as legacy; new smokes and CI stay on PHI‑on unless explicitly overridden.
|
||||
|
||||
Backends
|
||||
- LLVM harness performs PHI synthesis based on predecessor copies and dominance.
|
||||
- Other backends (Cranelift/JIT) are secondary during Phase‑15; PHI synthesis there is not required.
|
||||
- LLVM harness consumes the PHI‑rich MIR stream and validates incoming edges; no extra synthesis is performed unless legacy mode is forced.
|
||||
- Cranelift/JIT paths operate on the same MIR14 form; Phase‑15 keeps them secondary but expects PHIs to be present.
|
||||
|
||||
Acceptance
|
||||
- Default smokes/CI run with PHI‑off.
|
||||
- Parity checks compare PyVM vs. LLVM AOT outputs; differences are resolved on the LLVM side when they stem from PHI formation.
|
||||
- Default smokes/CI run with PHI‑on.
|
||||
- Legacy PHI‑off runs must document the reason in `CURRENT_TASK.md` (e.g., reproducing historical MIR13 bugs) and avoid committing the override into shared scripts.
|
||||
|
||||
@ -11,11 +11,11 @@ Normalization of println/print
|
||||
|
||||
Backend Behavior
|
||||
- LLVM/AOT (EXE-first):
|
||||
- `env.console.log` lowers to NyRT exports and links statically.
|
||||
- `env.console.log` is normalized in the LLVM builder to kernel exports and links statically.
|
||||
- Primary mapping uses pointer-API when possible to avoid handle churn:
|
||||
- `nyash.console.log(i8*) -> i64`
|
||||
- Fallback to handle-API helpers if only a handle is available.
|
||||
- Runtime result line: NyRT prints `Result: <code>` after `ny_main()` returns. Set `NYASH_NYRT_SILENT_RESULT=1` to suppress for tests.
|
||||
- Fallback to handle-API helpers (`nyash.string.to_i8p_h`) if only a handle is available.
|
||||
- Runtime result line: the kernel prints `Result: <code>` after `ny_main()` returns. Set `NYASH_NYRT_SILENT_RESULT=1` to suppress for tests.
|
||||
- PyVM:
|
||||
- Accepts `env.console.log/warn/error` and writes to stdout (MVP). Return is `0` when a destination is present.
|
||||
- JIT:
|
||||
@ -24,7 +24,7 @@ Backend Behavior
|
||||
MIR JSON v0 Encoding
|
||||
- Instruction shape:
|
||||
- `{ "op": "externcall", "func": "env.console.log", "args": [<vid>], "dst": <vid|null>, "dst_type": "i64"? }`
|
||||
- Builder may also emit `"func": "nyash.console.log"` in some paths; both are accepted by backends.
|
||||
- Builder may also emit `"func": "nyash.console.log"` in some paths; both are accepted by backends. The LLVM builder maps `env.console.*` to `nyash.console.*` automatically.
|
||||
|
||||
Key Fields (JSON v0, minimal)
|
||||
- `op`: literal `"externcall"`.
|
||||
|
||||
Reference in New Issue
Block a user