feat: MIR TypeOp/WeakRef/Barrier PoC implementation

- Add TypeOpKind, WeakRefOp, BarrierOp enums for unified instructions
- Implement TypeOp instruction combining TypeCheck/Cast
- Implement WeakRef instruction combining WeakNew/WeakLoad
- Implement Barrier instruction combining BarrierRead/BarrierWrite
- Update VM to handle new unified instructions
- Update MIR printer for new instruction formats
- Add feature flags mir_typeop_poc and mir_refbarrier_unify_poc
- Maintain backward compatibility with legacy instructions

This is Phase 8.5 MIR instruction diet PoC implementation.

🤖 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 19:27:02 +09:00
parent 98fd6a1e3e
commit fffbac9aac
25 changed files with 744 additions and 73 deletions

View File

@ -7,29 +7,37 @@
- Net: GET/POSTVM、404/500Ok(Response)、unreachableErr(ErrorBox)
3. VM命令カウンタ時間計測のCLI化`--vm-stats`, `--vm-stats-json`とJSON出力対応
- サンプル/スクリプト整備tools/run_vm_stats.sh、local_tests/vm_stats_*.nyash
4. MIR if-merge 修正retがphi dstを返す Verifier強化mergeでのphi未使用検知
5. ドキュメント追加・更新
- Dynamic Plugin FlowMIR→VM→Registry→Loader→Plugin
- Netプラグインのエラーモデルunreachable=Err, 404/500=Ok
- E2Eテスト一覧整備
6. CI: plugins E2E ジョブLinuxを追加
4. MIR if-merge 修正retがphi dstを返す Verifier強化mergeでのphi未使用検知、支配関係チェック導入
5. VMの健全化分岐・比較・Result
- Compare: Void/BoolのEq/Ne定義順序比較はTypeError
- Branch条件: `BoxRef(BoolBox)→bool``BoxRef(VoidBox)→false``Integer≠0→true`
- ResultBox: 新旧両実装への動的ディスパッチ統一isOk/getValue/getError
6. VMビルトイン強化Array/Map/Socket
- ArrayBox/MapBox: 代表メソッドをVM統合ディスパッチで実装push/get/set/size等
- SocketBox: `acceptTimeout(ms)`void/ `recvTimeout(ms)`(空文字)を追加
- E2E追加: `socket_timeout_server.nyash` / `socket_timeout_client.nyash`
7. ドキュメント追加・更新
- MIR→VMマッピング分岐条件の動的変換、Void/Bool比較
- VM READMESocketBoxタイムアウト/E2E導線・HTTP Result整理
- 26命令ダイエット: PoCフラグと進捗追記TypeOp/WeakRef/Barrier
8. CI: plugins E2E ジョブLinuxを追加
## 🚧 次にやること(再開方針)
1) MIR→VMの健全化短期・最優先
- マッピング表更新Err経路・Handle戻り・Result整合を実測で反映
- Verifierルールの拡充use-before-def across merge を強化
- 成果物: `docs/reference/architecture/mir-to-vm-mapping.md`(更新済・追補
1) 命令セットダイエットのPoC実装短期
- フラグ `mir_typeop_poc` 有効時、Builderで TypeCheck/Cast → TypeOp を出力
- VMにTypeOp実行経路を追加当面は既存と同義
- 次段: `mir_refbarrier_unify_poc` で Weak*/Barrier 統合Builder/VM
- 成果物: スナップショットflag on/off vm-statsで集計キー確認
2) VM×プラグインシステムのE2E検証(短期)
- FileBox/Netを中心にケース拡張大きいボディ、ヘッダー多数、タイムアウト等
- 成果物: E2E追補`VM_README.md` に既知の制約とTipsを追記
2) VM×プラグインのE2E拡張(短期)
- HTTP: 遅延応答・大ボディの計測、到達不能時のERR安定化の再検証
- Socket: タイムアウト系の追加ケース連続acceptTimeout/recvTimeout
- 成果物: E2E追加と `VM_README.md` のTips追補
3) 命令セットのダイエット中期目標26命令
- 実測HTTP OK/404/500/unreachable、FileBoxを反映して合意版を確定
- 統合方針TypeOp/WeakRef/Barrierの統合、ExternCall最小化
- 段階移行(ビルドモードでメタ降格、互換エイリアス→削除)と回帰テスト整備
- 成果物: 26命令案合意版移行計画
3) ResultBox単一路線への統合中期
- `NyashResultBox`へ統合、旧`ResultBox`は薄いラッパーとして段階移行
- 成果物: 実装整理・移行メモ・影響調査
## ▶ 実行コマンド例
@ -58,7 +66,7 @@ nyash --verify examples/plugin_box_sample.nyash
- メタ降格: Debug / Nop / Safepointビルドモードで制御
---
最終更新: 2025年8月23日VM×Plugins安定・MIR修正・26命令合意ドラフト再起動チェックポイント
最終更新: 2025年8月23日VM強化・E2E拡張・TypeOp PoC着手次段はBuilder/VMマッピング
## 🔁 再起動後の再開手順(ショート)
```bash
@ -71,4 +79,8 @@ cargo test --features plugins -q -- --nocapture
# 3) VM Stats 代表値の再取得(任意)
tools/run_vm_stats.sh local_tests/vm_stats_http_ok.nyash vm_stats_ok.json
tools/run_vm_stats.sh local_tests/vm_stats_http_err.nyash vm_stats_err.json
# 4) SocketBox タイムアウト確認(任意)
./target/release/nyash local_tests/socket_timeout_server.nyash
./target/release/nyash local_tests/socket_timeout_client.nyash
```