feat(phase21.5): strlen FAST EXE + loop JSONFrag diagnostics

## Task A: emit v0 boxcall (bin version) 
- Fix: emit_mir_json_for_harness_bin now handles I::Call with Callee::Method
- Added: Proper v0 boxcall emission when NYASH_MIR_UNIFIED_CALL=0
- Location: src/runner/mir_json_emit.rs:641-707
- Test: emit_boxcall_length_canary_vm.sh → PASS

## Task B: strlen FAST EXE (AOT without plugin) 
- Fix: FAST lowering now tracks newbox(StringBox) creation
- Added: newbox_string_args fallback in boxcall.py (lines 133-143)
- Added: StringBox tracking in newbox.py (lines 82-91)
- Benefit: EXE can compute string.length() without StringBox plugin
- Test: s3_backend_selector_crate_exe_strlen_fast_canary_vm.sh → PASS (rc=5)

## Task 1: selfhost-first Diagnostic Logging 
- Added: HAKO_SELFHOST_TRACE=1 outputs Program JSON stats
- Added: HAKO_SELFHOST_NO_DELEGATE=1 shows detailed failure logs
- Added: [builder/selfhost-first:fail:*] markers + last 80 lines
- Location: tools/hakorune_emit_mir.sh:try_selfhost_builder()

## Task 2: loop JsonFrag Hit Rate Improvement 
- Added: FORCE=1 fallback for non-Lt comparison operators
- Added: find_any_local_int_before() fallback when strict fails
- Location: lang/src/mir/builder/internal/lower_loop_simple_box.hako
- Benefit: Higher JSONFrag hit rate under HAKO_MIR_BUILDER_LOOP_FORCE_JSONFRAG=1

## Task 3: crate EXE Failure Diagnostics 
- Added: LLVM IR dump on build failure (first 120 lines)
- Added: Build error log capture (last 40 lines)
- Location: tools/smokes/v2/profiles/quick/core/phase2100/stageb_loop_jsonfrag_crate_exe_canary_vm.sh

## Test Results
- emit_boxcall_length: PASS 
- strlen_fast (FAST=1): PASS (rc=5) 
- loop_jsonfrag: SKIP (diagnostic enhanced) ⚠️

## Implementation Principles
- 既定挙動不変 (Default unchanged)
- Dev toggle guarded (FAST=1, FORCE=1, TRACE=1, NO_DELEGATE=1)
- Minimal diff, easy rollback
- Clear failure diagnostics for future fixes

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-11 05:50:23 +09:00
parent b9e9c967fb
commit 0d41970313
8 changed files with 187 additions and 17 deletions

View File

@ -79,6 +79,17 @@ def lower_newbox(
handle = builder.call(new_i64x, [ptr, zero, zero, zero, zero, zero], name=f"new_{box_type}")
vmap[dst_vid] = handle
# Track StringBox creation for FAST path optimization
# If newbox(StringBox, [string_arg]), store dst_vid -> string_arg mapping
if box_type == "StringBox" and args and resolver is not None:
try:
if not hasattr(resolver, 'newbox_string_args'):
resolver.newbox_string_args = {}
# Map the resulting box handle to the string argument
resolver.newbox_string_args[dst_vid] = args[0]
except Exception:
pass # Silently ignore failures
def lower_newbox_generic(
builder: ir.IRBuilder,
module: ir.Module,