🎯 革命的発見: プラグインC ABI = JIT→EXE変換の統一基盤 ## 主な変更点 - ArrayBoxプラグイン: get/set/push/size/is_empty実装 - MapBoxプラグイン: size/get/has実装(ROメソッドのみ) - Phase 10.1ドキュメント: プラグインBox統一化計画 - デモファイル3種: プラグイン動作確認用 ## 技術的詳細 - BID-FFI (Box ID Foreign Function Interface) 活用 - 既存のプラグインシステムでJIT/AOT統一可能 - スタティックリンクでオーバーヘッド解消 - "Everything is Box → Everything is Plugin → Everything is Executable" ## テスト済み - array_plugin_demo.nyash: 基本動作確認 ✅ - array_plugin_set_demo.nyash: set操作確認 ✅ - map_plugin_ro_demo.nyash: RO操作確認 ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.3 KiB
3.3 KiB
Phase 10.1 – Plugin Unification Path (MIR→JIT/AOT via C ABI)
This plan refines how we leverage the existing plugin system (BID-FFI) to unify JIT and AOT (EXE) paths using a single C ABI surface.
Goals
- Unify calls from JIT and AOT to the same C ABI (
nyrt_*/nyplug_*). - Convert builtin Boxes to Plugin Boxes in small steps (read-only first).
- Produce a minimal standalone EXE via static linking after unification.
Feasibility Summary
- JIT: emit calls to
extern "C"symbols (no change in semantics, only target). - AOT: emit
.owith unresolvednyrt_*/nyplug_*and link withlibnyrt.a+ plugin.a. - Compatibility: guard with
NYASH_USE_PLUGIN_BUILTINSand keep HostCall fallback.
Phase Breakdown
10.1: Plugin PoC + C ABI base (1 week)
- Deliverables:
- Minimal headers:
nyrt.h(runtime),nyplug_array.h(ArrayBox plugin). - ArrayBox as a plugin (
cdylib+staticlib), ABI version functions. - VM loader integration and
NYASH_USE_PLUGIN_BUILTINSswitch. - Smoke:
new/len/push/getworking via plugin.
- Minimal headers:
- DoD:
- Array plugin works on VM path; perf regression ≤10% on micro bench.
10.2: JIT Lowering unification (Array first) (1–1.5 weeks)
- Deliverables:
- IRBuilder:
emit_plugin_invoke(type_id, method_id, args, sig). - LowerCore BoxCall for Array routes to
plugin_invoke(events/stats intact). - Feature-flagged enablement:
NYASH_USE_PLUGIN_BUILTINS=1.
- IRBuilder:
- DoD:
- JIT execution of Array read/write (policy-constrained) via plugin path.
- Behavior parity with HostCall; no regressions on CI smoke.
10.3: Broaden plugin coverage + Compatibility (2 weeks)
- Targets: String/Integer/Bool/Map (read-only first).
- Deliverables:
- Pluginized Boxes and
plugin_invokelowering for BoxCall. - HostCall route retained; whitelist-driven co-existence.
- Added smoke and microbenches comparing HostCall vs Plugin.
- Pluginized Boxes and
- DoD:
- ≥5 builtin Boxes pluginized;
NYASH_USE_PLUGIN_BUILTINS=1green on smoke.
- ≥5 builtin Boxes pluginized;
10.4: AOT/EXE minimal pipeline (2–3 weeks)
- Deliverables:
- ObjectWriter path to emit
.owith unresolvednyrt_*/nyplug_*. libnyrt.aminimal runtime + selected plugin.a.- Link scripts and
nyc build-aotproof-of-concept. - Hello World-level standalone EXE on Linux/macOS.
- ObjectWriter path to emit
- DoD:
nyc build-aot <file.nyash> -o appruns without JIT/VM.- Basic debug info and minimal unwind.
10.5: Python Integration (moved; separate phase)
- Python work is deferred to 10.5 and builds on the plugin/AOT foundation.
Flags & Compatibility
NYASH_USE_PLUGIN_BUILTINS=1– enables plugin path for builtin Boxes.NYASH_JIT_HOSTCALL=1– preserves HostCall path for comparison.- Call conv alignment: x86_64 SysV, aarch64 AAPCS64, Win64.
- ABI version checks:
nyrt_abi_version(),nyplug_*_abi_version()hard-fail on mismatch.
Risks & Mitigations
- ABI drift: minimal headers + version checks.
- Linking complexity: start with the smallest set (Array/Print/GC-minimal), expand gradually.
- Performance: keep RO-first; benchmark and fall back to HostCall if needed.
- Windows linkage: prioritize Linux/macOS, then handle Win specifics in a follow-up task.
References
c_abi_unified_design.mdimplementation_steps.md../phase-10.5/(Python integration)
Everything is Plugin → unified paths for JIT and AOT.