Files
hakorune/docs/private/roadmap/phases/phase-20.12a

Phase20.12a — Hardcoding Cleanup (Lowering hygiene)

Scope (safe, reversible)

  • Name normalization via table (SSOT) instead of if chains in mir_call.py.
  • Tail/fastcc hinting: move logic toward helpers (no behavior change; stricter gating optional).
  • Method byid: gated route (NYASH_LLVM_METHOD_BY_ID=1) using stable 64bit hash (FNV1a). Fallback to byname kept.
  • Bench hooks (barrier/noop): normalized via alias table (dev only; AOT shim symbols).
  • ErrorBox unification (first wave): replace adhoc "Error: ..." StringBox in Divide/Modulo/Random/Time/HTTPServer with structured ErrorBox.
  • Arithmetic Extended: minimal compute_auto() + chain() for Subtract/Mul/Div (delegating to legacy execute by default).
  • PHI hardening: register block_phi_incomings on creation and autoenable PHI postprocess under strict mode to avoid empty PHI text lines.
  • Bench externs: specialcase Env.bench.print_i64/1/noop_i64/1/use_value/1 to void(i64) declarations and calls (fair, robust lowering path).

New micro benches (optimizationresistant)

  • tools/bench/run_inproc_mix_alu_resisted.sh — periteration value sink (use_value) for ALU loop.
  • tools/bench/run_inproc_call_noop_resisted.sh — periteration noop call. C side mirrors via noinline+asm barrier.

Nongoals (defer to 20.13)

  • Full externs registry ingestion from Rust at runtime.
  • Method byid defaulting and runtime registry integration.
  • Wide refactors beyond lowering helpers (keep deltas minimal).

Why (benefits)

  • Reduce adhoc hardcoding in lowering; improve readability and testability.
  • Keep mir_call.py focused on bridging, not string alias trivia.
  • Prepare byid migration without changing defaults.

Gates

  • NYASH_LLVM_METHOD_BY_ID=1 → use invoke_by_id if available (fallback byname)
  • NYASH_LLVM_TAILCALL_STRICT=1 → strict tail placement (same CC, at block ret, unused dst)

Files

  • src/llvm_py/consts/externs.py: add ALIASES (alias → canonical)
  • src/llvm_py/instructions/mir_call.py: _normalize_extern_name() uses table lookups; optional byid path
  • lang/c-abi/shims/hako_kernel.c: add hako_bench_noop_i64()

Validation

  • IR dump pre/post: NYASH_LLVM_DUMP_IR, NYASH_LLVM_DUMP_OPT_IR
  • Quick benches (inproc) unchanged semantics; div(2^k) requires NYASH_LLVM_UDIV_POW2=1 + NYASH_LLVM_ASSUME_UNSIGNED=1

Rollback

  • Remove ALIASES and revert _normalize_extern_name to explicit ifchains.
  • Disable NYASH_LLVM_METHOD_BY_ID gate.