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

@ -99,6 +99,7 @@ impl InstanceBox {
);
}
let legacy_enabled = crate::config::env::legacy_fields_enable();
Self {
class_name,
fields_ng: Arc::new(Mutex::new(field_map)),
@ -106,8 +107,8 @@ impl InstanceBox {
inner_content: None, // ユーザー定義は内包Boxなし
base: BoxBase::new(),
finalized: Arc::new(Mutex::new(false)),
// レガシー互換フィールド
fields: Some(Arc::new(Mutex::new(legacy_field_map))),
// レガシー互換フィールド既定OFF
fields: if legacy_enabled { Some(Arc::new(Mutex::new(legacy_field_map))) } else { None },
init_field_order: fields,
weak_fields_union: std::collections::HashSet::new(),
in_finalization: Arc::new(Mutex::new(false)),
@ -233,7 +234,8 @@ impl InstanceBox {
fields.lock().unwrap().insert(field_name, arc_box);
Ok(())
} else {
Err("Legacy fields not initialized".to_string())
// 既定OFFのため何もしない互換不要。必要なら NYASH_LEGACY_FIELDS_ENABLE=1 を設定。
Ok(())
}
}
@ -270,7 +272,12 @@ impl InstanceBox {
Ok(())
} else {
Err("Legacy fields not initialized".to_string())
// 既定OFF: fields_ng のみ更新Null 占位。整合を壊さないようにOK返す。
self.fields_ng
.lock()
.unwrap()
.insert(field_name.to_string(), NyashValue::Null);
Ok(())
}
}