Phase 11-12: LLVM backend initial, semantics layer, plugin unification

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>
This commit is contained in:
Moe Charm
2025-09-01 23:44:34 +09:00
parent fff9749f47
commit 11506cee3b
196 changed files with 10955 additions and 380 deletions

View File

@ -161,6 +161,8 @@ pub(super) extern "C" fn nyash_rt_checkpoint() -> i64 {
if std::env::var("NYASH_RUNTIME_CHECKPOINT_TRACE").ok().as_deref() == Some("1") {
eprintln!("[nyash.rt.checkpoint] reached");
}
// Bridge to GC/scheduler if configured
crate::runtime::global_hooks::safepoint_and_poll();
0
}
@ -620,3 +622,31 @@ pub(super) extern "C" fn nyash_string_lt_hh(a_h: u64, b_h: u64) -> i64 {
let b = handle_to_string_like(b_h).unwrap_or_default();
if a < b { 1 } else { 0 }
}
// Unified semantics: addition for dynamic boxes via shared coercions
#[cfg(feature = "cranelift-jit")]
pub(super) extern "C" fn nyash_semantics_add_hh(lhs_h: u64, rhs_h: u64) -> i64 {
events::emit_runtime(serde_json::json!({"id": crate::jit::r#extern::collections::SYM_SEMANTICS_ADD_HH, "decision":"allow", "argc":2, "arg_types":["Handle","Handle"]}), "hostcall", "<jit>");
use crate::runtime::semantics;
use crate::box_trait::{StringBox, IntegerBox};
use crate::jit::rt::handles;
let lhs = if let Some(o) = handles::get(lhs_h) { o } else { return 0 };
let rhs = if let Some(o) = handles::get(rhs_h) { o } else { return 0 };
let ls_opt = semantics::coerce_to_string(lhs.as_ref());
let rs_opt = semantics::coerce_to_string(rhs.as_ref());
if ls_opt.is_some() || rs_opt.is_some() {
let ls = ls_opt.unwrap_or_else(|| lhs.to_string_box().value);
let rs = rs_opt.unwrap_or_else(|| rhs.to_string_box().value);
let s = format!("{}{}", ls, rs);
let arc: std::sync::Arc<dyn crate::box_trait::NyashBox> = std::sync::Arc::new(StringBox::new(s));
return handles::to_handle(arc) as i64;
}
if let (Some(li), Some(ri)) = (semantics::coerce_to_i64(lhs.as_ref()), semantics::coerce_to_i64(rhs.as_ref())) {
let arc: std::sync::Arc<dyn crate::box_trait::NyashBox> = std::sync::Arc::new(IntegerBox::new(li + ri));
return handles::to_handle(arc) as i64;
}
// Fallback stringify concat
let s = format!("{}{}", lhs.to_string_box().value, rhs.to_string_box().value);
let arc: std::sync::Arc<dyn crate::box_trait::NyashBox> = std::sync::Arc::new(StringBox::new(s));
handles::to_handle(arc) as i64
}