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

@ -67,7 +67,7 @@ static box Main {
}
// Evaluate a simple JSON path by slicing JSON text directly (no full parse)
// Returns a JSON substring for the value or null if not found
// Returns a JSON substring for the value or the string "null" if not found
eval_path_text(json_text, path) {
local DEBUG = 0 // set to 1 for ad-hoc debug
local cur_text = json_text
@ -87,11 +87,11 @@ static box Main {
}
local key = path.substring(start, i)
if DEBUG == 1 { print("[dbg] key=" + key) }
if key.length() == 0 { return null }
if key.length() == 0 { return "null" }
// Get value text directly; then reset window to that text
local next_text = this.object_get_text(cur_text, 0, cur_text.length(), key)
if DEBUG == 1 { if next_text == null { print("[dbg] obj miss") } else { print("[dbg] obj hit len=" + next_text.length()) } }
if next_text == null { return null }
if next_text == null { return "null" }
cur_text = next_text
} else {
if ch == "[" {
@ -102,16 +102,16 @@ static box Main {
loop(i < path.length() && this.is_digit(path.substring(i, i + 1))) { i = i + 1 }
local idx_str = path.substring(start, i)
if DEBUG == 1 { print("[dbg] idx_str=" + idx_str + ", next=" + path.substring(i, i + 1)) }
if i >= path.length() || path.substring(i, i + 1) != "]" { return null }
if i >= path.length() || path.substring(i, i + 1) != "]" { return "null" }
i = i + 1 // skip ']'
local idx = this.parse_int(idx_str)
if DEBUG == 1 { print("[dbg] idx=" + idx) }
local next_text = this.array_get_text(cur_text, 0, cur_text.length(), idx)
if DEBUG == 1 { if next_text == null { print("[dbg] arr miss idx=" + idx_str) } else { print("[dbg] arr hit len=" + next_text.length()) } }
if next_text == null { return null }
if next_text == null { return "null" }
cur_text = next_text
} else {
return null
return "null"
}
}
}