Files
hakorune/docs/development/roadmap/phases/phase-11.7_jit_complete
Moe Charm 59b8cb3ace Phase 11.9: 統一文法アーキテクチャ作業中 - MIR builder分割とJIT lower整理
- MIR builder: stmts/exprs/typeingモジュール分割による整理
- JIT lower: core/ops_ext.rs追加(外部呼び出し系の分離)
- 統一文法エンジン基盤構築中(grammar/unified-grammar.toml対応)
- ChatGPT5協調作業: M1完了、M2作業中

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 01:37:38 +09:00
..

Phase 11.7 JIT Complete (MIR-15 + Semantics + Sync/Async GC)

Scope: Implement a productionready JIT backend for Nyash that fully supports the MIR Core15 instruction set, synchronous/async GC cooperation, and delivers a simple, reproducible developer experience across platforms (WSL/Linux/Windows).

Why now:

  • LLVM AOT は一度実装を進めたが、Windows 依存が重くサイズも大きい。Cranelift に回帰して、純Rustで“Just Works”のDXを取り戻し、高速な反復開発を実現するAOT/LLVMは資料として保持

Outcomes (Definition of Done):

  • All MIR15 ops compile and execute via JIT with behavioral parity to VM.
  • BoxCall/ExternCall are handled through NyRT shims (handlefirst ABI) safely.
  • Sync GC barriers in place (read/write), async safepoints wired at call/loop edges.
  • Smokes: echo/array/map/vinvoke/extern pass; parity checks vs VM/JIT (logs included).
  • 1command setup and run on WSL + Windows Dev PowerShell; no external LLVM needed.

Backends Strategy:

  • LLVM AOT はアーカイブ(参照は可)。主線は CraneliftJIT/軽量AOT
  • JIT 既定は Craneliftfeature: cranelift-jit。AOT は必要に応じ cranelift-object を併用。

This folder contains the living plan (PLAN.md) and the rolling snapshot of the current task focus (CURRENT_TASK.md). Semantics 層の導入により、Nyash スクリプトVMJITexeの動作を一致させる。

JIT Single-Exit Policy and TRACE

  • Single-Exit: JIT は関数終端で単一の ret ブロックに合流する方針。分岐合流は BlockParam最小PHIで表現し、end_function で最終 seal を行う。
  • Branch Fast-Path: then/else がともに i64 定数を即時 return する場合、select(cond, K_then, K_else)return に縮約(常時有効)。
  • TRACE 環境変数必要時のみON:
    • NYASH_JIT_DUMP=1 …… Lower の要約/CFGライトダンプを表示
    • NYASH_JIT_TRACE_BLOCKS=1 … ブロック入場ログ([JIT-BLOCK] enter=<idx>
    • NYASH_JIT_TRACE_BR=1 …… br_if の cond 有無ログ
    • NYASH_JIT_TRACE_SEL=1 … select の cond/then/else 値tag=100/101/102
    • NYASH_JIT_TRACE_RET=1 … return 値ログtag=201=直前, 200=合流)

Notes:

  • 旧フラグ NYASH_JIT_FASTPATH_SELECT は不要になりました(存在しても無視)。