wip(jit): AOTコア機能の継続的改善

JIT/AOTシステムのコア部分の改修を継続。
ChatGPTによる詳細な実装作業。

主な変更点:
- extern/collections.rs: 外部関数コレクション管理の改善
- lower/builder/cranelift.rs: Craneliftビルダーの最適化
- lower/core.rs: コア lowering ロジックの改修
- lower/core/ops_ext.rs: 拡張演算子のlowering処理
- lower/extern_thunks.rs: 外部関数サンクの実装改善

AOTビルドの安定性向上に向けた継続的な作業。

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Tomoaki
2025-09-06 06:46:04 +09:00
parent 7d88c04c0e
commit 4c5301e700
5 changed files with 65 additions and 19 deletions

View File

@ -539,6 +539,34 @@ pub(super) extern "C" fn nyash_string_charcode_at_h(handle: u64, idx: i64) -> i6
-1
}
// String.len_h(handle) -> i64 with param-index fallback (JIT bridge)
#[cfg(feature = "cranelift-jit")]
pub(super) extern "C" fn nyash_string_len_h(handle: u64) -> i64 {
events::emit_runtime(serde_json::json!({"id": c::SYM_STRING_LEN_H, "decision":"allow", "argc":1, "arg_types":["Handle"]}), "hostcall", "<jit>");
if handle > 0 {
if let Some(obj) = crate::jit::rt::handles::get(handle) {
if let Some(sb) = obj.as_any().downcast_ref::<crate::box_trait::StringBox>() { return sb.value.len() as i64; }
}
// Fallback to any.length_h for non-string handles
return nyash_any_length_h(handle);
}
// Legacy param index fallback (0..16): read from VM args
if handle <= 16 {
let idx = handle as usize;
let val = crate::jit::rt::with_legacy_vm_args(|args| args.get(idx).cloned());
if let Some(v) = val {
match v {
crate::backend::vm::VMValue::BoxRef(b) => {
if let Some(sb) = b.as_any().downcast_ref::<crate::box_trait::StringBox>() { return sb.value.len() as i64; }
}
crate::backend::vm::VMValue::String(s) => { return s.len() as i64; }
_ => {}
}
}
}
0
}
// ---- Birth (handle) ----
#[cfg(feature = "cranelift-jit")]
pub(super) extern "C" fn nyash_string_birth_h() -> i64 {