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>
This commit is contained in:
Selfhosting Dev
2025-09-24 23:27:59 +09:00
parent e5f6d51b3c
commit 9b9a91c859
36 changed files with 556 additions and 178 deletions

View File

@ -32,16 +32,14 @@ Bridge/Builder (JSON v0) Behavior
- MIR14 (default): If/Loop/Try placements emit PHIs up front; loop latches, break/continue, and structured joins have explicit incoming pairs.
- MIR13 (fallback): Merges are performed with edge copies (`merge_var_maps`). Use only when reproducing historical issues.
Testing
- Curated LLVM (default = PHI-on):
- `tools/smokes/curated_llvm.sh` (add `--phi-off` to exercise MIR13)
- PHI invariants/parity (AOT vs PyVM):
- `tools/pyvm_vs_llvmlite.sh` (default compares exit code; use `CMP_STRICT=1` for stdout+exit)
- Bridge/PyVM:
- `tools/selfhost_stage2_bridge_smoke.sh`
Testing (v2)
- Integration suite (LLVM harness/PHI invariants):
- `tools/smokes/v2/run.sh --profile integration`
- Bridge/PyVM の検証は v2 スイートに統合(必要に応じてフィルタを使用)
How to Force PHI-off (MIR13 fallback)
- Set: `NYASH_MIR_NO_PHI=1 NYASH_VERIFY_ALLOW_NO_PHI=1` and run `tools/smokes/curated_llvm.sh --phi-off`
- Set: `NYASH_MIR_NO_PHI=1 NYASH_VERIFY_ALLOW_NO_PHI=1`
- Run integration: `tools/smokes/v2/run.sh --profile integration`
- Label the run as legacy in `CURRENT_TASK.md` if results inform shared debugging.
Known Limitations (current)

View File

@ -15,7 +15,7 @@ Stages概要
- Stage A完了
- 文字列スキャンで整数抽出→print、ifリテラル条件の最小到達。
- サンプル: `apps/selfhost-vm/mini_vm*.nyash`
- スモーク: `tools/test/smoke/selfhost/mini_vm_*`
- スモークv2: `tools/smokes/v2/run.sh --profile quick --filter "mini_vm|selfhost"`
- Stage B進行中
- stdinローダ`NYASH_MINIVM_READ_STDIN=1`[実装済]
- JSON v0 ローダの最小強化Print(Literal/FunctionCall)、BinaryOp("+")の最小)[実装中]
@ -36,7 +36,9 @@ Stages概要
実行・導線
- PyVM経由既定: `NYASH_VM_USE_PY=1` で Runner が MIR(JSON)→PyVM へ委譲
- MiniVM入力: `NYASH_MINIVM_READ_STDIN=1` で標準入力を `NYASH_SCRIPT_ARGS_JSON` に注入
- サンプル実行: `bash tools/test/smoke/selfhost/mini_vm_stdin_loader_smoke.sh`
- サンプル実行(例):
- `NYASH_MINIVM_READ_STDIN=1 echo '{"kind":"Program","body":[]}' | ./target/release/nyash --backend vm`
- もしくは v2 ランナーで関連スモークをフィルタ実行
関連
- 現在の短期タスクと進捗: `CURRENT_TASK.md` の「MiniVM 構築ロードマップ(整理)」