Phase 21.7 normalization: optimization pre-work + bench harness expansion

- Add opt-in optimizations (defaults OFF)
  - Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
  - strlen FAST enhancement for const handles
  - FAST_INT gate for same-BB SSA optimization
  - length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
  - Add branch/call/stringchain/arraymap/chip8/kilo cases
  - Auto-calculate ratio vs C reference
  - Document in benchmarks/README.md
- Compiler health improvements
  - Unify PHI insertion to insert_phi_at_head()
  - Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
  - Clarify Rust/Hako ownership boundaries
  - Strengthen receiver localization (LocalSSA/pin/after-PHIs)
  - Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries

🤖 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-13 16:40:58 +09:00
parent 9e2fa1e36e
commit dda65b94b7
160 changed files with 6773 additions and 1692 deletions

View File

@ -16,6 +16,17 @@ Notes
- The wrapper runs StageB with `NYASH_JSON_ONLY=1` to keep the output clean (no `RC:` lines).
- When the Hako MirBuilder fails (e.g., under development), it automatically falls back to `--program-json-to-mir` (no behavior change by default).
[Performance quickstart]
- MIR emit bench (StageB → MIR(JSON))
- `tools/perf/bench_hakorune_emit_mir.sh apps/examples/json_query/main.hako 5`
- Env toggles: `HAKO_USING_RESOLVER_FIRST=1`, `HAKO_SELFHOST_BUILDER_FIRST=1`
- MIR(JSON) → obj/exe benchny-llvmc/crate
- `NYASH_LLVM_BACKEND=crate tools/perf/bench_ny_mir_builder.sh /tmp/program.mir.json 3`
- Optional: `HAKO_LLVM_OPT_LEVEL=1`default O0
- MIR(JSON) structural compare
- `tools/perf/compare_mir_json.sh out_before.json out_after.json`
See also: docs/guides/perf/benchmarks.md
*[🇯🇵 日本語版はこちら / Japanese Version](README.ja.md)*
[![Selfhost Minimal](https://github.com/moe-charm/nyash/actions/workflows/selfhost-minimal.yml/badge.svg?branch=selfhosting-dev)](https://github.com/moe-charm/nyash/actions/workflows/selfhost-minimal.yml)
@ -30,6 +41,13 @@ Notes
Architecture notes
- Runtime rings (ring0/ring1/ring2) and provider policy: see `docs/architecture/RINGS.md`.
Call system (unified by default)
- Builder emits `Call { callee: Callee }` whenever possible; the VM routes by callee kind (Global/Method/Extern/... ).
- Legacy byname callscallee なし)は廃止。必ず Builder が `Callee` を付与する(付与されない場合は FailFast
- Extern dispatch SSOT lives in `src/backend/mir_interpreter/handlers/calls/externs.rs`. Global externlike names should delegate there (e.g., `env.get`).
- Extern arity normalization: names with arity suffix (e.g., `env.get/1`) are accepted and normalized to their base form (`env.get`).
See environment knobs and policies in `docs/ENV_VARS.md`.
Execution Status (Feature Additions Pause)
- Active
- `--backend llvm` (ny-llvmc crate backend; llvmlite harness is internal) — AOT object/EXE line