🎉 Phase 11.8/12.7: MIR Core-13 完全実装 + 糖衣構文ドキュメント更新

主要な変更:
- MIR Core-13命令セット確定(Load/Store削除の革命的設計)
  - Const, BinOp, Compare(値・計算)
  - Jump, Branch, Return, Phi(制御)
  - Call, BoxCall, ExternCall(呼び出し)
  - TypeOp, Safepoint, Barrier(メタ)
- Phase 12.7糖衣構文ドキュメント整理(超圧縮重視、可逆変換保証)
- MIRビルダーのモジュール分割完了
- vtableテストスイート拡充
- AI協調開発ツール追加(並列リファクタリング支援)

詳細:
- src/mir/instruction_introspection.rs: core13_instruction_names()追加
- MIRビルダー分割: decls.rs, exprs_*.rs, fields.rs
- plugin_loader_v2: errors.rs, host_bridge.rs分離
- 論文用データ: mir13-final.md作成

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-09-04 11:34:15 +09:00
parent 4e824fa00e
commit fb2d8e37d5
62 changed files with 3632 additions and 835 deletions

View File

@ -762,10 +762,6 @@ pub(super) extern "C" fn nyash_string_from_ptr(ptr: u64, len: u64) -> i64 {
}
// ===== FunctionBox call shims (by arity, up to 4) =====
#[cfg(feature = "cranelift-jit")]
fn vmvalue_from_jit_arg_i64(v: i64) -> crate::backend::vm::VMValue { super::vmvalue_from_jit_arg_i64(v) }
#[cfg(feature = "cranelift-jit")]
fn i64_from_vmvalue(v: crate::backend::vm::VMValue) -> i64 { super::i64_from_vmvalue(v) }
#[cfg(feature = "cranelift-jit")]
fn fn_call_impl(func_h: u64, args: &[i64]) -> i64 {

View File

@ -1,8 +1,7 @@
//! InvokePolicyPass (minimal scaffold)
//! Centralizes decision for plugin/hostcall/any to keep lowerer slim.
//! Current implementation covers a small subset (ArrayBox length/get/set/push,
//! MapBox size/get/has/set) when NYASH_USE_PLUGIN_BUILTINS=1, falling back
//! to existing hostcall symbols otherwise. Extend incrementally.
//! Centralizes decision for plugin/hostcall to keep lowerer slim.
//! HostCall優先Core-13方針。ENV `NYASH_USE_PLUGIN_BUILTINS=1` の場合のみ
//! plugin_invoke を試し、解決できない場合はHostCallへフォールバックする。
#[derive(Debug, Clone)]
pub enum InvokeDecision {
@ -17,15 +16,7 @@ fn use_plugin_builtins() -> bool {
/// Decide invocation policy for a known Box method.
pub fn decide_box_method(box_type: &str, method: &str, argc: usize, has_ret: bool) -> InvokeDecision {
// Prefer plugin path when enabled and method is resolvable
if use_plugin_builtins() {
if let Ok(ph) = crate::runtime::plugin_loader_unified::get_global_plugin_host().read() {
if let Ok(h) = ph.resolve_method(box_type, method) {
return InvokeDecision::PluginInvoke { type_id: h.type_id, method_id: h.method_id, box_type: h.box_type, method: method.to_string(), argc, has_ret };
}
}
}
// Minimal hostcall mapping for common collections/math symbols
// HostCall mapping for common collections/strings/instance ops
let symbol = match (box_type, method) {
("ArrayBox", "length") | ("StringBox", "length") | ("StringBox", "len") => crate::jit::r#extern::collections::SYM_ANY_LEN_H,
("ArrayBox", "get") => crate::jit::r#extern::collections::SYM_ARRAY_GET_H,
@ -39,9 +30,18 @@ pub fn decide_box_method(box_type: &str, method: &str, argc: usize, has_ret: boo
("StringBox","charCodeAt") => crate::jit::r#extern::collections::SYM_STRING_CHARCODE_AT_H,
_ => "" // unknown
};
if symbol.is_empty() {
// Prefer HostCall when available
if !symbol.is_empty() {
InvokeDecision::HostCall { symbol: symbol.to_string(), argc, has_ret, reason: "mapped_symbol" }
} else if use_plugin_builtins() {
// Try plugin_invoke as a secondary path when enabled
if let Ok(ph) = crate::runtime::plugin_loader_unified::get_global_plugin_host().read() {
if let Ok(h) = ph.resolve_method(box_type, method) {
return InvokeDecision::PluginInvoke { type_id: h.type_id, method_id: h.method_id, box_type: h.box_type, method: method.to_string(), argc, has_ret };
}
}
InvokeDecision::Fallback { reason: "unknown_method" }
} else {
InvokeDecision::HostCall { symbol: symbol.to_string(), argc, has_ret, reason: "mapped_symbol" }
InvokeDecision::Fallback { reason: "unknown_method" }
}
}