Major changes: - LLVM backend initial implementation (compiler.rs, llvm mode) - Semantics layer integration in interpreter (operators.rs) - Phase 12 plugin architecture revision (3-layer system) - Builtin box removal preparation - MIR instruction set documentation (26→Core-15 migration) - Cross-backend testing infrastructure - Await/nowait syntax support New features: - LLVM AOT compilation support (--backend llvm) - Semantics layer for interpreter→VM flow - Tri-backend smoke tests - Plugin-only registry mode Bug fixes: - Interpreter plugin box arithmetic operations - Branch test returns incorrect values Documentation: - Phase 12 README.md updated with new plugin architecture - Removed obsolete NYIR proposals - Added LLVM test programs documentation Co-Authored-By: Claude <noreply@anthropic.com>
2.8 KiB
2.8 KiB
論文構成案:Nyash - 1ヶ月で完走した独自言語処理系
1. はじめに(Introduction)
- 背景:従来の言語開発の時間的コスト
- 動機:高速プロトタイピングの必要性
- 貢献:1ヶ月での完全言語処理系実現
2. 設計理念(Design Philosophy)
2.1 Everything is Box
- すべてのデータ型をBoxで統一
- メモリ安全性とシンプルさの両立
- プラグインシステムとの親和性
2.2 多段階実行モデル
- Interpreter → VM → JIT → AOT
- MIRを中心とした統一的な中間表現
2.3 意味論等価性の保証
- 全実行モードで同一の振る舞い
- GC有無による差異の排除
3. 実装(Implementation)
3.1 システムアーキテクチャ
Nyash Source → Parser → AST → MIR Builder → MIR
↓
┌─────────┼─────────┐
↓ ↓ ↓
Interpreter VM JIT/AOT
3.2 MIR設計
- 15命令の最小命令セット(当初26命令から削減)
- 型安全性と最適化容易性
3.3 JIT/AOTパイプライン
- Cranelift統合
- プラグインBox C ABI
- ネイティブコード生成
3.4 実装規模
- 総行数:約4,000行
- モジュール構成
- 外部依存の最小化
4. 評価(Evaluation)
4.1 性能評価
- ベンチマーク設計
- フィボナッチ数列
- 配列操作
- 文字列処理
- I/O混在ワークロード
- VM基準での相対性能
- JIT: 13.5倍
- AOT: XX倍(測定予定)
4.2 意味論等価性検証
- テストスイート
- I/Oトレース比較
- GC on/offでの挙動一致
4.3 実装効率
- 開発期間:1ヶ月
- コード行数 vs 機能範囲
- 他言語処理系との比較
4.4 配布可能性
- 実行ファイルサイズ(~1MB)
- 依存ライブラリなし
- クロスプラットフォーム対応
5. 関連研究(Related Work)
5.1 高速言語開発
- TinyCC
- Zig self-hosting
- V language
5.2 統一実行モデル
- GraalVM
- PyPy
- Truffle/Graal
5.3 軽量JIT
- LuaJIT
- JavaScriptCore
6. 考察(Discussion)
6.1 成功要因の分析
- 設計のシンプルさ
- 既存技術の効果的活用(Cranelift)
- 段階的実装アプローチ
6.2 制限事項
- 最適化の余地
- エコシステムの未成熟
- デバッグ機能の限定
6.3 今後の展望
- GPU対応
- 並列実行
- 型システムの拡張
7. 結論(Conclusion)
- 1ヶ月での完全言語処理系実現を実証
- 軽量アーキテクチャの有効性
- 新たな言語開発手法の提案
付録(Appendix)
- A. MIR命令セット詳細
- B. ベンチマークコード
- C. 再現可能性のための環境構築手順