Files
hakorune/docs/reference/mir/INSTRUCTION_SET.md
Moe Charm c9366d5c54 Phase 11.8/12: MIR Core-13 roadmap, Nyash ABI design, async/await enhancements with TaskGroupBox foundation
Major additions:
- Phase 11.8 MIR cleanup specification (Core-15→14→13 roadmap)
- Nyash ABI unified design document (3×u64 structure)
- TaskGroupBox foundation with cancelAll/joinAll methods
- Enhanced async/await with checkpoint auto-insertion
- Structured concurrency preparation (parent-child task relationships)

Documentation:
- docs/development/roadmap/phases/phase-11.8_mir_cleanup/: Complete Core-13 path
- docs/development/roadmap/phases/phase-12/NYASH-ABI-DESIGN.md: Unified ABI spec
- Updated Phase 12 README with AOT/JIT explanation for script performance
- Added async_task_system/ design docs

Implementation progress:
- FutureBox spawn tracking with weak/strong reference management
- VM checkpoint integration before/after await
- LLVM backend async support preparation
- Verifier rules for await-checkpoint enforcement
- Result<T,E> normalization for timeout/cancellation

Technical insights:
- MIR as 'atomic instructions', Box as 'molecules' philosophy
- 'Everything is Box' enables full-stack with minimal instructions
- Unified BoxCall for array/plugin/async operations future consolidation

Next steps:
- Complete TaskGroupBox implementation
- Migrate from global to scoped task management
- Implement LIFO cleanup on scope exit
- Continue Core-13 instruction consolidation

🚀 'From 15 atoms to infinite programs: The Nyash Box Theory'
2025-09-02 03:41:51 +09:00

82 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Nyash MIR Instruction Set (Canonical 26 → migrating to Core-15 → Core-14)
Status: Canonical (Source of Truth) — transitioning
Last Updated: 2025-09-01
この文書はNyashのMIR命令セットの唯一の参照現状は26命令だよ。Core-15 への段階移行を進めており、さらに Phase 12 で Core-14 へPluginInvoke → BoxCall 統合。安定次第この文書を14命令へ更新し、テスト固定数も切り替える移行中は26を維持
注意: Debug/Nop/Safepointはビルドモードでの降格用メタ命令であり、コア命令数には数えない。
Transition Note
- Builder/Rewrite/JIT は既に以下の統合を段階適用中
- TypeCheck/Cast → TypeOp
- WeakNew/WeakLoad → WeakRef
- BarrierRead/BarrierWrite → Barrier
- Print → ExternCall(env.console.log)Deprecated
- PluginInvoke → BoxCallDeprecated; 名前/スロット解決はBoxCall側で処理
- Phase 12ビルトインBox廃止での追加統合
- PluginInvoke → BoxCall 完全統合(ビルトインフォールバックがなくなるため区別不要)
- VM層でC ABI/Nyash ABI/Scriptプラグインを自動判定
- VM/JIT の代表的な Core-15 カバー手順は `docs/reference/mir/MIR15_COVERAGE_CHECKLIST.md` を参照。
- Core-14 安定後に本ドキュメントの「Core Instructions」を14命令へ更新し、マッピング表を併記する。
## Core Instructions26
- Const
- Copy
- Load
- Store
- UnaryOp
- BinOp
- Compare
- Jump
- Branch
- Phi
- Return
- Call
- ExternCall
- BoxCall
- Note: BoxCall carries optional `method_id` (numeric slot) when the builder can resolve the receiver type; otherwise falls back to name-only late bind. Universal methods use reserved slots: 0=toString, 1=type, 2=equals, 3=clone.
- NewBox
- ArrayGet
- ArraySet
- RefNew
- RefGet
- RefSet
- Await
- PrintDeprecated: ビルダーは発行しない。代わりに `ExternCall env.console.log` を使用)
- TypeOpTypeCheck/Cast統合
- WeakRefWeakNew/WeakLoad統合
- BarrierRead/Write統合
## Core-15Target; 移行中の最小コア)
- 基本演算(5): Const, UnaryOp, BinOp, Compare, TypeOp
- メモリ(2): Load, Store
- 制御(4): Branch, Jump, Return, Phi
- Box(3): NewBox, BoxCall, PluginInvoke
- 配列(2): ArrayGet, ArraySet
- 外部(1): ExternCall
## Core-14Phase 12 Target; PluginInvoke統合後
- 基本演算(5): Const, UnaryOp, BinOp, Compare, TypeOp
- メモリ(2): Load, Store
- 制御(4): Branch, Jump, Return, Phi
- Box(2): NewBox, BoxCall ← PluginInvokeを吸収
- 配列(2): ArrayGet, ArraySet
- 外部(1): ExternCall
Notes
- Print/Debug/Safepointはメタ/Extern化Print→ExternCall
- WeakRef/Barrier は統合済み旧WeakNew/WeakLoad/BarrierRead/WriteはRewriteで互換
- Call は BoxCall へ集約PluginInvokeはDeprecated → Phase 12で完全統合
- Phase 12: ビルトインBox廃止により、BoxCallとPluginInvokeの区別が不要に。VM層でABI判定。
## Meta (降格対象; カウント外)
- Debug
- Nop
- Safepoint
## 同期ルール
- 命令の追加/削除/統合は、まずこの文書を更新し、次に実装(列挙/Printer/Verifier/Optimizer/VMを同期。最後に「総数=26」テストを更新する。
- 実装が26を外れた場合はCIを赤にする設計の合意なく増減させないため