feat: Add VM statistics and fix compilation errors for plugin tests

- Add VM instruction statistics (--vm-stats, --vm-stats-json)
- Fix missing fields in ast.rs test code (public_fields, private_fields)
- Add CliConfig fields for VM statistics
- Enable TLV debug logging in plugin_loader_v2
- Successfully test FileBox handle passing and HTTP plugin creation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-23 04:51:24 +09:00
parent dd09e81018
commit 63749b683e
12 changed files with 360 additions and 7 deletions

View File

@ -126,6 +126,40 @@ bb0:
- **基本ブロック**: 制御フロー最適化
- **効果追跡**: 副作用の管理
- **型安全**: 実行時型チェック
- **対応状況**: 命令ごとの実装は「MIR → VM Mapping」を参照欠落・暫定箇所の把握に
- docs/reference/architecture/mir-to-vm-mapping.md
### 🧮 VM実行統計命令カウント・時間計測
VMバックエンドは命令ごとの実行回数と総実行時間(ms)を出力できます。
有効化方法CLI推奨:
```bash
# 人間向け表示
nyash --backend vm --vm-stats program.nyash
# JSON出力機械可読
nyash --backend vm --vm-stats --vm-stats-json program.nyash
```
環境変数でも制御可能:
```bash
NYASH_VM_STATS=1 ./target/release/nyash --backend vm program.nyash
NYASH_VM_STATS=1 NYASH_VM_STATS_JSON=1 ./target/release/nyash --backend vm program.nyash
# もしくは NYASH_VM_STATS_FORMAT=json でも可
```
JSON出力例:
```json
{
"total": 1234,
"elapsed_ms": 5.123,
"counts": { "Const": 200, "BinOp": 300, "Return": 100 },
"top20": [ { "op": "BinOp", "count": 300 } ],
"timestamp_ms": 1724371200000
}
```
ベンチマークと併用して、ホット命令の抽出・命令セット最適化に活用できます。
## 🌐 WASM実行Web対応
@ -336,4 +370,4 @@ nyash --compile-wasm app.nyash -o public/app.wat
**💡 Tip**: 開発中は**インタープリター**、テスト時は**VM**、配布時は**WASM**という使い分けが効果的です!
最終更新: 2025-08-14
作成者: Nyash Development Team
作成者: Nyash Development Team