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

@ -13,7 +13,7 @@ Entries
- Summary: If-join used to effectively handle at most two samename variable assignments per join when emitting PHI groups.
- Impact: LLVM harness (PHI wiring)
- Fix: FinalizePHI wiring + join result observation; normalized to handle N variables.
- Tests: `tools/test/smoke/llvm/ir_phi_hygiene_if_phi_ret.sh`, `tools/test/smoke/mir/hints_join_result_three_vars_smoke.sh`
- Tests (v2): use `tools/smokes/v2/run.sh --profile integration` (LLVM PHI invariants covered in integration suite)
- Notes: Keep IR hygiene smokes minimal in CI; more exhaustive coverage can run locally.
## CF-PHI-0002 — Empty PHI sanitize switch
@ -22,20 +22,20 @@ Entries
- Impact: LLVM harness only
- Gate: `NYASH_LLVM_SANITIZE_EMPTY_PHI=1`
- Exit criteria: PHI wiring guarantees no empty PHIs across Loop/If/Match; remove sanitize path.
- Tests: `tools/test/smoke/llvm/ir_phi_empty_check.sh`
- Tests (v2): covered by `tools/smokes/v2` integration runs; legacy scripts were removed
## CF-LOOP-0006 — Nested bare blocks with break/continue in loops
- Status: Resolved
- Summary: Previously, a `break`/`continue` inside a nested bare block (`{ ... }`) within a loop could bypass loop-aware lowering in certain cases.
- Impact: MIR builder (LoopBuilder vs generic block handling)
- Fix: LoopBuilder now lowers `Program` nodes by recursing through statements with termination checks; `break/continue` inside nested blocks route to the loop header/exit uniformly.
- Tests: `tools/test/smoke/macro/loop_nested_block_break_output_smoke.sh`
- Tests (v2): covered in `tools/smokes/v2` macro cases (legacy paths removed)
## CF-MATCH-0003 — Scrutinee single evaluation
- Status: Stable
- Summary: Scrutinee is evaluated once and stored in a gensym (e.g., `__ny_match_scrutinee_X`).
- Impact: Parser/Normalizer/All backends
- Tests: `tools/test/golden/macro/match_literal_basic.expanded.json`, output smokes under `tools/test/smoke/macro/`.
- Tests (v2): goldens remain; execution smokes are under `tools/smokes/v2` (legacy paths removed)
- Notes: Golden comparison may normalize gensym names in the future to reduce brittleness.
## EXC-PFX-0004 — Postfix catch/cleanup precedence
@ -43,7 +43,7 @@ Entries
- Summary: Postfix attaches to the immediately preceding expression (call/chain) and stops further chaining. Normalizes to a single TryCatch.
- Impact: Parser/Normalizer/All backends
- Gate: `NYASH_PARSER_STAGE3=1` (direct parsing); `NYASH_CATCH_NEW=1` (sugar normalization)
- Tests: `tools/test/smoke/macro/expr_postfix_catch_cleanup_output_smoke.sh`, `tools/test/smoke/mir/hints_scope_trycatch_smoke.sh`, `src/tests/parser_expr_postfix_catch.rs`
- Tests (v2): see `tools/smokes/v2` and `src/tests/parser_expr_postfix_catch.rs` (legacy paths removed)
## MACRO-CAPS-0005 — Macro sandbox capabilities (io/net/env)
- Status: Stable MVP

View File

@ -125,14 +125,14 @@ cargo build --release
./target/release/plugin-tester check path/to/your/plugin.so
```
### 5. **nyash_box.toml テンプレ & スモーク** 🆕
### 5. **nyash_box.toml テンプレ & スモークv2** 🆕
- テンプレート: `docs/reference/plugin-system/nyash_box.toml.template`
- スモーク実行VM・厳格チェックON:
- スモーク実行VM・動的プラグイン:
```bash
bash tools/smoke_plugins.sh
tools/smokes/v2/run.sh --profile plugins
```
- 実行内容: Python デモと Integer デモを `NYASH_PLUGIN_STRICT=1` で起動し、nyash_box.toml 経路のロードと実行を確認
- 事前条件: `cargo build --release --features cranelift-jit` 済み、各プラグインも release ビルド済み
- 代表ケースFixture/Counter/Math など)を自動検証。未配置の .so は SKIP で安全に進行
- 事前条件: `cargo build --release` 済み。必要に応じて `tools/smokes/v2/profiles/plugins/_ensure_fixture.sh` がフィクスチャを自動構築
### 6. **プラグイン優先(ビルトイン上書き)設定** 🆕
- 既定では、ビルトインの実装が優先されます(安全第一)。