AOT/JIT: StringBox.length デバッグ追跡とローカル材化強化

- ops_ext: StringBox.len/lengthの結果を必ずローカルに保存
  - param/local/literal/handle.of全経路で dst があれば local_index に格納
  - Returnが確実に値を拾えるよう修正

- デバッグ計測追加:
  - NYASH_JIT_TRACE_LOWER: BoxCall処理の追跡
  - NYASH_JIT_TRACE_RET: Return時の値解決追跡
  - NYASH_JIT_TRACE_LOCAL: ローカルslot I/O追跡
  - NYASH_JIT_TRACE_LEN: string.len_h thunk実行追跡

- 診断用プローブ追加: tmp_len_stringbox_probe.nyash
- CURRENT_TASK更新: 3rdハンドオフ進捗記録

現状: lowering/Return/ローカル材化は正しく配線されているが、
hostcall実行時に0を返している疑い。シンボル解決の追跡継続中。

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Tomoaki
2025-09-06 07:45:20 +09:00
parent 4c5301e700
commit 8c02093cfe
6 changed files with 255 additions and 18 deletions

View File

@ -543,12 +543,15 @@ pub(super) extern "C" fn nyash_string_charcode_at_h(handle: u64, idx: i64) -> i6
#[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 std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") { eprintln!("[JIT-LEN_H] handle={}", handle); }
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);
let v = nyash_any_length_h(handle);
if std::env::var("NYASH_JIT_TRACE_LEN").ok().as_deref() == Some("1") { eprintln!("[JIT-LEN_H] any.length_h(handle={}) -> {}", handle, v); }
return v;
}
// Legacy param index fallback (0..16): read from VM args
if handle <= 16 {