feat: Add VM instruction statistics and fix plugin TLV debugging
Major changes: - Add --vm-stats and --vm-stats-json CLI flags for VM instruction profiling - Implement instruction counting by opcode type with JSON output support - Add enhanced TLV debug logging with NYASH_DEBUG_PLUGIN=1 environment variable - Fix missing fields in CliConfig and ASTNode::BoxDeclaration for test compatibility - Improve plugin method call error messages with argument count/type details This enables MIR→VM conversion health checks and supports the Phase 8.6 VM optimization goals. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
20
src/cli.rs
20
src/cli.rs
@ -21,6 +21,8 @@ pub struct CliConfig {
|
||||
pub output_file: Option<String>,
|
||||
pub benchmark: bool,
|
||||
pub iterations: u32,
|
||||
pub vm_stats: bool,
|
||||
pub vm_stats_json: bool,
|
||||
}
|
||||
|
||||
impl CliConfig {
|
||||
@ -112,6 +114,18 @@ impl CliConfig {
|
||||
.help("Number of iterations for benchmarks (default: 10)")
|
||||
.default_value("10")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("vm-stats")
|
||||
.long("vm-stats")
|
||||
.help("Enable VM instruction statistics (equivalent to NYASH_VM_STATS=1)")
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
)
|
||||
.arg(
|
||||
Arg::new("vm-stats-json")
|
||||
.long("vm-stats-json")
|
||||
.help("Output VM statistics in JSON format")
|
||||
.action(clap::ArgAction::SetTrue)
|
||||
)
|
||||
}
|
||||
|
||||
/// Convert ArgMatches to CliConfig
|
||||
@ -128,6 +142,8 @@ impl CliConfig {
|
||||
output_file: matches.get_one::<String>("output").cloned(),
|
||||
benchmark: matches.get_flag("benchmark"),
|
||||
iterations: matches.get_one::<String>("iterations").unwrap().parse().unwrap_or(10),
|
||||
vm_stats: matches.get_flag("vm-stats"),
|
||||
vm_stats_json: matches.get_flag("vm-stats-json"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,9 +184,11 @@ mod tests {
|
||||
output_file: None,
|
||||
benchmark: false,
|
||||
iterations: 10,
|
||||
vm_stats: false,
|
||||
vm_stats_json: false,
|
||||
};
|
||||
|
||||
assert_eq!(config.backend, "interpreter");
|
||||
assert_eq!(config.iterations, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user