feat(phase21.5): MirBuilder optimization prep + crate EXE infrastructure
Phase 21.5 optimization readiness - C-level performance target: - MirBuilder: JsonFrag purify toggle (HAKO_MIR_BUILDER_JSONFRAG_PURIFY=1) - Normalizer: extended f64 canonicalization + dedupe improvements - loop_opts_adapter: JsonFrag path refinement for crate EXE compatibility Infrastructure improvements: - provider_registry: add diagnostics + ring-1 providers (array/console/map/path) - mir_interpreter: add normalization/purify feature gates - tools/selfhost_exe_stageb.sh: new end-to-end Stage-B→crate EXE pipeline - tools/perf/microbench.sh: performance measurement tooling Smoke tests (phase2100): - Extend timeout 15s→120s for heavy crate EXE builds - Add stageb_loop_jsonfrag_crate_exe_canary_vm.sh (target test) - Add s3_backend_selector_crate_exe_vm_parity_return42_canary_vm.sh Documentation: - ENV_VARS.md: add Phase 21.5 optimization toggles - README updates: clarify crate backend strategy - phase215-optimization.md: new optimization roadmap This commit sets the stage for Phase 21.5 critical optimization: achieving C-level performance to decide hakorune's future viability.
This commit is contained in:
@ -257,6 +257,11 @@ impl MirInterpreter {
|
||||
if Self::trace_enabled() {
|
||||
eprintln!("[vm-trace] inst bb={:?} {:?}", block.id, inst);
|
||||
}
|
||||
// Dev counters: count non-phi instructions and compares
|
||||
self.inst_count = self.inst_count.saturating_add(1);
|
||||
if let MirInstruction::Compare { .. } = inst {
|
||||
self.compare_count = self.compare_count.saturating_add(1);
|
||||
}
|
||||
self.execute_instruction(inst)?;
|
||||
}
|
||||
Ok(())
|
||||
@ -281,6 +286,8 @@ impl MirInterpreter {
|
||||
then_bb,
|
||||
else_bb,
|
||||
}) => {
|
||||
// Dev counter: count branch terminators actually evaluated
|
||||
self.branch_count = self.branch_count.saturating_add(1);
|
||||
let cond = self.reg_load(*condition)?;
|
||||
let branch = to_bool_vm(&cond).map_err(VMError::TypeError)?;
|
||||
let target = if branch { *then_bb } else { *else_bb };
|
||||
|
||||
@ -37,6 +37,10 @@ pub struct MirInterpreter {
|
||||
pub(super) static_boxes: HashMap<String, crate::instance_v2::InstanceBox>,
|
||||
// Static box declarations (metadata for creating instances)
|
||||
pub(super) static_box_decls: HashMap<String, crate::core::model::BoxDeclaration>,
|
||||
// Lightweight dev counters (opt-in print via NYASH_VM_STATS=1)
|
||||
pub(super) inst_count: u64,
|
||||
pub(super) branch_count: u64,
|
||||
pub(super) compare_count: u64,
|
||||
}
|
||||
|
||||
impl MirInterpreter {
|
||||
@ -51,9 +55,17 @@ impl MirInterpreter {
|
||||
last_inst: None,
|
||||
static_boxes: HashMap::new(),
|
||||
static_box_decls: HashMap::new(),
|
||||
inst_count: 0,
|
||||
branch_count: 0,
|
||||
compare_count: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return (inst_count, branch_count, compare_count)
|
||||
pub fn stats_counters(&self) -> (u64, u64, u64) {
|
||||
(self.inst_count, self.branch_count, self.compare_count)
|
||||
}
|
||||
|
||||
/// Register static box declarations (called from vm.rs during setup)
|
||||
pub fn register_static_box_decl(&mut self, name: String, decl: crate::core::model::BoxDeclaration) {
|
||||
self.static_box_decls.insert(name, decl);
|
||||
|
||||
Reference in New Issue
Block a user