Files
hakorune/docs/research/paper-11-compiler-knows-nothing
Moe Charm b003bdf25b 📚 Phase 11 documentation: Everything is Box × MIR15 revolution
Key updates:
- Document MIR 26→15 instruction reduction plan (transitioning status)
- Add Core-15 target instruction set in INSTRUCTION_SET.md
- Save AI conference analyses validating Box Theory and 15-instruction design
- Create MIR annotation system proposal for optimization hints
- Update SKIP_PHASE_10_DECISION.md with LLVM direct migration rationale

Technical insights:
- RefNew/RefGet/RefSet can be eliminated through Box unification
- GC/sync/async all achievable with 15 core instructions
- BoxCall lowering can automatically insert GC barriers
- 2-3x performance improvement expected with LLVM
- Build time reduction 50%, binary size reduction 40%

Status: Design complete, implementation pending
2025-08-31 03:03:04 +09:00
..

Paper 11: コンパイラは世界を知らないPluginInvoke一元化と"フォールバック廃止"の実践

Status: Planning
Target: Systems/Engineering Conference (OSDI/SOSP/ASPLOS)
Lead Author: Nyash Team

📋 論文概要

タイトル

The Compiler Knows Nothing: PluginInvoke Unification and the Practice of "No Fallback" Policy

中心的主張

  • コンパイラからドメイン知識を完全排除し、全てをPluginInvokeに一元化
  • フォールバック全廃により複雑性爆発を回避し、保守性を最大化
  • 対応表1枚mir→vm→jitで全ての拡張を管理可能に

主要貢献

  1. 設計原則:「コンパイラは世界を知らない」哲学の体系化
  2. 実装手法:フォールバック廃止による複雑性制御
  3. 運用知見:プラグインエコシステムの実践的構築法

🔧 実証データ計画

フォールバック削減の定量化

削減前Phase 9:
- 型名分岐: 47箇所
- 特殊処理: 23箇所
- フォールバック: 15箇所

削減後Phase 10.11:
- 型名分岐: 0箇所
- 特殊処理: 0箇所
- フォールバック: 0箇所

保守性メトリクス

コード変更影響範囲:
- 新Box追加時の変更行数: 0行プラグインのみ
- 新機能追加時の変更行数: 0行プラグインのみ
- コンパイラ本体の安定性: 100%(変更不要)

プラグイン統合実績

統合成功例:
- Python統合: 2日eval/import/getattr/call
- ファイルI/O: 1日
- ネットワーク: 1日
- 数学関数: 0.5日

📊 実践的証明

型名分岐の回避例Before/After

Beforeアンチパターン:

match box_type {
    "StringBox" => self.emit_string_length(),
    "ArrayBox" => self.emit_array_length(),
    "FileBox" => self.emit_file_size(),
    // 新しいBoxごとに分岐追加... 😱
}

AfterPluginInvoke一元化:

self.emit_plugin_invoke(type_id, method_id, args)
// 新しいBox追加時もコード変更不要 🎉

CI/CDによる品質保証

禁止パターンCI:
- 型名文字列による分岐
- ビルトイン特殊処理
- フォールバック実装

必須テスト:
- trace_hash等価性VM/JIT/AOT
- プラグイン境界テスト
- ABI互換性チェック

🏗️ アーキテクチャ設計

対応表による一元管理

MIR → VM → JIT/AOT マッピング:
┌─────────────┬────────────────┬─────────────────┐
│ MIR命令     │ VM実装         │ JIT/AOT実装     │
├─────────────┼────────────────┼─────────────────┤
│ PluginInvoke│ plugin_invoke()│ emit_plugin_call│
└─────────────┴────────────────┴─────────────────┘
1行で全てを表現

ABI v0の設計

最小限のFFI契約:
- invoke(type_id, method_id, args) → TLV
- 引数: TLVエンコード
- 戻り値: TLVエンコード
- エラー: Result<TLV, String>

📝 論文構成(予定)

1. Introduction2ページ

  • 問題:言語実装の複雑性爆発
  • 解決:ドメイン知識のプラグイン分離
  • 影響:保守性と拡張性の両立

2. Design Philosophy3ページ

  • 「コンパイラは世界を知らない」原則
  • フォールバック廃止の必要性
  • プラグイン境界の設計

3. Implementation4ページ

  • PluginInvoke一元化の実装
  • 型名分岐の除去プロセス
  • CI/CDによる品質維持

4. Case Studies3ページ

  • Python統合複雑な例
  • FileBoxI/O例
  • NetworkBox非同期例

5. Evaluation3ページ

  • 保守性の定量評価
  • 性能オーバーヘッド分析
  • 開発効率の改善

6. Lessons Learned2ページ

  • 成功要因の分析
  • 失敗と回避策
  • ベストプラクティス
  • プラグインアーキテクチャ
  • 言語拡張機構
  • モジュラーコンパイラ

8. Conclusion1ページ

🎯 執筆スケジュール

  • Week 1: 実装データ収集・整理
  • Week 2: Philosophy + Implementation執筆
  • Week 3: Case Studies執筆
  • Week 4: Evaluation + Lessons執筆
  • Week 5: 推敲・コード例整備

💡 期待される影響

学術的影響

  • コンパイラ設計の新しいパラダイム
  • 複雑性管理の体系的手法
  • プラグインエコシステムの理論

実務的影響

  • 言語実装のベストプラクティス集
  • 保守可能な言語の作り方
  • 拡張可能なアーキテクチャ設計

📚 参考文献(予定)

  • The Cathedral and the Bazaar (ESR)
  • Design Patterns (GoF)
  • Clean Architecture (Robert C. Martin)
  • LLVM: A Compilation Framework for Lifelong Program Analysis
  • The Art of Unix Programming