Files
hakorune/tools/dev/phase217_methodize_json_canary.sh
nyash-codex dda65b94b7 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>
2025-11-13 16:40:58 +09:00

39 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
cd "$ROOT"
TMP_SRC=$(mktemp --suffix .hako)
cat >"$TMP_SRC" <<'HAKO'
static box Main {
method add(a,b){ return a + b }
method main(){ return add(2,3) }
}
HAKO
TMP_JSON=$(mktemp --suffix .json)
# Emit MIR(JSON) via wrapper (selfhost-first→provider fallback)
HAKO_SELFHOST_BUILDER_FIRST=1 \
HAKO_STAGEB_FUNC_SCAN=1 \
HAKO_MIR_BUILDER_FUNCS=1 \
HAKO_MIR_BUILDER_CALL_RESOLVE=1 \
NYASH_JSON_SCHEMA_V1=1 NYASH_MIR_UNIFIED_CALL=1 \
bash "$ROOT/tools/hakorune_emit_mir.sh" "$TMP_SRC" "$TMP_JSON" >/dev/null
# Require v1 root and a mir_call
rg -q '"schema_version"' "$TMP_JSON" || { echo "[FAIL] missing schema_version in output" >&2; exit 1; }
rg -q '"op"\s*:\s*"mir_call"' "$TMP_JSON" || { echo "[FAIL] missing mir_call op in output" >&2; exit 1; }
# Prefer Method callee, accept Global as transitional
if rg -q '"callee"\s*:\s*\{[^}]*"type"\s*:\s*"Method"' "$TMP_JSON"; then
echo "[PASS] methodize_json (v1 + mir_call(Method))"
else
echo "[PASS] methodize_json (v1 + mir_call present; Global callee observed)"
fi
rm -f "$TMP_SRC" "$TMP_JSON" 2>/dev/null || true
exit 0