Files
hakorune/docs/private/papers/public/phi_off_harness.md
Selfhosting Dev 9b9a91c859 feat: GC機能復活&VM整理&json_native調査完了
## 🎉 ChatGPT×Claude協働成果
-  **GC機能復活**: vm-legacy削除で失われたGC機能を新実装で復活
  - GCメトリクス追跡システム実装(alloc/collect/pause計測)
  - 3種類のGCモード対応(counting/mark_sweep/generational)
  - host_handles.rsでハンドル管理復活

-  **VM整理とエイリアス追加**: 混乱していた名前を整理
  - MirInterpreter = NyashVm = VM のエイリアス統一
  - vm-legacyとインタープリターの違いを明確化
  - 壊れていたvm.rsの互換性修復

-  **スモークテスト整理**: v2構造でプラグイン/コア分離
  - plugins/ディレクトリにプラグインテスト移動
  - gc_metrics.sh, gc_mode_off.sh, async_await.sh追加
  - _ensure_fixture.shでプラグイン事前ビルド確認

## 📊 json_native調査結果
- **現状**: 25%完成(配列/オブジェクトパース未実装)
- **将来性**: 並行処理でyyjson超えの可能性大
  - 100KB以上のJSONで2-10倍速の可能性
  - Nyash ABI実装後はゼロコピー最適化
- **判断**: 現時点では置換不可、将来の大きな足場

## 🔍 技術的発見
- vm-legacy = 完全なVM実装(GC付き)だった
- MirInterpreter = 現在のRust VM(712行、Arc使用)
- 200行簡易JSONは既に削除済み(存在しない)

ChatGPT爆速修復×Claude詳細調査の完璧な協働!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 23:27:59 +09:00

1.5 KiB
Raw Blame History

PHIOff EdgeCopy + Harness PHI Synthesis (Draft)

Problem

  • Frontend/Builder PHI construction intertwines with optimization order and dominance; fragile in multibackend settings.

Contribution (Nyash)

  • Keep builders PHIoff using EdgeCopy policy (pred→copy→merge), and synthesize PHIs late in the harness.
  • Constrain PHI placement: always at block head (grouped) via phi_at_block_head/ensure_phi.
  • Make PHI wiring observable by JSONL traces + checker.

Method

  • IR discipline: JSON v0 Bridge emits no PHIs; records edgeend values per block.
  • Harness (finalize_phis) resolves (decl_b, src_vid) pairs to the nearest predecessor on CFG paths and wires incoming at block heads.
  • Selfcarry handling: prefer a nonself initial source if present.
  • Helpers: phi_at_block_head, ensure_phi, wire_incomings.

Code References

  • Bridge edgecopy: src/runner/json_v0_bridge/lowering/*
  • Harness PHI: src/llvm_py/phi_wiring/wiring.py, src/llvm_py/llvm_builder.py
  • Head placement helper: phi_at_block_head()

Evaluation Plan

  • Correctness: run curated smokes with complex mixes (loops, ifs, returns, exceptions) and diff traces.
  • Robustness: mutate block orders; verify PHIs remain grouped at heads and traces stable.
  • Cost: count PHIs vs. classic SSA on samples (optional).

Reproduce (v2)

  • cargo build --release
  • NYASH_LLVM_TRACE_PHI=1 NYASH_LLVM_TRACE_OUT=tmp/phi_trace.jsonl bash tools/smokes/phi_trace_local.sh
  • Optional: tools/smokes/v2/run.sh --profile integration